Changeset 12803
- Timestamp:
- 07/24/15 15:31:54 (9 years ago)
- Location:
- branches/PerformanceComparison
- Files:
-
- 1 added
- 4 edited
- 1 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Analysis/3.3/Optimizers/IRRRun.cs
r12764 r12803 25 25 using System.Drawing; 26 26 using System.Linq; 27 using System.Threading.Tasks;28 using HeuristicLab.Collections;29 27 using HeuristicLab.Common; 30 28 using HeuristicLab.Common.Resources; 31 29 using HeuristicLab.Core; 30 using HeuristicLab.Data; 31 using HeuristicLab.Optimization; 32 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 33 34 namespace HeuristicLab.Optimization { 34 namespace HeuristicLab.Analysis { 35 public enum TerminationCriterium { OnlyByTime, OnlyByEvaluations, OnlyByTarget, ByTargetAndTime, ByTargetAndEvaluations, WhicheverHitsFirst, WhicheverHitsLast } 35 36 /// <summary> 36 37 /// A run in which an algorithm is executed for a certain maximum time only. 37 38 /// </summary> 38 [Item(" Timelimit Run", "A run in which an optimizer is executed a certain maximum time.")]39 [Creatable(CreatableAttribute.Categories.TestingAndAnalysis, Priority = 11 5)]39 [Item("Independent Random Restart Run", "A run in which an optimizer is repeated until either a certain target value is reached or a maximum budget is exceeded.")] 40 [Creatable(CreatableAttribute.Categories.TestingAndAnalysis, Priority = 117)] 40 41 [StorableClass] 41 public sealed class TimeLimitRun : NamedItem, IOptimizer, IStorableContent, INotifyPropertyChanged {42 public sealed class IndepdentRandomRestartRun : NamedItem, IOptimizer, IStorableContent, INotifyPropertyChanged { 42 43 public string Filename { get; set; } 43 44 … … 51 52 #endregion 52 53 53 private bool pausedForSnapshot = false; 54 private bool pausedForTermination = false; 54 [Storable] 55 private TerminationCriterium terminationCriterium; 56 public TerminationCriterium TerminationCriterium { 57 get { return terminationCriterium; } 58 set { 59 if (terminationCriterium == value) return; 60 terminationCriterium = value; 61 OnPropertyChanged("TerminationCriterium"); 62 } 63 } 55 64 56 65 [Storable] … … 66 75 67 76 [Storable] 68 private int snapshotTimesIndex; 69 [Storable] 70 private ObservableList<TimeSpan> snapshotTimes; 71 public ObservableList<TimeSpan> SnapshotTimes { 72 get { return snapshotTimes; } 73 set { 74 if (snapshotTimes == value) return; 75 snapshotTimes = value; 76 snapshotTimes.Sort(); 77 FindNextSnapshotTimeIndex(ExecutionTime); 78 OnPropertyChanged("SnapshotTimes"); 79 } 80 } 81 82 [Storable] 83 private bool storeAlgorithmInEachSnapshot; 84 [Storable] 85 public bool StoreAlgorithmInEachSnapshot { 86 get { return storeAlgorithmInEachSnapshot; } 87 set { 88 if (storeAlgorithmInEachSnapshot == value) return; 89 storeAlgorithmInEachSnapshot = value; 90 OnPropertyChanged("StoreAlgorithmInEachSnapshot"); 91 } 92 } 93 94 [Storable] 95 private RunCollection snapshots; 96 public RunCollection Snapshots { 97 get { return snapshots; } 98 set { 99 if (snapshots == value) return; 100 snapshots = value; 101 OnPropertyChanged("Snapshots"); 102 } 103 } 104 105 #region Inherited Properties 77 private int maximumEvaluations; 78 public int MaximumEvaluations { 79 get { return maximumEvaluations; } 80 set { 81 if (maximumEvaluations == value) return; 82 maximumEvaluations = value; 83 OnPropertyChanged("MaximumEvaluations"); 84 } 85 } 86 87 [Storable] 88 private double targetValue; 89 public double TargetValue { 90 get { return targetValue; } 91 set { 92 if (targetValue == value) return; 93 targetValue = value; 94 OnPropertyChanged("TargetValue"); 95 } 96 } 97 98 [Storable] 99 private bool maximization; 100 public bool Maximization { 101 get { return maximization; } 102 private set { 103 if (maximization == value) return; 104 maximization = value; 105 OnPropertyChanged("Maximization"); 106 } 107 } 108 109 [Storable] 110 private double moveCostPerSolution; 111 public double MoveCostPerSolution { 112 get { return moveCostPerSolution; } 113 set { 114 if (moveCostPerSolution == value) return; 115 moveCostPerSolution = value; 116 OnPropertyChanged("MoveCostPerSolution"); 117 } 118 } 119 120 106 121 public ExecutionState ExecutionState { 107 122 get { return (Algorithm != null) ? Algorithm.ExecutionState : ExecutionState.Stopped; } 108 123 } 109 124 125 private TimeSpan lastAlgorithmExecutionTime; 126 [Storable] 127 private TimeSpan executionTime; 110 128 public TimeSpan ExecutionTime { 111 get { return (Algorithm != null) ? Algorithm.ExecutionTime : TimeSpan.FromSeconds(0); } 129 get { return executionTime; } 130 set { 131 if (executionTime == value) return; 132 executionTime = value; 133 OnPropertyChanged("ExecutionTime"); 134 OnExecutionTimeChanged(); 135 } 136 } 137 138 private int lastAlgorithmEvaluatedSolutions; 139 private int lastAlgorithmEvaluatedMoves; 140 [Storable] 141 private double evaluations; 142 public double Evaluations { 143 get { return evaluations; } 144 set { 145 if (evaluations == value) return; 146 evaluations = value; 147 OnPropertyChanged("Evaluations"); 148 } 149 } 150 151 [Storable] 152 private double bestSoFar; 153 public double BestSoFar { 154 get { return bestSoFar; } 155 set { 156 if (bestSoFar == value) return; 157 bestSoFar = value; 158 OnPropertyChanged("BestSoFar"); 159 } 160 } 161 162 [Storable] 163 private IRun currentRun; 164 public IRun CurrentRun { 165 get { return currentRun; } 166 private set { 167 if (currentRun == value) return; 168 currentRun = value; 169 OnPropertyChanged("CurrentRun"); 170 } 112 171 } 113 172 … … 148 207 } 149 208 } 150 #endregion 209 210 private bool IsFinished { 211 get { 212 var timeHit = ExecutionTime >= MaximumExecutionTime; 213 var evalHit = Evaluations >= MaximumEvaluations; 214 var targetHit = (Maximization && BestSoFar >= TargetValue || !Maximization && BestSoFar <= TargetValue); 215 216 return timeHit && evalHit && targetHit 217 || timeHit && (TerminationCriterium == TerminationCriterium.OnlyByTime 218 || TerminationCriterium == TerminationCriterium.ByTargetAndTime 219 || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst) 220 || evalHit && (TerminationCriterium == TerminationCriterium.OnlyByEvaluations 221 || TerminationCriterium == TerminationCriterium.ByTargetAndEvaluations 222 || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst) 223 || targetHit && (TerminationCriterium == TerminationCriterium.OnlyByTarget 224 || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst 225 || TerminationCriterium == TerminationCriterium.ByTargetAndTime 226 || TerminationCriterium == TerminationCriterium.ByTargetAndEvaluations); 227 } 228 } 151 229 152 230 [StorableConstructor] 153 private TimeLimitRun(bool deserializing) : base(deserializing) { }154 private TimeLimitRun(TimeLimitRun original, Cloner cloner)231 private IndepdentRandomRestartRun(bool deserializing) : base(deserializing) { } 232 private IndepdentRandomRestartRun(IndepdentRandomRestartRun original, Cloner cloner) 155 233 : base(original, cloner) { 234 terminationCriterium = original.terminationCriterium; 156 235 maximumExecutionTime = original.maximumExecutionTime; 157 snapshotTimes = new ObservableList<TimeSpan>(original.snapshotTimes); 158 snapshotTimesIndex = original.snapshotTimesIndex; 159 snapshots = cloner.Clone(original.snapshots); 160 storeAlgorithmInEachSnapshot = original.storeAlgorithmInEachSnapshot; 236 maximumEvaluations = original.maximumEvaluations; 237 targetValue = original.targetValue; 238 executionTime = original.executionTime; 239 evaluations = original.evaluations; 240 bestSoFar = original.bestSoFar; 241 lastAlgorithmExecutionTime = original.lastAlgorithmExecutionTime; 242 lastAlgorithmEvaluatedSolutions = original.lastAlgorithmEvaluatedSolutions; 243 lastAlgorithmEvaluatedMoves = original.lastAlgorithmEvaluatedMoves; 244 161 245 algorithm = cloner.Clone(original.algorithm); 162 246 runs = cloner.Clone(original.runs); … … 164 248 Initialize(); 165 249 } 166 public TimeLimitRun()250 public IndepdentRandomRestartRun() 167 251 : base() { 168 252 name = ItemName; 169 253 description = ItemDescription; 170 maximumExecutionTime = TimeSpan.FromMinutes(.5); 171 snapshotTimes = new ObservableList<TimeSpan>(new[] { 172 TimeSpan.FromSeconds(5), 173 TimeSpan.FromSeconds(10), 174 TimeSpan.FromSeconds(15) }); 175 snapshotTimesIndex = 0; 176 snapshots = new RunCollection(); 254 terminationCriterium = TerminationCriterium.OnlyByEvaluations; 255 maximumExecutionTime = TimeSpan.FromMinutes(1); 256 maximumEvaluations = 10000000; // 10 mio 257 targetValue = 0; 258 executionTime = TimeSpan.Zero; 259 evaluations = 0; 260 bestSoFar = double.NaN; 261 lastAlgorithmExecutionTime = TimeSpan.Zero; 262 lastAlgorithmEvaluatedSolutions = 0; 263 lastAlgorithmEvaluatedMoves = 0; 264 177 265 Runs = new RunCollection { OptimizerName = Name }; 178 266 Initialize(); 179 267 } 180 public TimeLimitRun(string name)268 public IndepdentRandomRestartRun(string name) 181 269 : base(name) { 182 270 description = ItemDescription; 183 maximumExecutionTime = TimeSpan.FromMinutes(.5); 184 snapshotTimes = new ObservableList<TimeSpan>(new[] { 185 TimeSpan.FromSeconds(5), 186 TimeSpan.FromSeconds(10), 187 TimeSpan.FromSeconds(15) }); 188 snapshotTimesIndex = 0; 271 terminationCriterium = TerminationCriterium.OnlyByEvaluations; 272 maximumExecutionTime = TimeSpan.FromMinutes(1); 273 maximumEvaluations = 10000000; // 10 mio 274 targetValue = 0; 275 executionTime = TimeSpan.Zero; 276 evaluations = 0; 277 bestSoFar = double.NaN; 278 lastAlgorithmExecutionTime = TimeSpan.Zero; 279 lastAlgorithmEvaluatedSolutions = 0; 280 lastAlgorithmEvaluatedMoves = 0; 281 189 282 Runs = new RunCollection { OptimizerName = Name }; 190 283 Initialize(); 191 284 } 192 public TimeLimitRun(string name, string description)285 public IndepdentRandomRestartRun(string name, string description) 193 286 : base(name, description) { 194 maximumExecutionTime = TimeSpan.FromMinutes(.5); 195 snapshotTimes = new ObservableList<TimeSpan>(new[] { 196 TimeSpan.FromSeconds(5), 197 TimeSpan.FromSeconds(10), 198 TimeSpan.FromSeconds(15) }); 199 snapshotTimesIndex = 0; 287 terminationCriterium = TerminationCriterium.OnlyByEvaluations; 288 maximumExecutionTime = TimeSpan.FromMinutes(1); 289 maximumEvaluations = 10000000; // 10 mio 290 targetValue = 0; 291 executionTime = TimeSpan.Zero; 292 evaluations = 0; 293 bestSoFar = double.NaN; 294 lastAlgorithmExecutionTime = TimeSpan.Zero; 295 lastAlgorithmEvaluatedSolutions = 0; 296 lastAlgorithmEvaluatedMoves = 0; 297 200 298 Runs = new RunCollection { OptimizerName = Name }; 201 299 Initialize(); … … 204 302 public override IDeepCloneable Clone(Cloner cloner) { 205 303 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState)); 206 return new TimeLimitRun(this, cloner);304 return new IndepdentRandomRestartRun(this, cloner); 207 305 } 208 306 … … 214 312 private void Initialize() { 215 313 if (algorithm != null) RegisterAlgorithmEvents(); 216 snapshotTimes.ItemsAdded += snapshotTimes_Changed;217 snapshotTimes.ItemsMoved += snapshotTimes_Changed;218 snapshotTimes.ItemsRemoved += snapshotTimes_Changed;219 snapshotTimes.ItemsReplaced += snapshotTimes_Changed;220 snapshotTimes.CollectionReset += snapshotTimes_Changed;221 }222 223 private void snapshotTimes_Changed(object sender, CollectionItemsChangedEventArgs<IndexedItem<TimeSpan>> e) {224 if (e.Items.Any()) snapshotTimes.Sort();225 FindNextSnapshotTimeIndex(ExecutionTime);226 }227 228 public void Snapshot() {229 if (Algorithm == null || Algorithm.ExecutionState != ExecutionState.Paused) throw new InvalidOperationException("Snapshot not allowed in execution states other than Paused");230 Task.Factory.StartNew(MakeSnapshot);231 314 } 232 315 … … 235 318 } 236 319 public void Prepare(bool clearRuns) { 320 executionTime = TimeSpan.Zero; 321 evaluations = 0; 322 lastAlgorithmExecutionTime = TimeSpan.Zero; 323 lastAlgorithmEvaluatedSolutions = 0; 324 237 325 Algorithm.Prepare(clearRuns); 238 326 } 239 327 public void Start() { 328 if (ExecutionState == ExecutionState.Prepared) { 329 currentRun = new Run(Algorithm) { 330 Name = Algorithm.Name + " IRRRun" + Runs.Count 331 }; 332 } 240 333 Algorithm.Start(); 241 334 } … … 306 399 algorithm.Started += Algorithm_Started; 307 400 algorithm.Stopped += Algorithm_Stopped; 401 algorithm.ProblemChanged += Algorithm_ProblemChanged; 308 402 } 309 403 private void DeregisterAlgorithmEvents() { … … 315 409 algorithm.Started -= Algorithm_Started; 316 410 algorithm.Stopped -= Algorithm_Stopped; 411 algorithm.ProblemChanged -= Algorithm_ProblemChanged; 317 412 } 318 413 private void Algorithm_ExceptionOccurred(object sender, EventArgs<Exception> e) { … … 320 415 } 321 416 private void Algorithm_ExecutionTimeChanged(object sender, EventArgs e) { 322 if (snapshotTimesIndex < SnapshotTimes.Count && ExecutionTime >= SnapshotTimes[snapshotTimesIndex] 323 && !pausedForSnapshot) { 324 pausedForSnapshot = true; 325 Algorithm.Pause(); 326 } 327 if (ExecutionTime >= MaximumExecutionTime && !pausedForTermination) { 328 pausedForTermination = true; 329 if (!pausedForSnapshot) Algorithm.Pause(); 417 ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime; 418 lastAlgorithmExecutionTime = Algorithm.ExecutionTime; 419 420 UpdateAlgorithmResults(); 421 422 if (IsFinished) { 423 Algorithm.Stop(); 330 424 } 331 425 OnExecutionTimeChanged(); 332 426 } 427 333 428 private void Algorithm_ExecutionStateChanged(object sender, EventArgs e) { 334 429 OnExecutionStateChanged(); 335 430 } 336 431 private void Algorithm_Paused(object sender, EventArgs e) { 337 var action = pausedForTermination ? ExecutionState.Stopped : (pausedForSnapshot ? ExecutionState.Started : ExecutionState.Paused); 338 if (pausedForSnapshot || pausedForTermination) { 339 pausedForSnapshot = pausedForTermination = false; 340 MakeSnapshot(); 341 FindNextSnapshotTimeIndex(ExecutionTime); 342 } 432 ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime; 433 lastAlgorithmExecutionTime = Algorithm.ExecutionTime; 434 435 UpdateAlgorithmResults(); 343 436 OnPaused(); 344 if (action == ExecutionState.Started) Algorithm.Start();345 else if (action == ExecutionState.Stopped) Algorithm.Stop();346 437 } 347 438 private void Algorithm_Prepared(object sender, EventArgs e) { 348 snapshotTimesIndex = 0;349 snapshots.Clear();350 439 OnPrepared(); 351 440 } … … 354 443 } 355 444 private void Algorithm_Stopped(object sender, EventArgs e) { 445 ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime; 446 lastAlgorithmExecutionTime = Algorithm.ExecutionTime; 447 448 var bestQuality = UpdateAlgorithmResults(); 449 450 foreach (var result in Algorithm.Results) { 451 if (result.Name == "QualityPerClock") { 452 if (!currentRun.Results.ContainsKey(result.Name)) 453 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 454 else { 455 var dt = (IndexedDataTable<double>)currentRun.Results[result.Name]; 456 var execTime = ((TimeSpanValue)currentRun.Results["ExecutionTime"]).Value.TotalSeconds; 457 var best = dt.Rows.First().Values.Last().Item2; 458 var resultDt = (IndexedDataTable<double>)result.Value; 459 foreach (var tupl in resultDt.Rows.First().Values) { 460 if (Maximization && tupl.Item2 > best || !Maximization && tupl.Item2 < best) { 461 dt.Rows.First().Values.Add(Tuple.Create(execTime + tupl.Item1, tupl.Item2)); 462 best = tupl.Item2; 463 } 464 } 465 } 466 } else if (result.Name == "QualityPerEvaluations") { 467 if (!currentRun.Results.ContainsKey(result.Name)) 468 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 469 else { 470 var dt = (IndexedDataTable<double>)currentRun.Results[result.Name]; 471 var evalSols = ((DoubleValue)currentRun.Results["EvaluatedSolutions"]).Value; 472 var evalMoves = ((DoubleValue)currentRun.Results["EvaluatedMoves"]).Value; 473 var best = dt.Rows.First().Values.Last().Item2; 474 var resultDt = (IndexedDataTable<double>)result.Value; 475 foreach (var tupl in resultDt.Rows.First().Values) { 476 if (Maximization && tupl.Item2 > best || !Maximization && tupl.Item2 < best) { 477 dt.Rows.First().Values.Add(Tuple.Create(evalSols + moveCostPerSolution * evalMoves + tupl.Item1, tupl.Item2)); 478 best = tupl.Item2; 479 } 480 } 481 } 482 } else if (result.Name == "EvaluatedSolutions") { 483 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 484 } else if (result.Name == "EvaluatedMoves") { 485 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 486 } else if (result.Name == "ExecutionTime") { 487 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 488 } else if (result.Name == "BestQuality") { 489 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 490 } else if (result.Name.ToLower().EndsWith("solution") && BestSoFar == bestQuality) { 491 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 492 } 493 } 494 foreach (var result in Algorithm.Results) { 495 if (result.Name == "QualityPerClock") { 496 497 } else if (result.Name == "QualityPerEvaluations") { 498 } else if (result.Name == "EvaluatedSolutions") { 499 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 500 } else if (result.Name == "EvaluatedMoves") { 501 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 502 } else if (result.Name == "ExecutionTime") { 503 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 504 } else if (result.Name == "BestQuality") { 505 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 506 } else if (result.Name.ToLower().EndsWith("solution") && BestSoFar == bestQuality) { 507 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 508 } 509 } 510 511 512 if (IsFinished) { 513 514 } 515 516 // TODO 356 517 var cloner = new Cloner(); 357 518 var algRun = cloner.Clone(Algorithm.Runs.Last()); 358 var clonedSnapshots = cloner.Clone(snapshots);359 algRun.Results.Add("TimeLimitRunSnapshots", clonedSnapshots);360 519 Runs.Add(algRun); 361 520 Algorithm.Runs.Clear(); 362 521 OnStopped(); 363 522 } 523 524 private double UpdateAlgorithmResults() { 525 IResult evaluationsResult; 526 if (Algorithm.Results.TryGetValue("EvaluatedSolutions", out evaluationsResult)) { 527 var evals = ((IntValue)evaluationsResult.Value).Value; 528 Evaluations += evals - lastAlgorithmEvaluatedSolutions; 529 lastAlgorithmEvaluatedSolutions = evals; 530 } 531 if (Algorithm.Results.TryGetValue("EvaluatedMoves", out evaluationsResult)) { 532 var evals = ((IntValue)evaluationsResult.Value).Value; 533 Evaluations += moveCostPerSolution * (evals - lastAlgorithmEvaluatedMoves); 534 lastAlgorithmEvaluatedMoves = evals; 535 } 536 if (Algorithm.Results.TryGetValue("BestQuality", out evaluationsResult)) { 537 var bestQuality = ((DoubleValue)evaluationsResult).Value; 538 if (double.IsNaN(BestSoFar) 539 || Maximization && bestQuality > BestSoFar 540 || !Maximization && bestQuality < BestSoFar) 541 BestSoFar = bestQuality; 542 return bestQuality; 543 } 544 return double.NaN; 545 } 546 547 private void Algorithm_ProblemChanged(object sender, EventArgs e) { 548 var soProblem = Algorithm.Problem as ISingleObjectiveHeuristicOptimizationProblem; 549 if (soProblem == null) return; 550 var maxParam = soProblem.MaximizationParameter as IValueParameter<BoolValue>; 551 if (maxParam != null) 552 Maximization = maxParam.Value.Value; 553 var bkParam = soProblem.BestKnownQualityParameter as IValueParameter<DoubleValue>; 554 if (bkParam != null && bkParam.Value != null) 555 TargetValue = bkParam.Value.Value; 556 } 364 557 #endregion 365 558 #endregion 366 367 private void FindNextSnapshotTimeIndex(TimeSpan reference) {368 var index = 0;369 while (index < snapshotTimes.Count && snapshotTimes[index] <= reference) {370 index++;371 };372 snapshotTimesIndex = index;373 }374 375 private void MakeSnapshot() {376 string time = Math.Round(ExecutionTime.TotalSeconds, 1).ToString("0.0");377 string runName = "Snapshot " + time + "s " + algorithm.Name;378 var changed = false;379 if (StoreAlgorithmInEachSnapshot && !Algorithm.StoreAlgorithmInEachRun) {380 Algorithm.StoreAlgorithmInEachRun = true;381 changed = true;382 } else if (!StoreAlgorithmInEachSnapshot && Algorithm.StoreAlgorithmInEachRun) {383 Algorithm.StoreAlgorithmInEachRun = false;384 changed = true;385 }386 var run = new Run(runName, Algorithm);387 if (changed)388 Algorithm.StoreAlgorithmInEachRun = !Algorithm.StoreAlgorithmInEachRun;389 390 snapshots.Add(run);391 }392 559 } 393 560 } -
branches/PerformanceComparison/HeuristicLab.Analysis/3.3/QualityAnalysis/QualityPerClockAnalyzer.cs
r12774 r12803 42 42 } 43 43 44 public I ResultParameter<TimeSpanValue> ExecutionTimeParameter {45 get { return (I ResultParameter<TimeSpanValue>)Parameters["ExecutionTime"]; }44 public ILookupParameter<DateTimeValue> LastUpdateTimeParameter { 45 get { return (ILookupParameter<DateTimeValue>)Parameters["LastUpdateTime"]; } 46 46 } 47 47 … … 56 56 : base() { 57 57 Parameters.Add(new LookupParameter<DoubleValue>("BestQuality", "The quality value that should be compared.")); 58 Parameters.Add(new ResultParameter<TimeSpanValue>("Execution Time", "The execution time."));58 Parameters.Add(new LookupParameter<DateTimeValue>("LastUpdateTime", "The time the analyzer was last run.")); 59 59 Parameters.Add(new ResultParameter<IndexedDataTable<double>>("QualityPerClock", "Data table containing the first hitting graph with elapsed wall clock time (in seconds) as the x-axis.")); 60 60 QualityPerClockParameter.DefaultValue = new IndexedDataTable<double>("Quality per Clock") { … … 75 75 76 76 public override IOperation Apply() { 77 var executionTime = Math.Max(ExecutionTimeParameter.ResultValue.Value.TotalSeconds, 0.2); 77 var lastUpdateTime = LastUpdateTimeParameter.ActualValue; 78 if (lastUpdateTime == null) { 79 lastUpdateTime = new DateTimeValue(DateTime.UtcNow.AddMilliseconds(-1)); 80 LastUpdateTimeParameter.ActualValue = lastUpdateTime; 81 } 82 var now = DateTime.UtcNow; 83 78 84 var bestQuality = BestQualityParameter.ActualValue.Value; 79 85 … … 81 87 var values = dataTable.Rows["First-hit Graph"].Values; 82 88 if (values.Count == 0 || values.Last().Item2 != bestQuality) 83 dataTable.Rows["First-hit Graph"].Values.Add(Tuple.Create( executionTime, bestQuality));89 dataTable.Rows["First-hit Graph"].Values.Add(Tuple.Create((now - lastUpdateTime.Value).TotalSeconds, bestQuality)); 84 90 91 lastUpdateTime.Value = now; 85 92 return base.Apply(); 86 93 } -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
r12771 r12803 338 338 <DependentUpon>RunCollectionEqualityConstraintView.cs</DependentUpon> 339 339 </Compile> 340 <Compile Include="RunCollectionViews\RunCollection ECDFView.cs">341 <SubType>UserControl</SubType> 342 </Compile> 343 <Compile Include="RunCollectionViews\RunCollection ECDFView.Designer.cs">344 <DependentUpon>RunCollection ECDFView.cs</DependentUpon>340 <Compile Include="RunCollectionViews\RunCollectionRLDView.cs"> 341 <SubType>UserControl</SubType> 342 </Compile> 343 <Compile Include="RunCollectionViews\RunCollectionRLDView.Designer.cs"> 344 <DependentUpon>RunCollectionRLDView.cs</DependentUpon> 345 345 </Compile> 346 346 <Compile Include="RunCollectionViews\RunCollectionTableView.cs"> -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.Designer.cs
r12771 r12803 20 20 #endregion 21 21 namespace HeuristicLab.Optimization.Views { 22 partial class RunCollection ECDFView {22 partial class RunCollectionRLDView { 23 23 /// <summary> 24 24 /// Required designer variable. -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs
r12774 r12803 32 32 33 33 namespace HeuristicLab.Optimization.Views { 34 [View(" ECDF Performance Comparison")]34 [View("Run-length Distribution View")] 35 35 [Content(typeof(RunCollection), false)] 36 public partial class RunCollection ECDFView : ItemView {36 public partial class RunCollectionRLDView : ItemView { 37 37 private const string AllRuns = "All Runs"; 38 38 … … 48 48 } 49 49 50 public RunCollection ECDFView() {50 public RunCollectionRLDView() { 51 51 InitializeComponent(); 52 52 combinedDataTable = new IndexedDataTable<double>("Combined DataTable", "A data table containing the ECDF of each of a number of groups.") { … … 253 253 254 254 private void UpdateCaption() { 255 Caption = Content != null ? Content.OptimizerName + " ECDF Comparison" : ViewAttribute.GetViewName(GetType());255 Caption = Content != null ? Content.OptimizerName + " RLD View" : ViewAttribute.GetViewName(GetType()); 256 256 } 257 257 -
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Algorithms/BasicAlgorithm.cs
r12771 r12803 24 24 using System.Threading.Tasks; 25 25 using HeuristicLab.Common; 26 using HeuristicLab.Data;27 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 27 … … 36 35 public override ResultCollection Results { 37 36 get { return results; } 38 }39 40 protected override void OnExecutionTimeChanged() {41 base.OnExecutionTimeChanged();42 IResult result;43 if (!Results.TryGetValue("Execution Time", out result))44 Results.Add(new Result("Execution Time", new TimeSpanValue(ExecutionTime)));45 else ((TimeSpanValue)result.Value).Value = ExecutionTime;46 37 } 47 38 -
branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Algorithms/EngineAlgorithm.cs
r12771 r12803 22 22 using System; 23 23 using System.Linq; 24 using System.Reflection;25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Core; 27 using HeuristicLab.Data;28 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 27 using HeuristicLab.PluginInfrastructure; … … 73 71 } 74 72 75 protected override void OnExecutionTimeChanged() {76 base.OnExecutionTimeChanged();77 IResult result;78 if (!Results.TryGetValue("Execution Time", out result))79 Results.Add(new Result("Execution Time", new TimeSpanValue(ExecutionTime)));80 else ((TimeSpanValue)result.Value).Value = ExecutionTime;81 }82 83 73 public override ResultCollection Results { 84 74 get {
Note: See TracChangeset
for help on using the changeset viewer.