Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12366 for branches


Ignore:
Timestamp:
04/29/15 17:04:43 (10 years ago)
Author:
pfleck
Message:

#2027 Added a base class ThresholdTerminationCriterion for generalization of the view, which shows only a single value threshold now, and of the ToString mechanic.

Location:
branches/TerminationCriteria
Files:
4 edited
2 moved

Legend:

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

    r12364 r12366  
    490490        qualityTerminationCriterion.Name = maximization ? "Maximum Quality" : "Minimum Quality";
    491491        qualityTerminationCriterion.Comparison = new Comparison(maximization ? ComparisonType.GreaterOrEqual : ComparisonType.LessOrEqual);
    492         qualityTerminationCriterion.LeftSideParameter.ActualName = qualityAnalyzer.CurrentBestQualityParameter.Name;
    493         qualityTerminationCriterion.RightSideParameter.Value = new DoubleValue(maximization ? double.MaxValue : double.MinValue);
     492        qualityTerminationCriterion.ValueParameter.ActualName = qualityAnalyzer.CurrentBestQualityParameter.Name;
     493        qualityTerminationCriterion.ThresholdParameter.Value = new DoubleValue(maximization ? double.MaxValue : double.MinValue);
    494494      }
    495495    }
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/ComparisonTerminationCriterion.cs

    r12364 r12366  
    3030  [Item("ComparisonTerminationCriterion", "An termination criterion which compares to values.")]
    3131  [StorableClass]
    32   public class ComparisonTerminationCriterion<T> : TerminationCriterion where T : class, IItem, IComparable {
    33     public ILookupParameter<T> LeftSideParameter {
    34       get { return (ILookupParameter<T>)Parameters["LeftSide"]; }
     32  public class ComparisonTerminationCriterion<T> : ThresholdTerminationCriterion<T> where T : class, IItem, IComparable {
     33    public ILookupParameter<T> ValueParameter {
     34      get { return (ILookupParameter<T>)Parameters["Value"]; }
    3535    }
    36     public IValueLookupParameter<T> RightSideParameter {
    37       get { return (IValueLookupParameter<T>)Parameters["RightSide"]; }
    38     }
     36
    3937    private ValueParameter<Comparison> ComparisonParameter {
    4038      get { return (ValueParameter<Comparison>)Parameters["Comparison"]; }
     
    4846    [StorableConstructor]
    4947    protected ComparisonTerminationCriterion(bool deserializing) : base(deserializing) { }
    50     [StorableHook(HookType.AfterDeserialization)]
    51     private void AfterDeserialization() {
    52       Initialize();
    53     }
    5448    protected ComparisonTerminationCriterion(ComparisonTerminationCriterion<T> original, Cloner cloner)
    55       : base(original, cloner) {
    56       Initialize();
    57     }
     49      : base(original, cloner) { }
    5850    public override IDeepCloneable Clone(Cloner cloner) {
    5951      return new ComparisonTerminationCriterion<T>(this, cloner);
     
    6153    public ComparisonTerminationCriterion()
    6254      : base() {
    63       Parameters.Add(new LookupParameter<T>("LeftSide", "The left side of the comparison."));
    64       Parameters.Add(new ValueLookupParameter<T>("RightSide", "The right side of the comparison."));
     55      Parameters.Add(new LookupParameter<T>("Value", "The left side value of the comparison."));
    6556      Parameters.Add(new ValueParameter<Comparison>("Comparison", "The type of comparison.", new Comparison(ComparisonType.GreaterOrEqual)) { Hidden = true });
    66 
    67       Initialize();
    6857    }
    6958    public ComparisonTerminationCriterion(string leftSideActualName, string rightSideActualName, ComparisonType comparison = ComparisonType.GreaterOrEqual)
    7059      : this() {
    71       LeftSideParameter.ActualName = leftSideActualName;
    72       RightSideParameter.ActualName = rightSideActualName;
     60      ValueParameter.ActualName = leftSideActualName;
     61      ThresholdParameter.ActualName = rightSideActualName;
    7362      Comparison.Value = comparison;
    7463    }
    7564    public ComparisonTerminationCriterion(string leftSideActualName, T rightSideValue, ComparisonType comparison = ComparisonType.GreaterOrEqual)
    7665      : this() {
    77       LeftSideParameter.ActualName = leftSideActualName;
    78       RightSideParameter.Value = rightSideValue;
     66      ValueParameter.ActualName = leftSideActualName;
     67      ThresholdParameter.Value = rightSideValue;
    7968      Comparison.Value = comparison;
    8069    }
    8170
    82     private void Initialize() {
    83       RightSideParameter.ToStringChanged += (s, a) => OnToStringChanged();
    84     }
    85 
    8671    protected override bool CheckTermination() {
    87       IComparable lhs = LeftSideParameter.ActualValue;
    88       IComparable rhs = RightSideParameter.ActualValue;
     72      IComparable lhs = ValueParameter.ActualValue;
     73      IComparable rhs = ThresholdParameter.ActualValue;
    8974
    9075      int i = lhs.CompareTo(rhs);
     
    10792    }
    10893
    109     public override string ToString() {
    110       if (RightSideParameter.Value == null) return Name;
    111       else return Name + ": " + RightSideParameter.Value;
    112     }
     94
    11395  }
    11496}
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/ExecutionTimeTimeTerminationCriterion.cs

    r12355 r12366  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
    26 using HeuristicLab.Parameters;
    2726using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827
     
    3029  [Item("ExecutionTimeTimeTerminationCriterion", "")]
    3130  [StorableClass]
    32   public class ExecutionTimeTimeTerminationCriterion : TerminationCriterion {
    33 
    34     private IValueParameter<TimeSpanValue> MaximumExecutionTimeParameter {
    35       get { return (IValueParameter<TimeSpanValue>)Parameters["MaximumExecutionTime"]; }
    36     }
     31  public class ExecutionTimeTimeTerminationCriterion : ThresholdTerminationCriterion<TimeSpanValue> {
    3732
    3833    [Storable]
     
    5247    public ExecutionTimeTimeTerminationCriterion(IExecutable executable, TimeSpan maximumExecutionTime) {
    5348      this.executable = executable;
    54       Parameters.Add(new ValueParameter<TimeSpanValue>("MaximumExecutionTime", "The maximum execution time of an algortihm.", new TimeSpanValue(maximumExecutionTime)));
     49      ThresholdParameter.Value = new TimeSpanValue(maximumExecutionTime);
     50
     51      Name = "Maximum Execution Time";
    5552    }
    5653
    5754    protected override bool CheckTermination() {
    58       var max = MaximumExecutionTimeParameter.Value.Value;
     55      var max = ThresholdParameter.Value.Value;
    5956
    6057      return executable.ExecutionTime > max;
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/HeuristicLab.Termination-3.3.csproj

    r12362 r12366  
    141141  </ItemGroup>
    142142  <ItemGroup>
    143     <Compile Include="Views\ComparisonTerminationCriterionView.cs">
     143    <Compile Include="ThresholdTerminationCriterion.cs" />
     144    <Compile Include="Views\ThresholdTerminationCriterionView.cs">
    144145      <SubType>UserControl</SubType>
    145146    </Compile>
    146     <Compile Include="Views\ComparisonTerminationCriterionView.Designer.cs">
    147       <DependentUpon>ComparisonTerminationCriterionView.cs</DependentUpon>
     147    <Compile Include="Views\ThresholdTerminationCriterionView.Designer.cs">
     148      <DependentUpon>ThresholdTerminationCriterionView.cs</DependentUpon>
    148149    </Compile>
    149150    <Compile Include="ITerminationCriterion.cs" />
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/Views/ThresholdTerminationCriterionView.Designer.cs

    r12362 r12366  
    2121
    2222namespace HeuristicLab.Termination.Views {
    23   partial class ComparisonTerminationCriterionView<T> {
     23  partial class ThresholdTerminationCriterionView<T> {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    6262      this.viewHost.ViewType = null;
    6363      //
    64       // ComparisonTerminationCriterionView
     64      // ThresholdTerminationCriterionView
    6565      //
    6666      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    6767      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    6868      this.Controls.Add(this.viewHost);
    69       this.Name = "ComparisonTerminationCriterionView";
     69      this.Name = "ThresholdTerminationCriterionView";
    7070      this.ResumeLayout(false);
    7171
  • branches/TerminationCriteria/HeuristicLab.Termination/3.3/Views/ThresholdTerminationCriterionView.cs

    r12364 r12366  
    2727namespace HeuristicLab.Termination.Views {
    2828
    29   [View("ComparisonTerminationCriterion View")]
    30   [Content(typeof(ComparisonTerminationCriterion<>), true)]
    31   public partial class ComparisonTerminationCriterionView<T> : ItemView where T : class, IItem, IComparable {
     29  [View("ThresholdTerminationCriterion View")]
     30  [Content(typeof(ThresholdTerminationCriterion<>), true)]
     31  public partial class ThresholdTerminationCriterionView<T> : ItemView where T : class, IItem, IComparable {
    3232
    33     public new ComparisonTerminationCriterion<T> Content {
    34       get { return (ComparisonTerminationCriterion<T>)base.Content; }
     33    public new ThresholdTerminationCriterion<T> Content {
     34      get { return (ThresholdTerminationCriterion<T>)base.Content; }
    3535      set { base.Content = value; }
    3636    }
    3737
    38     public ComparisonTerminationCriterionView() {
     38    public ThresholdTerminationCriterionView() {
    3939      InitializeComponent();
    4040    }
     
    4444      viewHost.Content = null;
    4545      if (Content != null) {
    46         if (Content.RightSideParameter.Value != null)
    47           viewHost.Content = Content.RightSideParameter.Value;
     46        if (Content.ThresholdParameter.Value != null)
     47          viewHost.Content = Content.ThresholdParameter.Value;
    4848        else
    49           viewHost.Content = Content.RightSideParameter;
     49          viewHost.Content = Content.ThresholdParameter;
    5050      }
    5151    }
Note: See TracChangeset for help on using the changeset viewer.