- Timestamp:
- 03/26/16 11:10:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs
r13583 r13736 325 325 326 326 foreach (var group in groupedRuns) { 327 var hits = new Dictionary<string, SortedList<double, double>>(); 327 // hits describes the number of target hits at a certain time for a certain group 328 var hits = new Dictionary<string, SortedList<double, int>>(); 329 // misses describes the number of target misses after a certain time for a certain group 330 // for instance when a run ends, but has not achieved all targets, misses describes 331 // how many targets have been left open at the point when the run ended 332 var misses = new Dictionary<string, SortedList<double, int>>(); 328 333 var maxLength = 0.0; 329 334 335 var noRuns = 0; 330 336 foreach (var problem in group.Value) { 331 337 foreach (var run in problem.Value.Item2) { … … 334 340 335 341 if (eachOrAllTargetCheckBox.Checked) { 336 CalculateHitsForEachTarget(hits, resultsTable.Rows.First(), problem.Key, group.Key, group.Value.Count, problem.Value.Item1, problem.Value.Item2.Count); 342 CalculateHitsForEachTarget(hits, misses, resultsTable.Rows.First(), problem.Key, group.Key, problem.Value.Item1); 343 // achiving each target can be seen as a separate run for that target only 344 noRuns += targets.Length; 337 345 } else { 338 maxLength = CalculateHitsForAllTargets(hits, resultsTable.Rows.First(), problem.Key, group.Key, group.Value.Count, problem.Value.Item1, problem.Value.Item2.Count); 346 var length = CalculateHitsForAllTargets(hits, misses, resultsTable.Rows.First(), problem.Key, group.Key, problem.Value.Item1); 347 maxLength = Math.Max(length, maxLength); 348 noRuns++; 339 349 } 340 350 } … … 351 361 }; 352 362 353 var total = 0.0; 363 var ecdf = 0.0; 364 var iter = misses[list.Key].GetEnumerator(); 365 iter.MoveNext(); 366 var sumTargets = noRuns * targets.Length; 354 367 foreach (var h in list.Value) { 355 total += h.Value; 356 row.Values.Add(Tuple.Create(h.Key, total)); 368 ecdf += h.Value; 369 while (iter.Current.Key < h.Key) { 370 sumTargets -= iter.Current.Value; 371 if (!iter.MoveNext()) break; 372 } 373 row.Values.Add(Tuple.Create(h.Key, ecdf / sumTargets)); 357 374 } 358 375 359 376 if (maxLength > 0 && (row.Values.Count == 0 || row.Values.Last().Item1 < maxLength)) 360 row.Values.Add(Tuple.Create(maxLength, total));377 row.Values.Add(Tuple.Create(maxLength, ecdf / sumTargets)); 361 378 362 379 byTargetDataTable.Rows.Add(row); … … 382 399 } 383 400 384 private void CalculateHitsForEachTarget(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, ProblemDescription problem, string group, int groupCount, double bestTarget, int problemCount) { 401 private void CalculateHitsForEachTarget(Dictionary<string, SortedList<double, int>> hits, 402 Dictionary<string, SortedList<double, int>> misses, 403 IndexedDataRow<double> row, ProblemDescription problem, 404 string group, double bestTarget) { 385 405 foreach (var l in targets.Select(x => (problem.IsMaximization() ? (1 - x) : (1 + x)) * bestTarget)) { 386 406 var key = group + "-" + l; 387 if (!hits.ContainsKey(key)) hits.Add(key, new SortedList<double, double>()); 407 if (!hits.ContainsKey(key)) { 408 hits.Add(key, new SortedList<double, int>()); 409 misses.Add(key, new SortedList<double, int>()); 410 } 411 var hit = false; 388 412 foreach (var v in row.Values) { 389 413 if (problem.IsMaximization() && v.Item2 >= l || !problem.IsMaximization() && v.Item2 <= l) { 390 414 if (hits[key].ContainsKey(v.Item1)) 391 hits[key][v.Item1] += 1.0 / (groupCount * problemCount); 392 else hits[key][v.Item1] = 1.0 / (groupCount * problemCount); 415 hits[key][v.Item1]++; 416 else hits[key][v.Item1] = 1; 417 hit = true; 393 418 break; 394 419 } 395 420 } 396 } 397 } 398 399 private double CalculateHitsForAllTargets(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, ProblemDescription problem, string group, int groupCount, double bestTarget, int problemCount) { 421 if (!hit) { 422 var max = row.Values.Last(); 423 if (misses[key].ContainsKey(max.Item1)) 424 misses[key][max.Item1]++; 425 else misses[key][max.Item1] = 1; 426 } 427 } 428 } 429 430 private double CalculateHitsForAllTargets(Dictionary<string, SortedList<double, int>> hits, 431 Dictionary<string, SortedList<double, int>> misses, 432 IndexedDataRow<double> row, ProblemDescription problem, 433 string group, double bestTarget) { 400 434 var values = row.Values; 401 if (!hits.ContainsKey(group)) hits.Add(group, new SortedList<double, double>()); 435 if (!hits.ContainsKey(group)) { 436 hits.Add(group, new SortedList<double, int>()); 437 misses.Add(group, new SortedList<double, int>()); 438 } 402 439 403 440 var i = 0; … … 408 445 if (problem.IsMaximization() && current.Item2 >= target 409 446 || !problem.IsMaximization() && current.Item2 <= target) { 410 if ( !hits[group].ContainsKey(current.Item1)) hits[group][current.Item1] = 0;411 hits[group][current.Item1] += 1.0 / (groupCount * problemCount * targets.Length);447 if (hits[group].ContainsKey(current.Item1)) hits[group][current.Item1]++; 448 else hits[group][current.Item1] = 1; 412 449 i++; 413 450 } else { … … 416 453 } 417 454 if (j == values.Count) j--; 455 if (i < targets.Length) { 456 if (misses[group].ContainsKey(values[j].Item1)) 457 misses[group][values[j].Item1] += targets.Length - i; 458 else misses[group][values[j].Item1] = targets.Length - i; 459 } 418 460 return values[j].Item1; 419 461 }
Note: See TracChangeset
for help on using the changeset viewer.