Changeset 12804
- Timestamp:
- 07/26/15 21:32:52 (9 years ago)
- Location:
- branches/PerformanceComparison
- Files:
-
- 7 edited
- 2 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj
r12771 r12804 199 199 <Compile Include="MultiObjective\RankBasedParetoFrontAnalyzer.cs" /> 200 200 <Compile Include="MultiObjective\ParetoFrontAnalyzer.cs" /> 201 <Compile Include="Optimizers\IRRestarter.cs" /> 201 202 <Compile Include="Plugin.cs" /> 202 203 <Compile Include="PopulationSimilarityAnalysis\PopulationDiversityAnalyzer.cs" /> -
branches/PerformanceComparison/HeuristicLab.Analysis/3.3/Optimizers/IRRestarter.cs
r12803 r12804 37 37 /// A run in which an algorithm is executed for a certain maximum time only. 38 38 /// </summary> 39 [Item("Independent Random Restart Run", "A run in which an optimizer is repeateduntil either a certain target value is reached or a maximum budget is exceeded.")]39 [Item("Independent Random Restarter", "An optimizer that repeats an algorithm until either a certain target value is reached or a maximum budget is exceeded.")] 40 40 [Creatable(CreatableAttribute.Categories.TestingAndAnalysis, Priority = 117)] 41 41 [StorableClass] 42 public sealed class IndepdentRandomRestartRun : NamedItem, IOptimizer, IStorableContent, INotifyPropertyChanged { 42 public sealed class IndepdentRandomRestarter : NamedItem, IOptimizer, IStorableContent, INotifyPropertyChanged { 43 private const string ExecutionTimeResultName = "Execution Time"; 44 private const string BestQualityResultName = "BestQuality"; 45 43 46 public string Filename { get; set; } 44 47 … … 100 103 public bool Maximization { 101 104 get { return maximization; } 102 privateset {105 set { 103 106 if (maximization == value) return; 104 107 maximization = value; … … 114 117 if (moveCostPerSolution == value) return; 115 118 moveCostPerSolution = value; 119 perEvaluationsAnalyzer.MoveCostPerSolutionParameter.Value = new DoubleValue(moveCostPerSolution); 116 120 OnPropertyChanged("MoveCostPerSolution"); 117 121 } 118 122 } 119 123 120 124 [Storable] 125 private QualityPerClockAnalyzer perClockAnalyzer; 126 [Storable] 127 private QualityPerEvaluationsAnalyzer perEvaluationsAnalyzer; 128 129 [Storable] 130 private ExecutionState executionState; 121 131 public ExecutionState ExecutionState { 122 get { return (Algorithm != null) ? Algorithm.ExecutionState : ExecutionState.Stopped; } 132 get { return executionState; } 133 private set { 134 if (executionState != value) { 135 executionState = value; 136 OnExecutionStateChanged(); 137 OnItemImageChanged(); 138 } 139 } 123 140 } 124 141 … … 176 193 get { return algorithm; } 177 194 set { 195 if (value != null && !typeof(ISingleObjectiveHeuristicOptimizationProblem).IsAssignableFrom(value.ProblemType)) 196 throw new ArgumentException("Algorithm is not single-objective!"); 178 197 if (algorithm == value) return; 179 if (algorithm != null) DeregisterAlgorithmEvents(); 198 if (algorithm != null) { 199 DeregisterAlgorithmEvents(); 200 RemoveAlgorithmAnalyzers(); 201 } 180 202 algorithm = value; 181 203 if (algorithm != null) { 182 204 RegisterAlgorithmEvents(); 205 AddAlgorithmAnalyzers(); 183 206 } 184 207 OnPropertyChanged("Algorithm"); … … 228 251 } 229 252 253 private ISingleObjectiveHeuristicOptimizationProblem problem; 254 230 255 [StorableConstructor] 231 private IndepdentRandomRestart Run(bool deserializing) : base(deserializing) { }232 private IndepdentRandomRestart Run(IndepdentRandomRestartRunoriginal, Cloner cloner)256 private IndepdentRandomRestarter(bool deserializing) : base(deserializing) { } 257 private IndepdentRandomRestarter(IndepdentRandomRestarter original, Cloner cloner) 233 258 : base(original, cloner) { 234 259 terminationCriterium = original.terminationCriterium; 235 260 maximumExecutionTime = original.maximumExecutionTime; 236 261 maximumEvaluations = original.maximumEvaluations; 262 moveCostPerSolution = original.moveCostPerSolution; 237 263 targetValue = original.targetValue; 264 maximization = original.maximization; 238 265 executionTime = original.executionTime; 239 266 evaluations = original.evaluations; … … 243 270 lastAlgorithmEvaluatedMoves = original.lastAlgorithmEvaluatedMoves; 244 271 272 perClockAnalyzer = cloner.Clone(original.perClockAnalyzer); 273 perEvaluationsAnalyzer = cloner.Clone(original.perEvaluationsAnalyzer); 274 245 275 algorithm = cloner.Clone(original.algorithm); 246 276 runs = cloner.Clone(original.runs); 247 277 278 ExecutionState = original.ExecutionState; 279 248 280 Initialize(); 249 281 } 250 public IndepdentRandomRestart Run()282 public IndepdentRandomRestarter() 251 283 : base() { 252 284 name = ItemName; 253 285 description = ItemDescription; 254 terminationCriterium = TerminationCriterium. OnlyByEvaluations;286 terminationCriterium = TerminationCriterium.ByTargetAndEvaluations; 255 287 maximumExecutionTime = TimeSpan.FromMinutes(1); 256 288 maximumEvaluations = 10000000; // 10 mio 289 moveCostPerSolution = 1; 257 290 targetValue = 0; 291 maximization = false; 258 292 executionTime = TimeSpan.Zero; 259 293 evaluations = 0; … … 263 297 lastAlgorithmEvaluatedMoves = 0; 264 298 299 perClockAnalyzer = new QualityPerClockAnalyzer(); 300 perEvaluationsAnalyzer = new QualityPerEvaluationsAnalyzer(); 301 265 302 Runs = new RunCollection { OptimizerName = Name }; 266 303 Initialize(); 267 304 } 268 public IndepdentRandomRestart Run(string name)305 public IndepdentRandomRestarter(string name) 269 306 : base(name) { 270 307 description = ItemDescription; 271 terminationCriterium = TerminationCriterium. OnlyByEvaluations;308 terminationCriterium = TerminationCriterium.ByTargetAndEvaluations; 272 309 maximumExecutionTime = TimeSpan.FromMinutes(1); 273 310 maximumEvaluations = 10000000; // 10 mio 311 moveCostPerSolution = 1; 274 312 targetValue = 0; 313 maximization = false; 275 314 executionTime = TimeSpan.Zero; 276 315 evaluations = 0; … … 280 319 lastAlgorithmEvaluatedMoves = 0; 281 320 321 perClockAnalyzer = new QualityPerClockAnalyzer(); 322 perEvaluationsAnalyzer = new QualityPerEvaluationsAnalyzer(); 323 282 324 Runs = new RunCollection { OptimizerName = Name }; 283 325 Initialize(); 284 326 } 285 public IndepdentRandomRestart Run(string name, string description)327 public IndepdentRandomRestarter(string name, string description) 286 328 : base(name, description) { 287 terminationCriterium = TerminationCriterium. OnlyByEvaluations;329 terminationCriterium = TerminationCriterium.ByTargetAndEvaluations; 288 330 maximumExecutionTime = TimeSpan.FromMinutes(1); 289 331 maximumEvaluations = 10000000; // 10 mio 332 moveCostPerSolution = 1; 290 333 targetValue = 0; 334 maximization = false; 291 335 executionTime = TimeSpan.Zero; 292 336 evaluations = 0; … … 296 340 lastAlgorithmEvaluatedMoves = 0; 297 341 342 perClockAnalyzer = new QualityPerClockAnalyzer(); 343 perEvaluationsAnalyzer = new QualityPerEvaluationsAnalyzer(); 344 298 345 Runs = new RunCollection { OptimizerName = Name }; 299 346 Initialize(); … … 302 349 public override IDeepCloneable Clone(Cloner cloner) { 303 350 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState)); 304 return new IndepdentRandomRestart Run(this, cloner);351 return new IndepdentRandomRestarter(this, cloner); 305 352 } 306 353 … … 314 361 } 315 362 363 private void Reset() { 364 ExecutionTime = TimeSpan.Zero; 365 Evaluations = 0; 366 BestSoFar = double.NaN; 367 lastAlgorithmExecutionTime = TimeSpan.Zero; 368 lastAlgorithmEvaluatedSolutions = 0; 369 lastAlgorithmEvaluatedMoves = 0; 370 371 CurrentRun = null; 372 } 373 316 374 public void Prepare() { 317 375 Prepare(false); 318 376 } 319 377 public void Prepare(bool clearRuns) { 320 executionTime = TimeSpan.Zero; 321 evaluations = 0; 322 lastAlgorithmExecutionTime = TimeSpan.Zero; 323 lastAlgorithmEvaluatedSolutions = 0; 324 325 Algorithm.Prepare(clearRuns); 378 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped)) 379 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); 380 Reset(); 381 382 if (Algorithm != null) { 383 Algorithm.Prepare(clearRuns); 384 ExecutionState = ExecutionState.Prepared; 385 OnPrepared(); 386 } 326 387 } 327 388 public void Start() { 389 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused)) 390 throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState)); 391 328 392 if (ExecutionState == ExecutionState.Prepared) { 329 currentRun = new Run(Algorithm) {393 CurrentRun = new Run(Algorithm) { 330 394 Name = Algorithm.Name + " IRRRun" + Runs.Count 331 395 }; 396 if (!CurrentRun.Results.ContainsKey(ExecutionTimeResultName)) 397 CurrentRun.Results.Add(ExecutionTimeResultName, new TimeSpanValue(TimeSpan.Zero)); 398 CurrentRun.Results.Add(perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName, new IntValue(0)); 399 CurrentRun.Results.Add(perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName, new IntValue(0)); 400 CurrentRun.Results.Add(BestQualityResultName, new DoubleValue(Maximization ? double.MinValue : double.MaxValue)); 332 401 } 333 402 Algorithm.Start(); 403 ExecutionState = ExecutionState.Started; 404 OnStarted(); 334 405 } 335 406 public void Pause() { 407 if (ExecutionState != ExecutionState.Started) 408 throw new InvalidOperationException(string.Format("Pause not allowed in execution state \"{0}\".", ExecutionState)); 336 409 Algorithm.Pause(); 337 } 410 ExecutionState = ExecutionState.Paused; 411 OnPaused(); 412 } 413 414 private bool forceStop = false; 338 415 public void Stop() { 416 if ((ExecutionState != ExecutionState.Started) && (ExecutionState != ExecutionState.Paused)) 417 throw new InvalidOperationException(string.Format("Stop not allowed in execution state \"{0}\".", ExecutionState)); 418 forceStop = true; 339 419 Algorithm.Stop(); 420 } 421 422 private void AddAlgorithmAnalyzers() { 423 if (!Algorithm.Parameters.ContainsKey("Analyzer")) return; 424 var analyzerParam = Algorithm.Parameters["Analyzer"] as IValueParameter<MultiAnalyzer>; 425 if (analyzerParam == null) return; 426 if (!analyzerParam.Value.Operators.Contains(perClockAnalyzer)) 427 analyzerParam.Value.Operators.Add(perClockAnalyzer); 428 if (!analyzerParam.Value.Operators.Contains(perEvaluationsAnalyzer)) 429 analyzerParam.Value.Operators.Add(perEvaluationsAnalyzer); 430 } 431 432 private void RemoveAlgorithmAnalyzers() { 433 if (!Algorithm.Parameters.ContainsKey("Analyzer")) return; 434 var analyzerParam = Algorithm.Parameters["Analyzer"] as IValueParameter<MultiAnalyzer>; 435 if (analyzerParam == null) return; 436 analyzerParam.Value.Operators.Remove(perClockAnalyzer); 437 analyzerParam.Value.Operators.Remove(perEvaluationsAnalyzer); 340 438 } 341 439 … … 400 498 algorithm.Stopped += Algorithm_Stopped; 401 499 algorithm.ProblemChanged += Algorithm_ProblemChanged; 500 Algorithm_ProblemChanged(algorithm, EventArgs.Empty); 402 501 } 403 502 private void DeregisterAlgorithmEvents() { … … 415 514 } 416 515 private void Algorithm_ExecutionTimeChanged(object sender, EventArgs e) { 417 ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime;418 lastAlgorithmExecutionTime = Algorithm.ExecutionTime; 419 420 UpdateAlgorithmResults();421 422 if (IsFinished ) {516 if (Algorithm.ExecutionState != ExecutionState.Started) return; 517 518 if (ExecutionState == ExecutionState.Started) 519 UpdateAlgorithmResults(); 520 521 if (IsFinished && ExecutionState != ExecutionState.Stopped) { 423 522 Algorithm.Stop(); 424 523 } … … 427 526 428 527 private void Algorithm_ExecutionStateChanged(object sender, EventArgs e) { 429 OnExecutionStateChanged();528 //OnExecutionStateChanged(); 430 529 } 431 530 private void Algorithm_Paused(object sender, EventArgs e) { 432 ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime;433 lastAlgorithmExecutionTime = Algorithm.ExecutionTime;434 435 531 UpdateAlgorithmResults(); 436 532 OnPaused(); 437 533 } 438 534 private void Algorithm_Prepared(object sender, EventArgs e) { 439 OnPrepared(); 535 lastAlgorithmEvaluatedSolutions = 0; 536 lastAlgorithmEvaluatedMoves = 0; 537 lastAlgorithmExecutionTime = TimeSpan.Zero; 440 538 } 441 539 private void Algorithm_Started(object sender, EventArgs e) { 442 OnStarted();540 //OnStarted(); 443 541 } 444 542 private void Algorithm_Stopped(object sender, EventArgs e) { 445 ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime;446 lastAlgorithmExecutionTime = Algorithm.ExecutionTime;447 448 543 var bestQuality = UpdateAlgorithmResults(); 449 544 545 var execTime = ((TimeSpanValue)currentRun.Results[ExecutionTimeResultName]).Value; 450 546 foreach (var result in Algorithm.Results) { 451 if (result.Name == "QualityPerClock") {547 if (result.Name == perClockAnalyzer.QualityPerClockParameter.ResultName) { 452 548 if (!currentRun.Results.ContainsKey(result.Name)) 453 549 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 454 550 else { 455 551 var dt = (IndexedDataTable<double>)currentRun.Results[result.Name]; 456 var execTime = ((TimeSpanValue)currentRun.Results["ExecutionTime"]).Value.TotalSeconds;457 552 var best = dt.Rows.First().Values.Last().Item2; 458 553 var resultDt = (IndexedDataTable<double>)result.Value; 459 554 foreach (var tupl in resultDt.Rows.First().Values) { 460 555 if (Maximization && tupl.Item2 > best || !Maximization && tupl.Item2 < best) { 461 dt.Rows.First().Values.Add(Tuple.Create(execTime + tupl.Item1, tupl.Item2));556 dt.Rows.First().Values.Add(Tuple.Create(execTime.TotalSeconds + tupl.Item1, tupl.Item2)); 462 557 best = tupl.Item2; 463 558 } 464 559 } 465 560 } 466 } else if (result.Name == "QualityPerEvaluations") {561 } else if (result.Name == perEvaluationsAnalyzer.QualityPerEvaluationsParameter.ResultName) { 467 562 if (!currentRun.Results.ContainsKey(result.Name)) 468 563 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 469 564 else { 470 565 var dt = (IndexedDataTable<double>)currentRun.Results[result.Name]; 471 var evalSols = (( DoubleValue)currentRun.Results["EvaluatedSolutions"]).Value;472 var evalMoves = (( DoubleValue)currentRun.Results["EvaluatedMoves"]).Value;566 var evalSols = ((IntValue)currentRun.Results[perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName]).Value; 567 var evalMoves = ((IntValue)currentRun.Results[perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName]).Value; 473 568 var best = dt.Rows.First().Values.Last().Item2; 474 569 var resultDt = (IndexedDataTable<double>)result.Value; … … 480 575 } 481 576 } 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()); 577 } else if (result.Name == perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName) { 578 var evalSols = ((IntValue)currentRun.Results[perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName]); 579 evalSols.Value += ((IntValue)result.Value).Value; 580 } else if (result.Name == perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName) { 581 var evalMoves = ((IntValue)currentRun.Results[perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName]); 582 evalMoves.Value += ((IntValue)result.Value).Value; 583 } else if (result.Name == perEvaluationsAnalyzer.BestQualityParameter.ActualName) { 584 var best = ((DoubleValue)currentRun.Results[BestQualityResultName]).Value; 585 if (Maximization && best < bestQuality || !Maximization && best > bestQuality) 586 currentRun.Results[BestQualityResultName] = new DoubleValue(bestQuality); 490 587 } else if (result.Name.ToLower().EndsWith("solution") && BestSoFar == bestQuality) { 491 currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 588 if (currentRun.Results.ContainsKey(result.Name)) 589 currentRun.Results[result.Name] = (IItem)result.Value.Clone(); 590 else currentRun.Results.Add(result.Name, (IItem)result.Value.Clone()); 492 591 } 493 592 } 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 517 var cloner = new Cloner(); 518 var algRun = cloner.Clone(Algorithm.Runs.Last()); 519 Runs.Add(algRun); 520 Algorithm.Runs.Clear(); 521 OnStopped(); 593 currentRun.Results[ExecutionTimeResultName] = new TimeSpanValue(execTime + Algorithm.ExecutionTime); 594 595 if (!forceStop && !IsFinished) { 596 Algorithm.Prepare(); 597 Algorithm.Start(); 598 } else { 599 forceStop = false; 600 Runs.Add(currentRun); 601 currentRun = null; 602 Algorithm.Prepare(true); 603 ExecutionState = ExecutionState.Stopped; 604 OnStopped(); 605 } 522 606 } 523 607 524 608 private double UpdateAlgorithmResults() { 609 ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime; 610 lastAlgorithmExecutionTime = Algorithm.ExecutionTime; 611 525 612 IResult evaluationsResult; 526 if (Algorithm.Results.TryGetValue( "EvaluatedSolutions", out evaluationsResult)) {613 if (Algorithm.Results.TryGetValue(perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName, out evaluationsResult)) { 527 614 var evals = ((IntValue)evaluationsResult.Value).Value; 528 615 Evaluations += evals - lastAlgorithmEvaluatedSolutions; 529 616 lastAlgorithmEvaluatedSolutions = evals; 530 617 } 531 if (Algorithm.Results.TryGetValue( "EvaluatedMoves", out evaluationsResult)) {618 if (Algorithm.Results.TryGetValue(perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName, out evaluationsResult)) { 532 619 var evals = ((IntValue)evaluationsResult.Value).Value; 533 620 Evaluations += moveCostPerSolution * (evals - lastAlgorithmEvaluatedMoves); 534 621 lastAlgorithmEvaluatedMoves = evals; 535 622 } 536 if (Algorithm.Results.TryGetValue( "BestQuality", out evaluationsResult)) {537 var bestQuality = ((DoubleValue)evaluationsResult ).Value;623 if (Algorithm.Results.TryGetValue(perEvaluationsAnalyzer.BestQualityParameter.ActualName, out evaluationsResult)) { 624 var bestQuality = ((DoubleValue)evaluationsResult.Value).Value; 538 625 if (double.IsNaN(BestSoFar) 539 626 || Maximization && bestQuality > BestSoFar … … 546 633 547 634 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>; 635 if (problem != null) DeregisterProblemEvents(); 636 637 problem = Algorithm.Problem as ISingleObjectiveHeuristicOptimizationProblem; 638 if (problem == null) return; 639 RegisterProblemEvents(); 640 641 AddAlgorithmAnalyzers(); 642 643 var maxParam = problem.MaximizationParameter as IValueParameter<BoolValue>; 551 644 if (maxParam != null) 552 645 Maximization = maxParam.Value.Value; 553 var bkParam = soProblem.BestKnownQualityParameter as IValueParameter<DoubleValue>;646 var bkParam = problem.BestKnownQualityParameter as IValueParameter<DoubleValue>; 554 647 if (bkParam != null && bkParam.Value != null) 555 648 TargetValue = bkParam.Value.Value; 649 650 Reset(); 651 } 652 653 private void RegisterProblemEvents() { 654 problem.Reset += ProblemOnReset; 655 problem.OperatorsChanged += ProblemOnOperatorsChanged; 656 } 657 658 private void DeregisterProblemEvents() { 659 problem.Reset -= ProblemOnReset; 660 problem.OperatorsChanged -= ProblemOnOperatorsChanged; 661 } 662 663 private void ProblemOnReset(object sender, EventArgs eventArgs) { 664 AddAlgorithmAnalyzers(); 665 } 666 667 private void ProblemOnOperatorsChanged(object sender, EventArgs eventArgs) { 668 AddAlgorithmAnalyzers(); 556 669 } 557 670 #endregion -
branches/PerformanceComparison/HeuristicLab.Analysis/3.3/QualityAnalysis/QualityPerClockAnalyzer.cs
r12803 r12804 75 75 76 76 public override IOperation Apply() { 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 84 77 var bestQuality = BestQualityParameter.ActualValue.Value; 85 86 78 var dataTable = QualityPerClockParameter.ResultValue; 87 79 var values = dataTable.Rows["First-hit Graph"].Values; 88 if (values.Count == 0 || values.Last().Item2 != bestQuality)89 dataTable.Rows["First-hit Graph"].Values.Add(Tuple.Create((now - lastUpdateTime.Value).TotalSeconds, bestQuality));90 80 91 lastUpdateTime.Value = now; 81 if (values.Count == 0 || values.Last().Item2 != bestQuality) { 82 var lastUpdateTime = LastUpdateTimeParameter.ActualValue; 83 if (lastUpdateTime == null) { 84 lastUpdateTime = new DateTimeValue(DateTime.UtcNow.AddMilliseconds(-1)); 85 LastUpdateTimeParameter.ActualValue = lastUpdateTime; 86 } 87 88 var now = DateTime.UtcNow; 89 var runtimeSoFar = (now - lastUpdateTime.Value).TotalSeconds + (values.Count > 0 ? values.Last().Item1 : 0); 90 dataTable.Rows["First-hit Graph"].Values.Add(Tuple.Create(runtimeSoFar, bestQuality)); 91 lastUpdateTime.Value = now; 92 } 92 93 return base.Apply(); 93 94 } -
branches/PerformanceComparison/HeuristicLab.Analysis/3.3/QualityAnalysis/QualityPerEvaluationsAnalyzer.cs
r12774 r12804 44 44 get { return (ILookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } 45 45 } 46 public ILookupParameter<IntValue> EvaluatedMovesParameter { 47 get { return (ILookupParameter<IntValue>)Parameters["EvaluatedMoves"]; } 48 } 49 public IValueLookupParameter<DoubleValue> MoveCostPerSolutionParameter { 50 get { return (IValueLookupParameter<DoubleValue>)Parameters["MoveCostPerSolution"]; } 51 } 46 52 public IResultParameter<IndexedDataTable<double>> QualityPerEvaluationsParameter { 47 53 get { return (IResultParameter<IndexedDataTable<double>>)Parameters["QualityPerEvaluations"]; } … … 54 60 : base() { 55 61 Parameters.Add(new LookupParameter<DoubleValue>("BestQuality", "The quality value that should be compared.")); 56 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The quality value that should be compared.")); 62 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated solutions.")); 63 Parameters.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of evaluated moves.")); 64 Parameters.Add(new ValueLookupParameter<DoubleValue>("MoveCostPerSolution", "The cost to evaluate a move as a ratio to the cost of evaluating a solution.", new DoubleValue(1))); 57 65 Parameters.Add(new ResultParameter<IndexedDataTable<double>>("QualityPerEvaluations", "Data table containing the first hitting graph with evaluations as the x-axis.")); 58 66 QualityPerEvaluationsParameter.DefaultValue = new IndexedDataTable<double>("Quality per Evaluations") { … … 74 82 public override IOperation Apply() { 75 83 var bestQuality = BestQualityParameter.ActualValue.Value; 76 var evaluations = Math.Max(EvaluatedSolutionsParameter.ActualValue.Value, 1); 84 var evalSols = EvaluatedSolutionsParameter.ActualValue; 85 var evalMoves = EvaluatedMovesParameter.ActualValue; 86 var evaluations = 0.0; 87 if (evalSols != null) evaluations += evalSols.Value; 88 if (evalMoves != null) evaluations += evalMoves.Value * MoveCostPerSolutionParameter.ActualValue.Value; 77 89 78 90 var dataTable = QualityPerEvaluationsParameter.ResultValue; 79 91 var values = dataTable.Rows["First-hit Graph"].Values; 92 if (evaluations == 0 || values.Count > 0 && evaluations < values.Last().Item1) evaluations = 1; 80 93 if (values.Count == 0 || values.Last().Item2 != bestQuality) 81 94 values.Add(Tuple.Create((double)evaluations, bestQuality)); -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
r12803 r12804 223 223 <DependentUpon>CreateNewSingleEncodingDialog.cs</DependentUpon> 224 224 </Compile> 225 <Compile Include="IRRestarterView.cs"> 226 <SubType>UserControl</SubType> 227 </Compile> 228 <Compile Include="IRRestarterView.Designer.cs"> 229 <DependentUpon>IRRestarterView.cs</DependentUpon> 230 </Compile> 225 231 <Compile Include="ISolutionSimilarityCalculatorView.cs"> 226 232 <SubType>UserControl</SubType> -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/IRRestarterView.Designer.cs
r12764 r12804 21 21 22 22 namespace HeuristicLab.Optimization.Views { 23 partial class TimeLimitRunView {23 partial class IndependentRandomRestarterView { 24 24 /// <summary> 25 25 /// Required designer variable. … … 34 34 /// </summary> 35 35 private void InitializeComponent() { 36 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof( TimeLimitRunView));36 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(IndependentRandomRestarterView)); 37 37 this.timeLimitLabel = new System.Windows.Forms.Label(); 38 this.timeLimitTextBox = new System.Windows.Forms.TextBox(); 39 this.label1 = new System.Windows.Forms.Label(); 40 this.snapshotsTextBox = new System.Windows.Forms.TextBox(); 41 this.storeAlgorithmInEachSnapshotCheckBox = new System.Windows.Forms.CheckBox(); 38 this.maxExecutionTimeTextBox = new System.Windows.Forms.TextBox(); 39 this.evaluationsLimitabel = new System.Windows.Forms.Label(); 40 this.maxEvaluationsTextBox = new System.Windows.Forms.TextBox(); 42 41 this.tabControl = new HeuristicLab.MainForm.WindowsForms.DragOverTabControl(); 43 42 this.algorithmTabPage = new System.Windows.Forms.TabPage(); … … 45 44 this.openAlgorithmButton = new System.Windows.Forms.Button(); 46 45 this.newAlgorithmButton = new System.Windows.Forms.Button(); 47 this. snapshotsTabPage = new System.Windows.Forms.TabPage();48 this. snapshotsView = new HeuristicLab.Optimization.Views.RunCollectionView();46 this.currentRunTabPage = new System.Windows.Forms.TabPage(); 47 this.currentRunView = new HeuristicLab.Optimization.Views.RunView(); 49 48 this.runsTabPage = new System.Windows.Forms.TabPage(); 50 49 this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView(); 51 50 this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 52 this.snapshotButton = new System.Windows.Forms.Button(); 53 this.sequenceButton = new System.Windows.Forms.Button(); 51 this.targetValueTextBox = new System.Windows.Forms.TextBox(); 52 this.targetValueLabel = new System.Windows.Forms.Label(); 53 this.terminationComboBox = new System.Windows.Forms.ComboBox(); 54 this.terminationLabel = new System.Windows.Forms.Label(); 55 this.moveCostPerSolutionTextBox = new System.Windows.Forms.TextBox(); 56 this.moveCostPerSolutionLabel = new System.Windows.Forms.Label(); 57 this.maximizationLabel = new System.Windows.Forms.Label(); 58 this.maximizationCheckBox = new System.Windows.Forms.CheckBox(); 54 59 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 55 60 this.tabControl.SuspendLayout(); 56 61 this.algorithmTabPage.SuspendLayout(); 57 this. snapshotsTabPage.SuspendLayout();62 this.currentRunTabPage.SuspendLayout(); 58 63 this.runsTabPage.SuspendLayout(); 59 64 this.SuspendLayout(); … … 95 100 this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 96 101 this.errorProvider.SetIconPadding(this.nameTextBox, 2); 97 this.nameTextBox.Location = new System.Drawing.Point( 69, 0);98 this.nameTextBox.Size = new System.Drawing.Size(4 55, 20);102 this.nameTextBox.Location = new System.Drawing.Point(115, 0); 103 this.nameTextBox.Size = new System.Drawing.Size(409, 20); 99 104 // 100 105 // infoLabel … … 107 112 this.timeLimitLabel.Location = new System.Drawing.Point(3, 29); 108 113 this.timeLimitLabel.Name = "timeLimitLabel"; 109 this.timeLimitLabel.Size = new System.Drawing.Size( 53, 13);114 this.timeLimitLabel.Size = new System.Drawing.Size(106, 13); 110 115 this.timeLimitLabel.TabIndex = 3; 111 this.timeLimitLabel.Text = " Time limit:";112 // 113 // timeLimitTextBox114 // 115 this. timeLimitTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)116 this.timeLimitLabel.Text = "Max Execution Time:"; 117 // 118 // maxExecutionTimeTextBox 119 // 120 this.maxExecutionTimeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 116 121 | System.Windows.Forms.AnchorStyles.Right))); 117 this.timeLimitTextBox.Location = new System.Drawing.Point(69, 26); 118 this.timeLimitTextBox.Name = "timeLimitTextBox"; 119 this.timeLimitTextBox.Size = new System.Drawing.Size(455, 20); 120 this.timeLimitTextBox.TabIndex = 4; 121 this.timeLimitTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.timeLimitTextBox_Validating); 122 // 123 // label1 124 // 125 this.label1.AutoSize = true; 126 this.label1.Location = new System.Drawing.Point(3, 55); 127 this.label1.Name = "label1"; 128 this.label1.Size = new System.Drawing.Size(60, 13); 129 this.label1.TabIndex = 5; 130 this.label1.Text = "Snapshots:"; 131 // 132 // snapshotsTextBox 133 // 134 this.snapshotsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 135 | System.Windows.Forms.AnchorStyles.Right))); 136 this.snapshotsTextBox.Location = new System.Drawing.Point(69, 52); 137 this.snapshotsTextBox.Name = "snapshotsTextBox"; 138 this.snapshotsTextBox.Size = new System.Drawing.Size(175, 20); 139 this.snapshotsTextBox.TabIndex = 6; 140 this.snapshotsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.snapshotsTextBox_Validating); 141 // 142 // storeAlgorithmInEachSnapshotCheckBox 143 // 144 this.storeAlgorithmInEachSnapshotCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 145 this.storeAlgorithmInEachSnapshotCheckBox.AutoSize = true; 146 this.storeAlgorithmInEachSnapshotCheckBox.Location = new System.Drawing.Point(340, 54); 147 this.storeAlgorithmInEachSnapshotCheckBox.Name = "storeAlgorithmInEachSnapshotCheckBox"; 148 this.storeAlgorithmInEachSnapshotCheckBox.Size = new System.Drawing.Size(184, 17); 149 this.storeAlgorithmInEachSnapshotCheckBox.TabIndex = 7; 150 this.storeAlgorithmInEachSnapshotCheckBox.Text = "Store Algorithm in Each Snapshot"; 151 this.storeAlgorithmInEachSnapshotCheckBox.UseVisualStyleBackColor = true; 152 this.storeAlgorithmInEachSnapshotCheckBox.CheckedChanged += new System.EventHandler(this.storeAlgorithmInEachSnapshotCheckBox_CheckedChanged); 122 this.maxExecutionTimeTextBox.Location = new System.Drawing.Point(115, 26); 123 this.maxExecutionTimeTextBox.Name = "maxExecutionTimeTextBox"; 124 this.maxExecutionTimeTextBox.Size = new System.Drawing.Size(409, 20); 125 this.maxExecutionTimeTextBox.TabIndex = 4; 126 this.maxExecutionTimeTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.maxExecutionTimeTextBox_Validating); 127 // 128 // evaluationsLimitabel 129 // 130 this.evaluationsLimitabel.AutoSize = true; 131 this.evaluationsLimitabel.Location = new System.Drawing.Point(3, 55); 132 this.evaluationsLimitabel.Name = "evaluationsLimitabel"; 133 this.evaluationsLimitabel.Size = new System.Drawing.Size(88, 13); 134 this.evaluationsLimitabel.TabIndex = 5; 135 this.evaluationsLimitabel.Text = "Max Evaluations:"; 136 // 137 // maxEvaluationsTextBox 138 // 139 this.maxEvaluationsTextBox.Location = new System.Drawing.Point(115, 52); 140 this.maxEvaluationsTextBox.Name = "maxEvaluationsTextBox"; 141 this.maxEvaluationsTextBox.Size = new System.Drawing.Size(157, 20); 142 this.maxEvaluationsTextBox.TabIndex = 6; 143 this.maxEvaluationsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.maxEvaluationsTextBox_Validating); 153 144 // 154 145 // tabControl … … 159 150 | System.Windows.Forms.AnchorStyles.Right))); 160 151 this.tabControl.Controls.Add(this.algorithmTabPage); 161 this.tabControl.Controls.Add(this. snapshotsTabPage);152 this.tabControl.Controls.Add(this.currentRunTabPage); 162 153 this.tabControl.Controls.Add(this.runsTabPage); 163 this.tabControl.Location = new System.Drawing.Point(0, 78);154 this.tabControl.Location = new System.Drawing.Point(0, 132); 164 155 this.tabControl.Name = "tabControl"; 165 156 this.tabControl.SelectedIndex = 0; 166 this.tabControl.Size = new System.Drawing.Size(546, 3 56);157 this.tabControl.Size = new System.Drawing.Size(546, 302); 167 158 this.tabControl.TabIndex = 8; 168 159 // … … 176 167 this.algorithmTabPage.Name = "algorithmTabPage"; 177 168 this.algorithmTabPage.Padding = new System.Windows.Forms.Padding(3); 178 this.algorithmTabPage.Size = new System.Drawing.Size(538, 330);169 this.algorithmTabPage.Size = new System.Drawing.Size(538, 276); 179 170 this.algorithmTabPage.TabIndex = 1; 180 171 this.algorithmTabPage.Text = "Algorithm"; … … 195 186 this.algorithmViewHost.Name = "algorithmViewHost"; 196 187 this.algorithmViewHost.ReadOnly = false; 197 this.algorithmViewHost.Size = new System.Drawing.Size(526, 2 88);188 this.algorithmViewHost.Size = new System.Drawing.Size(526, 234); 198 189 this.algorithmViewHost.TabIndex = 2; 199 190 this.algorithmViewHost.ViewsLabelVisible = true; … … 202 193 // openAlgorithmButton 203 194 // 204 this.openAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;195 this.openAlgorithmButton.Image = ((System.Drawing.Image)(resources.GetObject("openAlgorithmButton.Image"))); 205 196 this.openAlgorithmButton.Location = new System.Drawing.Point(36, 6); 206 197 this.openAlgorithmButton.Name = "openAlgorithmButton"; … … 213 204 // newAlgorithmButton 214 205 // 215 this.newAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;206 this.newAlgorithmButton.Image = ((System.Drawing.Image)(resources.GetObject("newAlgorithmButton.Image"))); 216 207 this.newAlgorithmButton.Location = new System.Drawing.Point(6, 6); 217 208 this.newAlgorithmButton.Name = "newAlgorithmButton"; … … 222 213 this.newAlgorithmButton.Click += new System.EventHandler(this.newAlgorithmButton_Click); 223 214 // 224 // snapshotsTabPage 225 // 226 this.snapshotsTabPage.Controls.Add(this.snapshotsView); 227 this.snapshotsTabPage.Location = new System.Drawing.Point(4, 22); 228 this.snapshotsTabPage.Name = "snapshotsTabPage"; 229 this.snapshotsTabPage.Padding = new System.Windows.Forms.Padding(3); 230 this.snapshotsTabPage.Size = new System.Drawing.Size(538, 330); 231 this.snapshotsTabPage.TabIndex = 2; 232 this.snapshotsTabPage.Text = "Snapshots"; 233 this.snapshotsTabPage.UseVisualStyleBackColor = true; 234 // 235 // snapshotsView 236 // 237 this.snapshotsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 238 | System.Windows.Forms.AnchorStyles.Left) 239 | System.Windows.Forms.AnchorStyles.Right))); 240 this.snapshotsView.Caption = "RunCollection View"; 241 this.snapshotsView.Content = null; 242 this.snapshotsView.Location = new System.Drawing.Point(6, 6); 243 this.snapshotsView.Name = "snapshotsView"; 244 this.snapshotsView.ReadOnly = false; 245 this.snapshotsView.Size = new System.Drawing.Size(526, 317); 246 this.snapshotsView.TabIndex = 0; 215 // currentRunTabPage 216 // 217 this.currentRunTabPage.Controls.Add(this.currentRunView); 218 this.currentRunTabPage.Location = new System.Drawing.Point(4, 22); 219 this.currentRunTabPage.Name = "currentRunTabPage"; 220 this.currentRunTabPage.Padding = new System.Windows.Forms.Padding(6); 221 this.currentRunTabPage.Size = new System.Drawing.Size(538, 276); 222 this.currentRunTabPage.TabIndex = 4; 223 this.currentRunTabPage.Text = "Current Run"; 224 this.currentRunTabPage.UseVisualStyleBackColor = true; 225 // 226 // currentRunView 227 // 228 this.currentRunView.Caption = "Run View"; 229 this.currentRunView.Content = null; 230 this.currentRunView.Dock = System.Windows.Forms.DockStyle.Fill; 231 this.currentRunView.Location = new System.Drawing.Point(6, 6); 232 this.currentRunView.Name = "currentRunView"; 233 this.currentRunView.ReadOnly = false; 234 this.currentRunView.Size = new System.Drawing.Size(526, 264); 235 this.currentRunView.TabIndex = 0; 247 236 // 248 237 // runsTabPage … … 251 240 this.runsTabPage.Location = new System.Drawing.Point(4, 22); 252 241 this.runsTabPage.Name = "runsTabPage"; 253 this.runsTabPage.Size = new System.Drawing.Size(538, 330); 242 this.runsTabPage.Padding = new System.Windows.Forms.Padding(6); 243 this.runsTabPage.Size = new System.Drawing.Size(538, 276); 254 244 this.runsTabPage.TabIndex = 3; 255 245 this.runsTabPage.Text = "Runs"; … … 258 248 // runsView 259 249 // 260 this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)261 | System.Windows.Forms.AnchorStyles.Left)262 | System.Windows.Forms.AnchorStyles.Right)));263 250 this.runsView.Caption = "RunCollection View"; 264 251 this.runsView.Content = null; 252 this.runsView.Dock = System.Windows.Forms.DockStyle.Fill; 265 253 this.runsView.Location = new System.Drawing.Point(6, 6); 266 254 this.runsView.Name = "runsView"; 267 255 this.runsView.ReadOnly = false; 268 this.runsView.Size = new System.Drawing.Size(526, 317);256 this.runsView.Size = new System.Drawing.Size(526, 264); 269 257 this.runsView.TabIndex = 1; 270 258 // … … 276 264 this.openFileDialog.Title = "Open Optimizer"; 277 265 // 278 // snapshotButton 279 // 280 this.snapshotButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 281 this.snapshotButton.Location = new System.Drawing.Point(120, 440); 282 this.snapshotButton.Name = "snapshotButton"; 283 this.snapshotButton.Size = new System.Drawing.Size(24, 24); 284 this.snapshotButton.TabIndex = 13; 285 this.snapshotButton.Text = "Snapshot"; 286 this.toolTip.SetToolTip(this.snapshotButton, "Create Snapshot"); 287 this.snapshotButton.UseVisualStyleBackColor = true; 288 this.snapshotButton.Click += new System.EventHandler(this.snapshotButton_Click); 289 // 290 // sequenceButton 291 // 292 this.sequenceButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 293 this.sequenceButton.Location = new System.Drawing.Point(250, 50); 294 this.sequenceButton.Name = "sequenceButton"; 295 this.sequenceButton.Size = new System.Drawing.Size(75, 23); 296 this.sequenceButton.TabIndex = 16; 297 this.sequenceButton.Text = "Sequence..."; 298 this.sequenceButton.UseVisualStyleBackColor = true; 299 this.sequenceButton.Click += new System.EventHandler(this.sequenceButton_Click); 300 // 301 // TimeLimitRunView 266 // targetValueTextBox 267 // 268 this.targetValueTextBox.Location = new System.Drawing.Point(115, 78); 269 this.targetValueTextBox.Name = "targetValueTextBox"; 270 this.targetValueTextBox.Size = new System.Drawing.Size(157, 20); 271 this.targetValueTextBox.TabIndex = 6; 272 this.targetValueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.targetValueTextBox_Validating); 273 // 274 // targetValueLabel 275 // 276 this.targetValueLabel.AutoSize = true; 277 this.targetValueLabel.Location = new System.Drawing.Point(3, 81); 278 this.targetValueLabel.Name = "targetValueLabel"; 279 this.targetValueLabel.Size = new System.Drawing.Size(71, 13); 280 this.targetValueLabel.TabIndex = 5; 281 this.targetValueLabel.Text = "Target Value:"; 282 // 283 // terminationComboBox 284 // 285 this.terminationComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 286 | System.Windows.Forms.AnchorStyles.Right))); 287 this.terminationComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 288 this.terminationComboBox.FormattingEnabled = true; 289 this.terminationComboBox.Location = new System.Drawing.Point(115, 105); 290 this.terminationComboBox.Name = "terminationComboBox"; 291 this.terminationComboBox.Size = new System.Drawing.Size(409, 21); 292 this.terminationComboBox.TabIndex = 16; 293 this.terminationComboBox.SelectedIndexChanged += new System.EventHandler(this.terminationComboBox_SelectedIndexChanged); 294 // 295 // terminationLabel 296 // 297 this.terminationLabel.AutoSize = true; 298 this.terminationLabel.Location = new System.Drawing.Point(3, 108); 299 this.terminationLabel.Name = "terminationLabel"; 300 this.terminationLabel.Size = new System.Drawing.Size(65, 13); 301 this.terminationLabel.TabIndex = 5; 302 this.terminationLabel.Text = "Termination:"; 303 // 304 // moveCostPerSolutionTextBox 305 // 306 this.moveCostPerSolutionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 307 | System.Windows.Forms.AnchorStyles.Right))); 308 this.moveCostPerSolutionTextBox.Location = new System.Drawing.Point(401, 52); 309 this.moveCostPerSolutionTextBox.Name = "moveCostPerSolutionTextBox"; 310 this.moveCostPerSolutionTextBox.Size = new System.Drawing.Size(123, 20); 311 this.moveCostPerSolutionTextBox.TabIndex = 6; 312 this.moveCostPerSolutionTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.moveCostPerSolutionTextBox_Validating); 313 // 314 // moveCostPerSolutionLabel 315 // 316 this.moveCostPerSolutionLabel.AutoSize = true; 317 this.moveCostPerSolutionLabel.Location = new System.Drawing.Point(278, 55); 318 this.moveCostPerSolutionLabel.Name = "moveCostPerSolutionLabel"; 319 this.moveCostPerSolutionLabel.Size = new System.Drawing.Size(117, 13); 320 this.moveCostPerSolutionLabel.TabIndex = 5; 321 this.moveCostPerSolutionLabel.Text = "Move cost per solution:"; 322 // 323 // maximizationLabel 324 // 325 this.maximizationLabel.AutoSize = true; 326 this.maximizationLabel.Location = new System.Drawing.Point(278, 81); 327 this.maximizationLabel.Name = "maximizationLabel"; 328 this.maximizationLabel.Size = new System.Drawing.Size(70, 13); 329 this.maximizationLabel.TabIndex = 5; 330 this.maximizationLabel.Text = "Maximization:"; 331 // 332 // maximizationCheckBox 333 // 334 this.maximizationCheckBox.AutoSize = true; 335 this.maximizationCheckBox.Location = new System.Drawing.Point(401, 80); 336 this.maximizationCheckBox.Name = "maximizationCheckBox"; 337 this.maximizationCheckBox.Size = new System.Drawing.Size(15, 14); 338 this.maximizationCheckBox.TabIndex = 17; 339 this.maximizationCheckBox.UseVisualStyleBackColor = true; 340 this.maximizationCheckBox.CheckedChanged += new System.EventHandler(this.maximizationCheckBox_CheckedChanged); 341 // 342 // IndependentRandomRestarterView 302 343 // 303 344 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 304 this.Controls.Add(this. sequenceButton);305 this.Controls.Add(this. snapshotButton);345 this.Controls.Add(this.maximizationCheckBox); 346 this.Controls.Add(this.terminationComboBox); 306 347 this.Controls.Add(this.tabControl); 307 this.Controls.Add(this. timeLimitTextBox);348 this.Controls.Add(this.maxExecutionTimeTextBox); 308 349 this.Controls.Add(this.timeLimitLabel); 309 this.Controls.Add(this.label1); 310 this.Controls.Add(this.snapshotsTextBox); 311 this.Controls.Add(this.storeAlgorithmInEachSnapshotCheckBox); 312 this.Name = "TimeLimitRunView"; 350 this.Controls.Add(this.terminationLabel); 351 this.Controls.Add(this.targetValueLabel); 352 this.Controls.Add(this.maximizationLabel); 353 this.Controls.Add(this.moveCostPerSolutionLabel); 354 this.Controls.Add(this.evaluationsLimitabel); 355 this.Controls.Add(this.moveCostPerSolutionTextBox); 356 this.Controls.Add(this.targetValueTextBox); 357 this.Controls.Add(this.maxEvaluationsTextBox); 358 this.Name = "IndependentRandomRestarterView"; 313 359 this.Size = new System.Drawing.Size(549, 464); 314 this.Controls.SetChildIndex(this.storeAlgorithmInEachSnapshotCheckBox, 0); 315 this.Controls.SetChildIndex(this.snapshotsTextBox, 0); 316 this.Controls.SetChildIndex(this.label1, 0); 360 this.Controls.SetChildIndex(this.maxEvaluationsTextBox, 0); 361 this.Controls.SetChildIndex(this.targetValueTextBox, 0); 362 this.Controls.SetChildIndex(this.moveCostPerSolutionTextBox, 0); 363 this.Controls.SetChildIndex(this.evaluationsLimitabel, 0); 364 this.Controls.SetChildIndex(this.moveCostPerSolutionLabel, 0); 365 this.Controls.SetChildIndex(this.maximizationLabel, 0); 366 this.Controls.SetChildIndex(this.targetValueLabel, 0); 367 this.Controls.SetChildIndex(this.terminationLabel, 0); 317 368 this.Controls.SetChildIndex(this.timeLimitLabel, 0); 318 this.Controls.SetChildIndex(this. timeLimitTextBox, 0);369 this.Controls.SetChildIndex(this.maxExecutionTimeTextBox, 0); 319 370 this.Controls.SetChildIndex(this.tabControl, 0); 320 371 this.Controls.SetChildIndex(this.nameLabel, 0); … … 327 378 this.Controls.SetChildIndex(this.executionTimeTextBox, 0); 328 379 this.Controls.SetChildIndex(this.startButton, 0); 329 this.Controls.SetChildIndex(this. snapshotButton, 0);330 this.Controls.SetChildIndex(this. sequenceButton, 0);380 this.Controls.SetChildIndex(this.terminationComboBox, 0); 381 this.Controls.SetChildIndex(this.maximizationCheckBox, 0); 331 382 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 332 383 this.tabControl.ResumeLayout(false); 333 384 this.algorithmTabPage.ResumeLayout(false); 334 this. snapshotsTabPage.ResumeLayout(false);385 this.currentRunTabPage.ResumeLayout(false); 335 386 this.runsTabPage.ResumeLayout(false); 336 387 this.ResumeLayout(false); … … 342 393 343 394 private System.Windows.Forms.Label timeLimitLabel; 344 private System.Windows.Forms.TextBox timeLimitTextBox; 345 private System.Windows.Forms.Label label1; 346 private System.Windows.Forms.TextBox snapshotsTextBox; 347 private System.Windows.Forms.CheckBox storeAlgorithmInEachSnapshotCheckBox; 395 private System.Windows.Forms.TextBox maxExecutionTimeTextBox; 396 private System.Windows.Forms.Label evaluationsLimitabel; 397 private System.Windows.Forms.TextBox maxEvaluationsTextBox; 348 398 private MainForm.WindowsForms.DragOverTabControl tabControl; 399 private System.Windows.Forms.TabPage runsTabPage; 400 private RunCollectionView runsView; 401 private System.Windows.Forms.OpenFileDialog openFileDialog; 402 private System.Windows.Forms.TextBox targetValueTextBox; 403 private System.Windows.Forms.Label targetValueLabel; 404 private System.Windows.Forms.ComboBox terminationComboBox; 405 private System.Windows.Forms.Label terminationLabel; 406 private System.Windows.Forms.TextBox moveCostPerSolutionTextBox; 407 private System.Windows.Forms.Label moveCostPerSolutionLabel; 408 private System.Windows.Forms.Label maximizationLabel; 409 private System.Windows.Forms.CheckBox maximizationCheckBox; 349 410 private System.Windows.Forms.TabPage algorithmTabPage; 350 411 private MainForm.WindowsForms.ViewHost algorithmViewHost; 351 412 private System.Windows.Forms.Button openAlgorithmButton; 352 413 private System.Windows.Forms.Button newAlgorithmButton; 353 private System.Windows.Forms.TabPage snapshotsTabPage; 354 private RunCollectionView snapshotsView; 355 private System.Windows.Forms.TabPage runsTabPage; 356 private RunCollectionView runsView; 357 private System.Windows.Forms.OpenFileDialog openFileDialog; 358 private System.Windows.Forms.Button snapshotButton; 359 private System.Windows.Forms.Button sequenceButton; 414 private System.Windows.Forms.TabPage currentRunTabPage; 415 private RunView currentRunView; 360 416 } 361 417 } -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/IRRestarterView.cs
r12764 r12804 22 22 using System; 23 23 using System.ComponentModel; 24 using System.Globalization; 24 25 using System.Linq; 25 using System.Text.RegularExpressions;26 26 using System.Windows.Forms; 27 using HeuristicLab. Collections;27 using HeuristicLab.Analysis; 28 28 using HeuristicLab.Common; 29 using HeuristicLab.Common.Resources;30 29 using HeuristicLab.Core; 31 30 using HeuristicLab.Core.Views; 32 31 using HeuristicLab.MainForm; 33 using HeuristicLab.MainForm.WindowsForms;34 32 using HeuristicLab.PluginInfrastructure; 35 33 36 34 namespace HeuristicLab.Optimization.Views { 37 [View(" TimeLimit RunView")]38 [Content(typeof( TimeLimitRun), IsDefaultView = true)]39 public partial class TimeLimitRunView : IOptimizerView {35 [View("Independent Random Restarter View")] 36 [Content(typeof(IndepdentRandomRestarter), IsDefaultView = true)] 37 public partial class IndependentRandomRestarterView : IOptimizerView { 40 38 protected TypeSelectorDialog algorithmTypeSelectorDialog; 41 39 protected virtual bool SuppressEvents { get; set; } 42 40 43 public new TimeLimitRunContent {44 get { return ( TimeLimitRun)base.Content; }41 public new IndepdentRandomRestarter Content { 42 get { return (IndepdentRandomRestarter)base.Content; } 45 43 set { base.Content = value; } 46 44 } 47 45 48 public TimeLimitRunView() {46 public IndependentRandomRestarterView() { 49 47 InitializeComponent(); 50 snapshotButton.Text = String.Empty; 51 snapshotButton.Image = VSImageLibrary.Camera; 48 terminationComboBox.Items.AddRange(Enum.GetValues(typeof(TerminationCriterium)).Cast<object>().ToArray()); 52 49 } 53 50 … … 62 59 protected override void DeregisterContentEvents() { 63 60 Content.PropertyChanged -= Content_PropertyChanged; 64 Content.SnapshotTimes.ItemsAdded -= Content_SnapshotTimes_Changed;65 Content.SnapshotTimes.ItemsMoved -= Content_SnapshotTimes_Changed;66 Content.SnapshotTimes.ItemsRemoved -= Content_SnapshotTimes_Changed;67 Content.SnapshotTimes.ItemsReplaced -= Content_SnapshotTimes_Changed;68 Content.SnapshotTimes.CollectionReset -= Content_SnapshotTimes_Changed;69 61 base.DeregisterContentEvents(); 70 62 } … … 72 64 base.RegisterContentEvents(); 73 65 Content.PropertyChanged += Content_PropertyChanged; 74 Content.SnapshotTimes.ItemsAdded += Content_SnapshotTimes_Changed;75 Content.SnapshotTimes.ItemsMoved += Content_SnapshotTimes_Changed;76 Content.SnapshotTimes.ItemsRemoved += Content_SnapshotTimes_Changed;77 Content.SnapshotTimes.ItemsReplaced += Content_SnapshotTimes_Changed;78 Content.SnapshotTimes.CollectionReset += Content_SnapshotTimes_Changed;79 66 } 80 67 … … 84 71 try { 85 72 if (Content == null) { 86 timeLimitTextBox.Text = TimeSpanHelper.FormatNatural(TimeSpan.FromSeconds(60)); 87 snapshotsTextBox.Text = String.Empty; 88 storeAlgorithmInEachSnapshotCheckBox.Checked = false; 73 maxExecutionTimeTextBox.Text = String.Empty; 74 maxEvaluationsTextBox.Text = String.Empty; 75 moveCostPerSolutionTextBox.Text = String.Empty; 76 targetValueTextBox.Text = String.Empty; 77 maximizationCheckBox.CheckState = CheckState.Indeterminate; 78 terminationComboBox.SelectedIndex = -1; 79 89 80 algorithmViewHost.Content = null; 90 snapshotsView.Content = null;81 currentRunView.Content = null; 91 82 runsView.Content = null; 92 83 } else { 93 timeLimitTextBox.Text = TimeSpanHelper.FormatNatural(Content.MaximumExecutionTime); 94 snapshotsTextBox.Text = String.Join(" ; ", Content.SnapshotTimes.Select(x => TimeSpanHelper.FormatNatural(x, true))); 95 storeAlgorithmInEachSnapshotCheckBox.Checked = Content.StoreAlgorithmInEachSnapshot; 84 maxExecutionTimeTextBox.Text = TimeSpanHelper.FormatNatural(Content.MaximumExecutionTime); 85 maxEvaluationsTextBox.Text = Content.MaximumEvaluations.ToString(); 86 moveCostPerSolutionTextBox.Text = Content.MoveCostPerSolution.ToString(CultureInfo.CurrentCulture.NumberFormat); 87 targetValueTextBox.Text = Content.TargetValue.ToString(CultureInfo.CurrentCulture.NumberFormat); 88 maximizationCheckBox.Checked = Content.Maximization; 89 terminationComboBox.SelectedItem = Content.TerminationCriterium; 90 96 91 algorithmViewHost.Content = Content.Algorithm; 97 snapshotsView.Content = Content.Snapshots;92 currentRunView.Content = Content.CurrentRun; 98 93 runsView.Content = Content.Runs; 99 94 } … … 103 98 protected override void SetEnabledStateOfControls() { 104 99 base.SetEnabledStateOfControls(); 105 timeLimitTextBox.Enabled = Content != null && !ReadOnly; 106 snapshotsTextBox.Enabled = Content != null && !ReadOnly; 107 storeAlgorithmInEachSnapshotCheckBox.Enabled = Content != null && !ReadOnly; 100 maxExecutionTimeTextBox.Enabled = Content != null && !ReadOnly && !Locked; 101 maxEvaluationsTextBox.Enabled = Content != null && !ReadOnly && !Locked; 102 moveCostPerSolutionTextBox.Enabled = Content != null && !ReadOnly && !Locked; 103 targetValueTextBox.Enabled = Content != null && !ReadOnly && !Locked; 104 maximizationCheckBox.Enabled = Content != null && !ReadOnly && !Locked; 105 terminationComboBox.Enabled = Content != null && !ReadOnly && !Locked; 108 106 newAlgorithmButton.Enabled = Content != null && !ReadOnly; 109 107 openAlgorithmButton.Enabled = Content != null && !ReadOnly; 110 108 algorithmViewHost.Enabled = Content != null; 111 snapshotsView.Enabled = Content != null;109 currentRunView.Enabled = Content != null; 112 110 runsView.Enabled = Content != null; 113 }114 115 protected override void SetEnabledStateOfExecutableButtons() {116 base.SetEnabledStateOfExecutableButtons();117 snapshotButton.Enabled = Content != null && Content.Algorithm != null && Content.ExecutionState == ExecutionState.Paused;118 111 } 119 112 … … 133 126 #region Content events 134 127 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 135 switch (e.PropertyName) {136 case "MaximumExecutionTime":137 SuppressEvents = true;138 try {139 timeLimitTextBox.Text = TimeSpanHelper.FormatNatural(Content.MaximumExecutionTime);140 } finally { SuppressEvents = false; }141 break;142 case "SnapshotTimes":143 SuppressEvents = true;144 try {145 if (Content.SnapshotTimes.Any())146 snapshotsTextBox.Text = String.Join(" ; ", Content.SnapshotTimes.Select(x => TimeSpanHelper.FormatNatural(x, true)));147 else snapshotsTextBox.Text = String.Empty;148 Content.SnapshotTimes.ItemsAdded += Content_SnapshotTimes_Changed;149 Content.SnapshotTimes.ItemsMoved += Content_SnapshotTimes_Changed;150 Content.SnapshotTimes.ItemsRemoved += Content_SnapshotTimes_Changed;151 Content.SnapshotTimes.ItemsReplaced += Content_SnapshotTimes_Changed;152 Content.SnapshotTimes.CollectionReset += Content_SnapshotTimes_Changed;153 } finally { SuppressEvents = false; }154 break;155 case "StoreAlgorithmInEachSnapshot":156 SuppressEvents = true;157 try {158 storeAlgorithmInEachSnapshotCheckBox.Checked = Content.StoreAlgorithmInEachSnapshot;159 } finally { SuppressEvents = false; }160 break;161 case "Algorithm":162 SuppressEvents = true;163 try {164 algorithmViewHost.Content = Content.Algorithm;165 } finally { SuppressEvents = false; }166 break;167 case "Snapshots":168 SuppressEvents = true;169 try {170 snapshotsView.Content = Content.Snapshots;171 } finally { SuppressEvents = false; }172 break;173 case "Runs":174 SuppressEvents = true;175 try {176 runsView.Content = Content.Runs;177 } finally { SuppressEvents = false; }178 break;179 }180 }181 182 private void Content_SnapshotTimes_Changed(object sender, EventArgs e) {183 128 SuppressEvents = true; 184 129 try { 185 if (Content.SnapshotTimes.Any()) 186 snapshotsTextBox.Text = string.Join(" ; ", Content.SnapshotTimes.Select(x => TimeSpanHelper.FormatNatural(x, true))); 187 else snapshotsTextBox.Text = String.Empty; 130 switch (e.PropertyName) { 131 case "TerminationCriterium": terminationComboBox.SelectedItem = Content.TerminationCriterium; break; 132 case "MaximumExecutionTime": maxExecutionTimeTextBox.Text = TimeSpanHelper.FormatNatural(Content.MaximumExecutionTime); break; 133 case "MaximumEvaluations": maxEvaluationsTextBox.Text = Content.MaximumEvaluations.ToString(); break; 134 case "TargetValue": targetValueTextBox.Text = Content.TargetValue.ToString(CultureInfo.CurrentCulture.NumberFormat); break; 135 case "Maximization": maximizationCheckBox.Checked = Content.Maximization; break; 136 case "MoveCostPerSolution": moveCostPerSolutionTextBox.Text = Content.MoveCostPerSolution.ToString(CultureInfo.CurrentCulture.NumberFormat); break; 137 case "Algorithm": algorithmViewHost.Content = Content.Algorithm; break; 138 case "CurrentRun": currentRunView.Content = Content.CurrentRun; break; 139 case "Runs": runsView.Content = Content.Runs; break; 140 } 188 141 } finally { SuppressEvents = false; } 189 142 } … … 191 144 192 145 #region Control events 193 private void timeLimitTextBox_Validating(object sender, CancelEventArgs e) { 194 if (SuppressEvents) return; 146 private void maxExecutionTimeTextBox_Validating(object sender, CancelEventArgs e) { 147 if (SuppressEvents) return; 148 if (InvokeRequired) { 149 Invoke((Action<object, CancelEventArgs>)maxExecutionTimeTextBox_Validating, sender, e); 150 return; 151 } 195 152 TimeSpan ts; 196 if (!TimeSpanHelper.TryGetFromNaturalFormat( timeLimitTextBox.Text, out ts)) {197 e.Cancel = ! timeLimitTextBox.ReadOnly && timeLimitTextBox.Enabled;198 errorProvider.SetError( timeLimitTextBox, "Please enter a valid time span, e.g. 20 seconds ; 45s ; 4min ; 1h ; 3 hours ; 2 days ; 4d");153 if (!TimeSpanHelper.TryGetFromNaturalFormat(maxExecutionTimeTextBox.Text, out ts)) { 154 e.Cancel = !maxExecutionTimeTextBox.ReadOnly && maxExecutionTimeTextBox.Enabled; 155 errorProvider.SetError(maxExecutionTimeTextBox, "Please enter a valid time span, e.g. 20 seconds ; 45s ; 4min ; 1h ; 3 hours ; 2 days ; 4d"); 199 156 } else { 200 157 Content.MaximumExecutionTime = ts; 201 158 e.Cancel = false; 202 errorProvider.SetError(timeLimitTextBox, null); 203 } 204 } 205 206 private void snapshotsTextBox_Validating(object sender, CancelEventArgs e) { 207 if (SuppressEvents) return; 208 e.Cancel = false; 209 errorProvider.SetError(snapshotsTextBox, null); 210 211 var snapshotTimes = new ObservableList<TimeSpan>(); 212 var matches = Regex.Matches(snapshotsTextBox.Text, @"(\d+[ ;,\t]*\w+)"); 213 foreach (Match m in matches) { 214 TimeSpan value; 215 if (!TimeSpanHelper.TryGetFromNaturalFormat(m.Value, out value)) { 216 e.Cancel = !snapshotsTextBox.ReadOnly && snapshotsTextBox.Enabled; // don't cancel an operation that cannot be edited 217 errorProvider.SetError(snapshotsTextBox, "Error parsing " + m.Value + ", please provide a valid time span, e.g. 20 seconds ; 45s ; 4min ; 1h ; 3 hours ; 2 days ; 4d"); 218 return; 219 } else { 220 snapshotTimes.Add(value); 221 } 222 } 223 Content.SnapshotTimes = snapshotTimes; 224 } 225 226 private void storeAlgorithmInEachSnapshotCheckBox_CheckedChanged(object sender, EventArgs e) { 227 if (SuppressEvents) return; 228 SuppressEvents = true; 229 try { 230 Content.StoreAlgorithmInEachSnapshot = storeAlgorithmInEachSnapshotCheckBox.Checked; 231 } finally { SuppressEvents = false; } 159 errorProvider.SetError(maxExecutionTimeTextBox, null); 160 } 161 } 162 163 private void maxEvaluationsTextBox_Validating(object sender, CancelEventArgs e) { 164 if (SuppressEvents) return; 165 if (InvokeRequired) { 166 Invoke((Action<object, CancelEventArgs>)maxEvaluationsTextBox_Validating, sender, e); 167 return; 168 } 169 int value; 170 if (!int.TryParse(maxEvaluationsTextBox.Text, out value)) { 171 e.Cancel = !maxEvaluationsTextBox.ReadOnly && maxEvaluationsTextBox.Enabled; 172 errorProvider.SetError(maxEvaluationsTextBox, "Please enter a valid integer number."); 173 } else { 174 Content.MaximumEvaluations = value; 175 e.Cancel = false; 176 errorProvider.SetError(maxEvaluationsTextBox, null); 177 } 178 } 179 180 private void moveCostPerSolutionTextBox_Validating(object sender, CancelEventArgs e) { 181 if (SuppressEvents) return; 182 if (InvokeRequired) { 183 Invoke((Action<object, CancelEventArgs>)moveCostPerSolutionTextBox_Validating, sender, e); 184 return; 185 } 186 double value; 187 if (!double.TryParse(moveCostPerSolutionTextBox.Text, out value)) { 188 e.Cancel = !moveCostPerSolutionTextBox.ReadOnly && moveCostPerSolutionTextBox.Enabled; 189 errorProvider.SetError(moveCostPerSolutionTextBox, "Please enter a valid integer number."); 190 } else { 191 Content.MoveCostPerSolution = value; 192 e.Cancel = false; 193 errorProvider.SetError(moveCostPerSolutionTextBox, null); 194 } 195 } 196 197 private void targetValueTextBox_Validating(object sender, CancelEventArgs e) { 198 if (SuppressEvents) return; 199 if (InvokeRequired) { 200 Invoke((Action<object, CancelEventArgs>)targetValueTextBox_Validating, sender, e); 201 return; 202 } 203 double value; 204 if (!double.TryParse(targetValueTextBox.Text, out value)) { 205 e.Cancel = !targetValueTextBox.ReadOnly && targetValueTextBox.Enabled; 206 errorProvider.SetError(targetValueTextBox, "Please enter a valid integer number."); 207 } else { 208 Content.TargetValue = value; 209 e.Cancel = false; 210 errorProvider.SetError(targetValueTextBox, null); 211 } 212 } 213 214 private void maximizationCheckBox_CheckedChanged(object sender, EventArgs e) { 215 if (SuppressEvents) return; 216 if (InvokeRequired) { 217 Invoke((Action<object, EventArgs>)maximizationCheckBox_CheckedChanged, sender, e); 218 return; 219 } 220 Content.Maximization = maximizationCheckBox.Checked; 221 } 222 223 private void terminationComboBox_SelectedIndexChanged(object sender, EventArgs e) { 224 if (SuppressEvents) return; 225 if (InvokeRequired) { 226 Invoke((Action<object, EventArgs>)terminationComboBox_SelectedIndexChanged, sender, e); 227 return; 228 } 229 Content.TerminationCriterium = (TerminationCriterium)terminationComboBox.SelectedItem; 232 230 } 233 231 … … 236 234 algorithmTypeSelectorDialog = new TypeSelectorDialog { Caption = "Select Algorithm" }; 237 235 algorithmTypeSelectorDialog.TypeSelector.Caption = "Available Algorithms"; 238 algorithmTypeSelectorDialog.TypeSelector.Configure(typeof(IAlgorithm), false, true); 236 algorithmTypeSelectorDialog.TypeSelector.Configure(typeof(IAlgorithm) 237 , showNotInstantiableTypes: false, showGenericTypes: false); 239 238 } 240 239 if (algorithmTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) { … … 275 274 private void algorithmTabPage_DragEnterOver(object sender, DragEventArgs e) { 276 275 e.Effect = DragDropEffects.None; 277 if (!ReadOnly && (e.Data.GetData(Constants.DragDropDataFormat) is IAlgorithm)) { 276 var alg = e.Data.GetData(Constants.DragDropDataFormat) as IAlgorithm; 277 if (!ReadOnly && alg != null) { 278 if (!typeof(ISingleObjectiveHeuristicOptimizationProblem).IsAssignableFrom(alg.ProblemType)) 279 return; 278 280 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 279 281 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key … … 291 293 } 292 294 } 293 294 private void snapshotButton_Click(object sender, EventArgs e) {295 Content.Snapshot();296 }297 298 private void sequenceButton_Click(object sender, EventArgs e) {299 using (var dialog = new DefineArithmeticTimeSpanProgressionDialog(TimeSpan.FromSeconds(1), Content.MaximumExecutionTime, TimeSpan.FromSeconds(1))) {300 if (dialog.ShowDialog() == DialogResult.OK) {301 if (dialog.Values.Any())302 Content.SnapshotTimes = new ObservableList<TimeSpan>(dialog.Values);303 else Content.SnapshotTimes = new ObservableList<TimeSpan>();304 }305 }306 }307 295 #endregion 308 296 #endregion -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.Designer.cs
r12803 r12804 44 44 /// </summary> 45 45 private void InitializeComponent() { 46 this.components = new System.ComponentModel.Container(); 46 47 this.dataTableComboBox = new System.Windows.Forms.ComboBox(); 47 48 this.label1 = new System.Windows.Forms.Label(); … … 50 51 this.groupComboBox = new System.Windows.Forms.ComboBox(); 51 52 this.logScalingCheckBox = new System.Windows.Forms.CheckBox(); 53 this.targetsTextBox = new System.Windows.Forms.TextBox(); 54 this.label3 = new System.Windows.Forms.Label(); 55 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 56 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 52 57 this.SuspendLayout(); 53 58 // … … 81 86 this.viewHost.Content = null; 82 87 this.viewHost.Enabled = false; 83 this.viewHost.Location = new System.Drawing.Point(4, 57);88 this.viewHost.Location = new System.Drawing.Point(4, 90); 84 89 this.viewHost.Name = "viewHost"; 85 90 this.viewHost.ReadOnly = false; 86 this.viewHost.Size = new System.Drawing.Size(520, 2 91);91 this.viewHost.Size = new System.Drawing.Size(520, 258); 87 92 this.viewHost.TabIndex = 2; 88 93 this.viewHost.ViewsLabelVisible = true; … … 122 127 this.logScalingCheckBox.CheckedChanged += new System.EventHandler(this.logScalingCheckBox_CheckedChanged); 123 128 // 124 // RunCollectionECDFView 129 // targetsTextBox 130 // 131 this.targetsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 132 | System.Windows.Forms.AnchorStyles.Right))); 133 this.targetsTextBox.Location = new System.Drawing.Point(69, 57); 134 this.targetsTextBox.Name = "targetsTextBox"; 135 this.targetsTextBox.Size = new System.Drawing.Size(455, 20); 136 this.targetsTextBox.TabIndex = 6; 137 this.targetsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.targetsTextBox_Validating); 138 // 139 // label3 140 // 141 this.label3.AutoSize = true; 142 this.label3.Location = new System.Drawing.Point(3, 60); 143 this.label3.Name = "label3"; 144 this.label3.Size = new System.Drawing.Size(46, 13); 145 this.label3.TabIndex = 1; 146 this.label3.Text = "Targets:"; 147 // 148 // errorProvider 149 // 150 this.errorProvider.ContainerControl = this; 151 // 152 // RunCollectionRLDView 125 153 // 126 154 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 155 this.Controls.Add(this.targetsTextBox); 127 156 this.Controls.Add(this.logScalingCheckBox); 128 157 this.Controls.Add(this.groupComboBox); 129 158 this.Controls.Add(this.label2); 130 159 this.Controls.Add(this.viewHost); 160 this.Controls.Add(this.label3); 131 161 this.Controls.Add(this.label1); 132 162 this.Controls.Add(this.dataTableComboBox); 133 this.Name = "RunCollection ECDFView";163 this.Name = "RunCollectionRLDView"; 134 164 this.Size = new System.Drawing.Size(527, 374); 165 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 135 166 this.ResumeLayout(false); 136 167 this.PerformLayout(); … … 146 177 private System.Windows.Forms.ComboBox groupComboBox; 147 178 private System.Windows.Forms.CheckBox logScalingCheckBox; 179 private System.Windows.Forms.TextBox targetsTextBox; 180 private System.Windows.Forms.Label label3; 181 protected System.Windows.Forms.ErrorProvider errorProvider; 148 182 } 149 183 } -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs
r12803 r12804 42 42 } 43 43 44 private double[] levels; 45 44 46 private bool suppressUpdates; 45 47 private readonly IndexedDataTable<double> combinedDataTable; … … 167 169 var table = (string)dataTableComboBox.SelectedItem; 168 170 if (string.IsNullOrEmpty(table)) return; 169 var maximum = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item2)).Max(); 170 var minimum = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item2)).Min(); 171 var levels = Enumerable.Range(0, 51).Select(x => maximum - (x / 50.0) * (maximum - minimum)).ToArray(); 171 if (levels == null) { 172 var worst = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item2)).First(); 173 var best = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item2)).Last(); 174 levels = Enumerable.Range(0, 51).Select(x => worst + (x / 50.0) * (best - worst)).ToArray(); 175 suppressTargetsEvents = true; 176 targetsTextBox.Text = string.Join(" ; ", levels); 177 suppressTargetsEvents = false; 178 } 172 179 var selectedGroup = (string)groupComboBox.SelectedItem; 173 180 if (string.IsNullOrEmpty(selectedGroup)) return; … … 184 191 var resultsTable = (IndexedDataTable<double>)run.Results[table]; 185 192 xAxisTitles.Add(resultsTable.VisualProperties.XAxisTitle); 186 var graph = new LinkedList<Tuple<double, double>>(resultsTable.Rows.First().Values); 187 var current = graph.First.Next; 188 // prune convergence graph to obtain first hit times only 189 while (current != null) { 190 if (current.Value.Item2.IsAlmost(current.Previous.Value.Item2)) { 191 var h = current; 192 current = current.Previous; 193 graph.Remove(h); 194 } 195 current = current.Next; 196 } 193 var values = resultsTable.Rows.First().Values; 194 var maximization = values.First().Item2 < values.Last().Item2; 197 195 var i = 0; 198 current = graph.First; 199 while (i < levels.Length && current != null) { 200 if (current.Value.Item2 < levels[i]) { 201 if (hits.ContainsKey(current.Value.Item1)) 202 hits[current.Value.Item1]++; 203 else hits[current.Value.Item1] = 1; 196 var j = 0; 197 var current = values[j]; 198 var prev = Tuple.Create(-1.0, double.NaN); 199 while (i < levels.Length) { 200 if ((double.IsNaN(prev.Item2) || prev.Item2 != current.Item2) 201 && (maximization && current.Item2 >= levels[i] 202 || !maximization && current.Item2 <= levels[i])) { 203 if (hits.ContainsKey(current.Item1)) 204 hits[current.Item1]++; 205 else hits[current.Item1] = 1; 204 206 i++; 205 207 } else { 206 current = current.Next; 208 j++; 209 if (j >= values.Count) break; 210 prev = current; 211 current = values[j]; 207 212 } 208 213 } … … 266 271 combinedDataTable.VisualProperties.XAxisLogScale = logScalingCheckBox.Checked; 267 272 } 273 274 private bool suppressTargetsEvents; 275 private void targetsTextBox_Validating(object sender, CancelEventArgs e) { 276 if (suppressTargetsEvents) return; 277 var targetStrings = targetsTextBox.Text.Split(new[] { ';', '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries); 278 var targetList = new List<double>(); 279 foreach (var ts in targetStrings) { 280 double t; 281 if (!double.TryParse(ts, out t)) { 282 errorProvider.SetError(targetsTextBox, "Not all targets can be parsed: " + ts); 283 e.Cancel = true; 284 return; 285 } 286 targetList.Add(t); 287 } 288 if (targetList.Count == 0) { 289 errorProvider.SetError(targetsTextBox, "Give at least one target value!"); 290 e.Cancel = true; 291 return; 292 } 293 e.Cancel = false; 294 errorProvider.SetError(targetsTextBox, null); 295 levels = targetList.ToArray(); 296 } 268 297 } 269 298 } -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunView.cs
r12012 r12804 97 97 98 98 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 99 if (InvokeRequired) { 100 Invoke((Action<object, PropertyChangedEventArgs>)Content_PropertyChanged, sender, e); 101 return; 102 } 99 103 if (e.PropertyName == "Color") { 100 104 if (InvokeRequired) this.Invoke((Action)UpdateColor, null); … … 112 116 113 117 private void ParametersOnItemsChanged(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) { 118 if (InvokeRequired) { 119 Invoke((Action<object, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>>>)ParametersOnItemsChanged, sender, e); 120 return; 121 } 114 122 foreach (var item in e.OldItems) { 115 123 listView.Items.Remove(parametersItemToListViewItem[item.Key]); … … 124 132 125 133 private void ParametersOnItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) { 134 if (InvokeRequired) { 135 Invoke((Action<object, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>>>)ParametersOnItemsRemoved, sender, e); 136 return; 137 } 126 138 foreach (var item in e.Items) { 127 139 listView.Items.Remove(parametersItemToListViewItem[item.Key]); … … 131 143 132 144 private void ResultsOnItemsChanged(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) { 145 if (InvokeRequired) { 146 Invoke((Action<object, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>>>)ResultsOnItemsChanged, sender, e); 147 return; 148 } 133 149 foreach (var item in e.OldItems) { 134 150 listView.Items.Remove(resultsItemToListViewItem[item.Key]); … … 143 159 144 160 private void ResultsOnItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) { 161 if (InvokeRequired) { 162 Invoke((Action<object, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>>>)ResultsOnItemsRemoved, sender, e); 163 return; 164 } 145 165 foreach (var item in e.Items) { 146 166 listView.Items.Remove(resultsItemToListViewItem[item.Key]);
Note: See TracChangeset
for help on using the changeset viewer.