Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12436


Ignore:
Timestamp:
06/12/15 15:13:36 (9 years ago)
Author:
mkommend
Message:

#2027: Improved code formatting for terminators.

Location:
branches/TerminationCriteria/HeuristicLab.Termination/3.3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/ComparisonTerminator.cs

    r12413 r12436  
    7979    }
    8080
     81    protected override bool CheckContinueCriterion() {
     82      IComparable lhs = ComparisonValueParameter.ActualValue;
     83      IComparable rhs = ThresholdParameter.Value;
     84
     85      return Comparison.Compare(lhs, rhs);
     86    }
     87
    8188    private void Initialize() {
    8289      ComparisonParameter.Value.ValueChanged += new EventHandler(Comparison_ValueChanged);
    8390    }
    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 
    9091    private void Comparison_ValueChanged(object sender, EventArgs e) {
    9192      OnComparisonChanged();
     
    9596    }
    9697
    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));
    102101    }
    103102
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/ExecutionTimeTerminator.cs

    r12407 r12436  
    5353    protected override bool CheckContinueCriterion() {
    5454      var max = ThresholdParameter.Value.Value;
    55 
    5655      return executable.ExecutionTime < max;
    5756    }
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/MultiTerminator.cs

    r12414 r12436  
    3737    public static new Image StaticItemImage {
    3838      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       }
    4539    }
    4640
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/SingleObjectiveQualityTerminator.cs

    r12411 r12436  
    3131    public void Parameterize(IParameter qualityParameter, ISingleObjectiveHeuristicOptimizationProblem problem) {
    3232      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;
    4040      }
    4141    }
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/Terminator.cs

    r12414 r12436  
    5353      if (!TerminateParameter.ActualValue.Value) { // If terminate flag is already set, no need to check further termination criteria.
    5454        bool terminate = !CheckContinueCriterion();
    55         TerminateParameter.ActualValue = new BoolValue(terminate);
     55        TerminateParameter.ActualValue.Value = terminate;
    5656      }
    5757      return base.Apply();
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/ThresholdTerminator.cs

    r12415 r12436  
    3131  [StorableClass]
    3232  public abstract class ThresholdTerminator<T> : Terminator, ISingleValueTerminator where T : class, IItem, IStringConvertibleValue, new() {
     33    IParameter ISingleValueTerminator.SingleValueParameter {
     34      get { return ThresholdParameter; }
     35    }
    3336    [Storable]
    3437    private IFixedValueParameter<T> thresholdParameter;
     
    4548        OnThresholdParameterChanged();
    4649      }
    47     }
    48     IParameter ISingleValueTerminator.SingleValueParameter {
    49       get { return ThresholdParameter; }
    5050    }
    5151
     
    7878      RegisterThresholdParameterEvents();
    7979    }
     80    private void RegisterThresholdParameterEvents() {
     81      Threshold.ValueChanged += new EventHandler(Threshold_ValueChanged);
     82    }
     83    private void OnThresholdParameterChanged() {
     84      RegisterThresholdParameterEvents();
     85    }
    8086
    8187    private void Threshold_ValueChanged(object sender, EventArgs e) {
     
    8692    }
    8793
    88     private void OnThresholdParameterChanged() {
    89       RegisterThresholdParameterEvents();
    90     }
    91 
    92     private void RegisterThresholdParameterEvents() {
    93       Threshold.ValueChanged += new EventHandler(Threshold_ValueChanged);
    94     }
    95 
    9694    public override string ToString() {
    9795      if (ThresholdParameter.Value == null) return Name;
Note: See TracChangeset for help on using the changeset viewer.