Changeset 12407
- Timestamp:
- 05/28/15 09:47:23 (10 years ago)
- Location:
- branches/TerminationCriteria
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/TerminationCriteria/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r12405 r12407 351 351 UpdateAnalyzers(); 352 352 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" }; 357 357 executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5))) { Name = "Execution Time" }; 358 358 ParameterizeTerminators(); … … 508 508 if (maximizationParameter != null) { 509 509 bool maximization = maximizationParameter.Value.Value; 510 qualityTerminator.Comparison = maximization ? ComparisonType. GreaterOrEqual : ComparisonType.LessOrEqual;511 qualityTerminator.Threshold.Value = maximization ? double.M axValue : double.MinValue;510 qualityTerminator.Comparison = maximization ? ComparisonType.Less : ComparisonType.Greater; 511 qualityTerminator.Threshold.Value = maximization ? double.MinValue : double.MaxValue; 512 512 } 513 513 } -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/ComparisonTerminator.cs
r12405 r12407 57 57 return new ComparisonTerminator<T>(this, cloner); 58 58 } 59 public ComparisonTerminator(T threshold = default(T))59 public ComparisonTerminator(T threshold) 60 60 : base(threshold) { 61 61 Parameters.Add(new LookupParameter<T>("ComparisonValue", "The left side value of the comparison.") { Hidden = false }); … … 63 63 Initialize(); 64 64 } 65 public ComparisonTerminator(string comparisonValueActualName, ComparisonType comparison = default(ComparisonType), T threshold = default(T))65 public ComparisonTerminator(string comparisonValueActualName, ComparisonType comparison, T threshold) 66 66 : this(threshold) { 67 67 ComparisonValueParameter.ActualName = comparisonValueActualName; … … 73 73 } 74 74 75 protected override bool Check Termination() {75 protected override bool CheckContinueCriterion() { 76 76 IComparable lhs = ComparisonValueParameter.ActualValue; 77 77 IComparable rhs = ThresholdParameter.Value; -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/ExecutionTimeTerminator.cs
r12405 r12407 51 51 } 52 52 53 protected override bool Check Termination() {53 protected override bool CheckContinueCriterion() { 54 54 var max = ThresholdParameter.Value.Value; 55 55 56 return executable.ExecutionTime >max;56 return executable.ExecutionTime < max; 57 57 } 58 58 59 59 public override string ToString() { 60 60 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); 62 62 } 63 63 } -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/Terminator.cs
r12405 r12407 51 51 public sealed override IOperation InstrumentedApply() { 52 52 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(); 54 54 TerminateParameter.ActualValue = new BoolValue(terminate); 55 55 } … … 57 57 } 58 58 59 protected abstract bool Check Termination();59 protected abstract bool CheckContinueCriterion(); 60 60 } 61 61 }
Note: See TracChangeset
for help on using the changeset viewer.