Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12407


Ignore:
Timestamp:
05/28/15 09:47:23 (10 years ago)
Author:
pfleck
Message:

#2027
Inverted the conditions to check the continue criteria instead of termination criteria.
Conditions are then specified more naturally: "while generations < max" instead of "break if generations > min".
If any Continue-Check returns false, the algorithm will be terminated.

The naming "Terminator" has to be discussed because it suggest to specify the criteria when the algorithm should stop, instead of continue.

Location:
branches/TerminationCriteria
Files:
4 edited

Legend:

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

    r12405 r12407  
    351351      UpdateAnalyzers();
    352352
    353       generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.GreaterOrEqual, new IntValue(50)) { Name = "Generations" };
    354       evaluatedSolutionsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.GreaterOrEqual, new IntValue(int.MaxValue)) { Name = "Evaluations" };
    355       selectionPressureTerminator = new ComparisonTerminator<DoubleValue>("SelectionPressure", ComparisonType.GreaterOrEqual, new DoubleValue(200)) { Name = "Selection Pressure" };
    356       qualityTerminator = new ComparisonTerminator<DoubleValue>(threshold: new DoubleValue()) { Name = "Quality" };
     353      generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.Less, new IntValue(50)) { Name = "Generations" };
     354      evaluatedSolutionsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue)) { Name = "Evaluations" };
     355      selectionPressureTerminator = new ComparisonTerminator<DoubleValue>("SelectionPressure", ComparisonType.Less, new DoubleValue(200)) { Name = "Selection Pressure" };
     356      qualityTerminator = new ComparisonTerminator<DoubleValue>(new DoubleValue()) { Name = "Quality" };
    357357      executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5))) { Name = "Execution Time" };
    358358      ParameterizeTerminators();
     
    508508        if (maximizationParameter != null) {
    509509          bool maximization = maximizationParameter.Value.Value;
    510           qualityTerminator.Comparison = maximization ? ComparisonType.GreaterOrEqual : ComparisonType.LessOrEqual;
    511           qualityTerminator.Threshold.Value = maximization ? double.MaxValue : double.MinValue;
     510          qualityTerminator.Comparison = maximization ? ComparisonType.Less : ComparisonType.Greater;
     511          qualityTerminator.Threshold.Value = maximization ? double.MinValue : double.MaxValue;
    512512        }
    513513      }
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/ComparisonTerminator.cs

    r12405 r12407  
    5757      return new ComparisonTerminator<T>(this, cloner);
    5858    }
    59     public ComparisonTerminator(T threshold = default(T))
     59    public ComparisonTerminator(T threshold)
    6060      : base(threshold) {
    6161      Parameters.Add(new LookupParameter<T>("ComparisonValue", "The left side value of the comparison.") { Hidden = false });
     
    6363      Initialize();
    6464    }
    65     public ComparisonTerminator(string comparisonValueActualName, ComparisonType comparison = default(ComparisonType), T threshold = default(T))
     65    public ComparisonTerminator(string comparisonValueActualName, ComparisonType comparison, T threshold)
    6666      : this(threshold) {
    6767      ComparisonValueParameter.ActualName = comparisonValueActualName;
     
    7373    }
    7474
    75     protected override bool CheckTermination() {
     75    protected override bool CheckContinueCriterion() {
    7676      IComparable lhs = ComparisonValueParameter.ActualValue;
    7777      IComparable rhs = ThresholdParameter.Value;
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/ExecutionTimeTerminator.cs

    r12405 r12407  
    5151    }
    5252
    53     protected override bool CheckTermination() {
     53    protected override bool CheckContinueCriterion() {
    5454      var max = ThresholdParameter.Value.Value;
    5555
    56       return executable.ExecutionTime > max;
     56      return executable.ExecutionTime < max;
    5757    }
    5858
    5959    public override string ToString() {
    6060      if (Threshold == null) return Name;
    61       else return string.Format("{0} {1} {2}", Name, ">", ThresholdParameter.Value);
     61      else return string.Format("{0} {1} {2}", Name, "<", ThresholdParameter.Value);
    6262    }
    6363  }
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/Terminator.cs

    r12405 r12407  
    5151    public sealed override IOperation InstrumentedApply() {
    5252      if (!TerminateParameter.ActualValue.Value) { // If terminate flag is already set, no need to check further termination criteria.
    53         bool terminate = CheckTermination();
     53        bool terminate = !CheckContinueCriterion();
    5454        TerminateParameter.ActualValue = new BoolValue(terminate);
    5555      }
     
    5757    }
    5858
    59     protected abstract bool CheckTermination();
     59    protected abstract bool CheckContinueCriterion();
    6060  }
    6161}
Note: See TracChangeset for help on using the changeset viewer.