Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12408 for branches


Ignore:
Timestamp:
05/28/15 14:22:03 (9 years ago)
Author:
pfleck
Message:

#2027

  • Added ValueChanged-events to Terminators.
  • Fixed wiring bug of quality-based Terminator.
Location:
branches/TerminationCriteria
Files:
5 edited

Legend:

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

    r12407 r12408  
    504504    }
    505505    private void ParameterizeTerminators() {
     506      qualityTerminator.ComparisonValueParameter.ActualName = qualityAnalyzer.CurrentBestQualityParameter.Name;
    506507      if (Problem != null) {
    507508        var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter;
     
    509510          bool maximization = maximizationParameter.Value.Value;
    510511          qualityTerminator.Comparison = maximization ? ComparisonType.Less : ComparisonType.Greater;
    511           qualityTerminator.Threshold.Value = maximization ? double.MinValue : double.MaxValue;
     512          qualityTerminator.Threshold.Value = maximization ? double.MaxValue : double.MinValue;
    512513        }
    513514      }
    514       qualityTerminator.ComparisonValueParameter.ActualName = qualityAnalyzer.CurrentBestQualityParameter.Name;
    515515    }
    516516    private void ParameterizeComparisonFactorModifiers() {
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/ComparisonTerminator.cs

    r12407 r12408  
    3030  [Item("ComparisonTerminator", "An termination criterion which compares two values.")]
    3131  [StorableClass]
    32   public class ComparisonTerminator<T> : ThresholdTerminator<T> where T : class, IItem, IComparable, new() {
     32  public class ComparisonTerminator<T> : ThresholdTerminator<T> where T : class, IItem, IComparable, IStringConvertibleValue, new() {
    3333    public ILookupParameter<T> ComparisonValueParameter {
    3434      get { return (ILookupParameter<T>)Parameters["ComparisonValue"]; }
     
    5757      return new ComparisonTerminator<T>(this, cloner);
    5858    }
     59
     60    public ComparisonTerminator()
     61      : this(new T()) { }
    5962    public ComparisonTerminator(T threshold)
    6063      : base(threshold) {
     
    7073
    7174    private void Initialize() {
    72       ComparisonParameter.ToStringChanged += (s, a) => OnToStringChanged();
     75      ComparisonParameter.Value.ValueChanged += new EventHandler(Comparison_ValueChanged);
     76    }
     77
     78    private void Comparison_ValueChanged(object sender, EventArgs e) {
     79      OnComparisonChanged();
     80    }
     81    protected virtual void OnComparisonChanged() {
     82      OnToStringChanged();
    7383    }
    7484
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/ThresholdTerminator.cs

    r12405 r12408  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2426using HeuristicLab.Parameters;
    2527using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2931  [Item("ThresholdTerminator", "Base class for all termination criteria which specifies some threshold.")]
    3032  [StorableClass]
    31   public abstract class ThresholdTerminator<T> : Terminator where T : class, IItem, new() {
     33  public abstract class ThresholdTerminator<T> : Terminator where T : class, IItem, IStringConvertibleValue, new() {
    3234    public IFixedValueParameter<T> ThresholdParameter {
    3335      get { return (IFixedValueParameter<T>)Parameters["Threshold"]; }
     
    4850      Initialize();
    4951    }
    50     protected ThresholdTerminator(T threshold = default(T))
     52    protected ThresholdTerminator()
     53      : this(new T()) { }
     54    protected ThresholdTerminator(T threshold)
    5155      : base() {
     56      if (threshold == null) throw new ArgumentNullException("threshold");
    5257      Parameters.Add(new FixedValueParameter<T>("Threshold", "The limit of the termiation criterion.", threshold));
    5358      Initialize();
     
    5560
    5661    private void Initialize() {
    57       ThresholdParameter.ToStringChanged += (s, a) => OnToStringChanged();
     62      Threshold.ValueChanged += new EventHandler(Threshold_ValueChanged);
     63    }
     64
     65    private void Threshold_ValueChanged(object sender, EventArgs e) {
     66      OnThresholdChanged();
     67    }
     68    protected virtual void OnThresholdChanged() {
     69      OnToStringChanged();
    5870    }
    5971
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/Views/ThresholdTerminatorView.Designer.cs

    r12405 r12408  
    2222using System;
    2323using HeuristicLab.Core;
     24using HeuristicLab.Data;
    2425
    2526namespace HeuristicLab.Termination.Views {
    26   partial class ThresholdTerminatorView<T> where T : class, IItem, IComparable, new() {
     27  partial class ThresholdTerminatorView<T> where T : class, IItem, IComparable, IStringConvertibleValue, new() {
    2728    /// <summary>
    2829    /// Required designer variable.
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/Views/ThresholdTerminatorView.cs

    r12405 r12408  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Core.Views;
     25using HeuristicLab.Data;
    2526using HeuristicLab.MainForm;
    2627
     
    2930  [View("ThresholdTerminator View")]
    3031  [Content(typeof(ThresholdTerminator<>), true)]
    31   public partial class ThresholdTerminatorView<T> : ItemView where T : class, IItem, IComparable, new() {
     32  public partial class ThresholdTerminatorView<T> : ItemView where T : class, IItem, IComparable, IStringConvertibleValue, new() {
    3233
    3334    public new ThresholdTerminator<T> Content {
Note: See TracChangeset for help on using the changeset viewer.