- Timestamp:
- 06/12/15 15:13:36 (9 years ago)
- Location:
- branches/TerminationCriteria/HeuristicLab.Termination/3.3
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/TerminationCriteria/HeuristicLab.Termination/3.3/ComparisonTerminator.cs
r12413 r12436 79 79 } 80 80 81 protected override bool CheckContinueCriterion() { 82 IComparable lhs = ComparisonValueParameter.ActualValue; 83 IComparable rhs = ThresholdParameter.Value; 84 85 return Comparison.Compare(lhs, rhs); 86 } 87 81 88 private void Initialize() { 82 89 ComparisonParameter.Value.ValueChanged += new EventHandler(Comparison_ValueChanged); 83 90 } 84 85 public override void CollectParameterValues(IDictionary<string, IItem> values) {86 base.CollectParameterValues(values);87 values.Add(ComparisonValueParameter.Name, new StringValue(ComparisonValueParameter.ActualName));88 }89 90 91 private void Comparison_ValueChanged(object sender, EventArgs e) { 91 92 OnComparisonChanged(); … … 95 96 } 96 97 97 protected override bool CheckContinueCriterion() { 98 IComparable lhs = ComparisonValueParameter.ActualValue; 99 IComparable rhs = ThresholdParameter.Value; 100 101 return Comparison.Compare(lhs, rhs); 98 public override void CollectParameterValues(IDictionary<string, IItem> values) { 99 base.CollectParameterValues(values); 100 values.Add(ComparisonValueParameter.Name, new StringValue(ComparisonValueParameter.ActualName)); 102 101 } 103 102 -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/ExecutionTimeTerminator.cs
r12407 r12436 53 53 protected override bool CheckContinueCriterion() { 54 54 var max = ThresholdParameter.Value.Value; 55 56 55 return executable.ExecutionTime < max; 57 56 } -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/MultiTerminator.cs
r12414 r12436 37 37 public static new Image StaticItemImage { 38 38 get { return HeuristicLab.Common.Resources.VSImageLibrary.FlagRed; } 39 }40 public override Image ItemImage {41 get {42 if (Breakpoint) return HeuristicLab.Common.Resources.VSImageLibrary.BreakpointActive;43 else return base.ItemImage;44 }45 39 } 46 40 -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/SingleObjectiveQualityTerminator.cs
r12411 r12436 31 31 public void Parameterize(IParameter qualityParameter, ISingleObjectiveHeuristicOptimizationProblem problem) { 32 32 ComparisonValueParameter.ActualName = qualityParameter.Name; 33 if (problem != null) {34 var maximizationParameter = (IValueParameter<BoolValue>)problem.MaximizationParameter; 35 if (maximizationParameter != null) {36 bool maximization = maximizationParameter.Value.Value;37 Comparison = maximization ? ComparisonType.Less : ComparisonType.Greater;38 Threshold.Value = maximization ? double.MaxValue : double.MinValue;39 }33 if (problem == null) return; 34 35 var maximizationParameter = (IValueParameter<BoolValue>)problem.MaximizationParameter; 36 if (maximizationParameter != null) { 37 bool maximization = maximizationParameter.Value.Value; 38 Comparison = maximization ? ComparisonType.Less : ComparisonType.Greater; 39 Threshold.Value = maximization ? double.MaxValue : double.MinValue; 40 40 } 41 41 } -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/Terminator.cs
r12414 r12436 53 53 if (!TerminateParameter.ActualValue.Value) { // If terminate flag is already set, no need to check further termination criteria. 54 54 bool terminate = !CheckContinueCriterion(); 55 TerminateParameter.ActualValue = new BoolValue(terminate);55 TerminateParameter.ActualValue.Value = terminate; 56 56 } 57 57 return base.Apply(); -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/ThresholdTerminator.cs
r12415 r12436 31 31 [StorableClass] 32 32 public abstract class ThresholdTerminator<T> : Terminator, ISingleValueTerminator where T : class, IItem, IStringConvertibleValue, new() { 33 IParameter ISingleValueTerminator.SingleValueParameter { 34 get { return ThresholdParameter; } 35 } 33 36 [Storable] 34 37 private IFixedValueParameter<T> thresholdParameter; … … 45 48 OnThresholdParameterChanged(); 46 49 } 47 }48 IParameter ISingleValueTerminator.SingleValueParameter {49 get { return ThresholdParameter; }50 50 } 51 51 … … 78 78 RegisterThresholdParameterEvents(); 79 79 } 80 private void RegisterThresholdParameterEvents() { 81 Threshold.ValueChanged += new EventHandler(Threshold_ValueChanged); 82 } 83 private void OnThresholdParameterChanged() { 84 RegisterThresholdParameterEvents(); 85 } 80 86 81 87 private void Threshold_ValueChanged(object sender, EventArgs e) { … … 86 92 } 87 93 88 private void OnThresholdParameterChanged() {89 RegisterThresholdParameterEvents();90 }91 92 private void RegisterThresholdParameterEvents() {93 Threshold.ValueChanged += new EventHandler(Threshold_ValueChanged);94 }95 96 94 public override string ToString() { 97 95 if (ThresholdParameter.Value == null) return Name;
Note: See TracChangeset
for help on using the changeset viewer.