Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/01/15 16:47:32 (9 years ago)
Author:
pfleck
Message:

#2027

  • Removed MaximumIterationsTerminator and MaximumEvaluatedSolutionsTermimator because they practically do the same.
  • Add the possibility for ThresholdTerminators to use a foreign parameter (e.g. MaximumSelectionPressure). This way the terminator can use parameters which are still relevant for the algorithm and still provide consistent management of the terminators.
  • Renamed IThresholdTerminator to ISingleValueTerminator.
File:
1 edited

Legend:

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

    r12410 r12411  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 
    3029namespace HeuristicLab.Termination {
    3130  [Item("ThresholdTerminator", "Base class for all termination criteria which specifies some threshold.")]
    3231  [StorableClass]
    33   public abstract class ThresholdTerminator<T> : Terminator, IThresholdTerminator where T : class, IItem, IStringConvertibleValue, new() {
     32  public abstract class ThresholdTerminator<T> : Terminator, ISingleValueTerminator where T : class, IItem, IStringConvertibleValue, new() {
     33    [Storable]
     34    private IFixedValueParameter<T> thresholdParameter;
    3435    public IFixedValueParameter<T> ThresholdParameter {
    35       get { return (IFixedValueParameter<T>)Parameters["Threshold"]; }
     36      get { return thresholdParameter; }
     37      set {
     38        if (value == null) throw new ArgumentNullException("Threshold parameter must not be null.");
     39        if (value.Value == null) throw new ArgumentNullException("Threshold parameter value must not be null.");
     40        if (thresholdParameter == value) return;
     41
     42        if (thresholdParameter != null) Parameters.Remove(thresholdParameter);
     43        thresholdParameter = value;
     44        Parameters.Add(thresholdParameter);
     45        OnThresholdParameterChanged();
     46      }
    3647    }
    37     IParameter IThresholdTerminator.ThresholdParameter {
     48    IParameter ISingleValueTerminator.ThresholdParameter {
    3849      get { return ThresholdParameter; }
    3950    }
     
    5162    protected ThresholdTerminator(ThresholdTerminator<T> original, Cloner cloner)
    5263      : base(original, cloner) {
     64      thresholdParameter = cloner.Clone(original.thresholdParameter);
    5365      Initialize();
    5466    }
     
    5870      : base() {
    5971      if (threshold == null) throw new ArgumentNullException("threshold");
    60       Parameters.Add(new FixedValueParameter<T>("Threshold", "The limit of the termiation criterion.", threshold));
     72      thresholdParameter = new FixedValueParameter<T>("Threshold", "The limit of the termiation criterion.", threshold);
     73      Parameters.Add(thresholdParameter);
    6174      Initialize();
    6275    }
    6376
    6477    private void Initialize() {
    65       Threshold.ValueChanged += new EventHandler(Threshold_ValueChanged);
     78      RegisterThresholdParameterEvents();
    6679    }
    6780
     
    7386    }
    7487
     88    private void OnThresholdParameterChanged() {
     89      RegisterThresholdParameterEvents();
     90    }
     91
     92    private void RegisterThresholdParameterEvents() {
     93      Threshold.ValueChanged += new EventHandler(Threshold_ValueChanged);
     94    }
     95
    7596    public override string ToString() {
    7697      if (ThresholdParameter.Value == null) return Name;
Note: See TracChangeset for help on using the changeset viewer.