Changeset 12356


Ignore:
Timestamp:
04/29/15 10:42:04 (4 years ago)
Author:
pfleck
Message:

#2027 Split update and parameterization of TerminationCriteria similar to other operators.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/TerminationCriteria/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs

    r12355 r12356  
    356356      qualityTerminationCriterion = new ComparisonTerminationCriterion<DoubleValue>() { Name = "Maximum/Minimum Quality" };
    357357      executionTimeTerminationCriterion = new ExecutionTimeTimeTerminationCriterion(this, TimeSpan.FromMinutes(5)) { Name = "Maximum Execution Time" };
     358      ParameterizeTerminationCriteria();
    358359      UpdateTerminationCriteria();
    359360
     
    376377      ParameterizeSelectors();
    377378      ParameterizeAnalyzers();
     379      ParameterizeTerminationCriteria();
    378380      ParameterizeIterationBasedOperators();
    379381      UpdateCrossovers();
     
    405407      UpdateMutators();
    406408      UpdateAnalyzers();
     409      UpdateTerminationCriteria();
    407410      base.Problem_OperatorsChanged(sender, e);
    408411    }
     
    482485      }
    483486    }
     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    }
    484496    private void ParameterizeComparisonFactorModifiers() {
    485497      foreach (IDiscreteDoubleValueModifier modifier in ComparisonFactorModifierParameter.ValidValues) {
     
    541553    private void UpdateTerminationCriteria() {
    542554      TerminationCriteria.Operators.Clear();
    543 
    544555      if (Problem != null) {
    545556        foreach (var terminationCriterion in Problem.Operators.OfType<ITerminationCriterion>())
    546557          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);
    552558      }
    553559      TerminationCriteria.Operators.Add(maximumGenerationsTerminationCriterion);
Note: See TracChangeset for help on using the changeset viewer.