Changeset 12356 for branches/TerminationCriteria/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm
- Timestamp:
- 04/29/15 10:42:04 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/TerminationCriteria/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r12355 r12356 356 356 qualityTerminationCriterion = new ComparisonTerminationCriterion<DoubleValue>() { Name = "Maximum/Minimum Quality" }; 357 357 executionTimeTerminationCriterion = new ExecutionTimeTimeTerminationCriterion(this, TimeSpan.FromMinutes(5)) { Name = "Maximum Execution Time" }; 358 ParameterizeTerminationCriteria(); 358 359 UpdateTerminationCriteria(); 359 360 … … 376 377 ParameterizeSelectors(); 377 378 ParameterizeAnalyzers(); 379 ParameterizeTerminationCriteria(); 378 380 ParameterizeIterationBasedOperators(); 379 381 UpdateCrossovers(); … … 405 407 UpdateMutators(); 406 408 UpdateAnalyzers(); 409 UpdateTerminationCriteria(); 407 410 base.Problem_OperatorsChanged(sender, e); 408 411 } … … 482 485 } 483 486 } 487 private void ParameterizeTerminationCriteria() { 488 if (Problem != null) { 489 bool maximization = ((BoolValue)Problem.MaximizationParameter.ActualValue).Value; 490 qualityTerminationCriterion.Name = maximization ? "Maximum Quality" : "Minimum Quality"; 491 qualityTerminationCriterion.Comparison = new Comparison(maximization ? ComparisonType.GreaterOrEqual : ComparisonType.LessOrEqual); 492 qualityTerminationCriterion.LeftSideParameter.ActualName = qualityAnalyzer.CurrentBestQualityParameter.Name; 493 qualityTerminationCriterion.RightSideParameter.Value = new DoubleValue(maximization ? double.MaxValue : double.MinValue); 494 } 495 } 484 496 private void ParameterizeComparisonFactorModifiers() { 485 497 foreach (IDiscreteDoubleValueModifier modifier in ComparisonFactorModifierParameter.ValidValues) { … … 541 553 private void UpdateTerminationCriteria() { 542 554 TerminationCriteria.Operators.Clear(); 543 544 555 if (Problem != null) { 545 556 foreach (var terminationCriterion in Problem.Operators.OfType<ITerminationCriterion>()) 546 557 TerminationCriteria.Operators.Add(terminationCriterion); 547 bool maximization = ((BoolValue)Problem.MaximizationParameter.ActualValue).Value;548 qualityTerminationCriterion.Name = maximization ? "Maximum Quality" : "Minimum Quality";549 qualityTerminationCriterion.Comparison = new Comparison(maximization ? ComparisonType.GreaterOrEqual : ComparisonType.LessOrEqual);550 qualityTerminationCriterion.LeftSideParameter.ActualName = qualityAnalyzer.CurrentBestQualityParameter.Name;551 qualityTerminationCriterion.RightSideParameter.Value = new DoubleValue(maximization ? double.MaxValue : double.MinValue);552 558 } 553 559 TerminationCriteria.Operators.Add(maximumGenerationsTerminationCriterion);
Note: See TracChangeset
for help on using the changeset viewer.