Changeset 12366
- Timestamp:
- 04/29/15 17:04:43 (10 years ago)
- Location:
- branches/TerminationCriteria
- Files:
-
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/TerminationCriteria/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r12364 r12366 490 490 qualityTerminationCriterion.Name = maximization ? "Maximum Quality" : "Minimum Quality"; 491 491 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); 494 494 } 495 495 } -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/ComparisonTerminationCriterion.cs
r12364 r12366 30 30 [Item("ComparisonTerminationCriterion", "An termination criterion which compares to values.")] 31 31 [StorableClass] 32 public class ComparisonTerminationCriterion<T> : T erminationCriterionwhere 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"]; } 35 35 } 36 public IValueLookupParameter<T> RightSideParameter { 37 get { return (IValueLookupParameter<T>)Parameters["RightSide"]; } 38 } 36 39 37 private ValueParameter<Comparison> ComparisonParameter { 40 38 get { return (ValueParameter<Comparison>)Parameters["Comparison"]; } … … 48 46 [StorableConstructor] 49 47 protected ComparisonTerminationCriterion(bool deserializing) : base(deserializing) { } 50 [StorableHook(HookType.AfterDeserialization)]51 private void AfterDeserialization() {52 Initialize();53 }54 48 protected ComparisonTerminationCriterion(ComparisonTerminationCriterion<T> original, Cloner cloner) 55 : base(original, cloner) { 56 Initialize(); 57 } 49 : base(original, cloner) { } 58 50 public override IDeepCloneable Clone(Cloner cloner) { 59 51 return new ComparisonTerminationCriterion<T>(this, cloner); … … 61 53 public ComparisonTerminationCriterion() 62 54 : 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.")); 65 56 Parameters.Add(new ValueParameter<Comparison>("Comparison", "The type of comparison.", new Comparison(ComparisonType.GreaterOrEqual)) { Hidden = true }); 66 67 Initialize();68 57 } 69 58 public ComparisonTerminationCriterion(string leftSideActualName, string rightSideActualName, ComparisonType comparison = ComparisonType.GreaterOrEqual) 70 59 : this() { 71 LeftSideParameter.ActualName = leftSideActualName;72 RightSideParameter.ActualName = rightSideActualName;60 ValueParameter.ActualName = leftSideActualName; 61 ThresholdParameter.ActualName = rightSideActualName; 73 62 Comparison.Value = comparison; 74 63 } 75 64 public ComparisonTerminationCriterion(string leftSideActualName, T rightSideValue, ComparisonType comparison = ComparisonType.GreaterOrEqual) 76 65 : this() { 77 LeftSideParameter.ActualName = leftSideActualName;78 RightSideParameter.Value = rightSideValue;66 ValueParameter.ActualName = leftSideActualName; 67 ThresholdParameter.Value = rightSideValue; 79 68 Comparison.Value = comparison; 80 69 } 81 70 82 private void Initialize() {83 RightSideParameter.ToStringChanged += (s, a) => OnToStringChanged();84 }85 86 71 protected override bool CheckTermination() { 87 IComparable lhs = LeftSideParameter.ActualValue;88 IComparable rhs = RightSideParameter.ActualValue;72 IComparable lhs = ValueParameter.ActualValue; 73 IComparable rhs = ThresholdParameter.ActualValue; 89 74 90 75 int i = lhs.CompareTo(rhs); … … 107 92 } 108 93 109 public override string ToString() { 110 if (RightSideParameter.Value == null) return Name; 111 else return Name + ": " + RightSideParameter.Value; 112 } 94 113 95 } 114 96 } -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/ExecutionTimeTimeTerminationCriterion.cs
r12355 r12366 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Data; 26 using HeuristicLab.Parameters;27 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 27 … … 30 29 [Item("ExecutionTimeTimeTerminationCriterion", "")] 31 30 [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> { 37 32 38 33 [Storable] … … 52 47 public ExecutionTimeTimeTerminationCriterion(IExecutable executable, TimeSpan maximumExecutionTime) { 53 48 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"; 55 52 } 56 53 57 54 protected override bool CheckTermination() { 58 var max = MaximumExecutionTimeParameter.Value.Value;55 var max = ThresholdParameter.Value.Value; 59 56 60 57 return executable.ExecutionTime > max; -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/HeuristicLab.Termination-3.3.csproj
r12362 r12366 141 141 </ItemGroup> 142 142 <ItemGroup> 143 <Compile Include="Views\ComparisonTerminationCriterionView.cs"> 143 <Compile Include="ThresholdTerminationCriterion.cs" /> 144 <Compile Include="Views\ThresholdTerminationCriterionView.cs"> 144 145 <SubType>UserControl</SubType> 145 146 </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> 148 149 </Compile> 149 150 <Compile Include="ITerminationCriterion.cs" /> -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/Views/ThresholdTerminationCriterionView.Designer.cs
r12362 r12366 21 21 22 22 namespace HeuristicLab.Termination.Views { 23 partial class ComparisonTerminationCriterionView<T> {23 partial class ThresholdTerminationCriterionView<T> { 24 24 /// <summary> 25 25 /// Required designer variable. … … 62 62 this.viewHost.ViewType = null; 63 63 // 64 // ComparisonTerminationCriterionView64 // ThresholdTerminationCriterionView 65 65 // 66 66 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 67 67 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 68 68 this.Controls.Add(this.viewHost); 69 this.Name = " ComparisonTerminationCriterionView";69 this.Name = "ThresholdTerminationCriterionView"; 70 70 this.ResumeLayout(false); 71 71 -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/Views/ThresholdTerminationCriterionView.cs
r12364 r12366 27 27 namespace HeuristicLab.Termination.Views { 28 28 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 { 32 32 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; } 35 35 set { base.Content = value; } 36 36 } 37 37 38 public ComparisonTerminationCriterionView() {38 public ThresholdTerminationCriterionView() { 39 39 InitializeComponent(); 40 40 } … … 44 44 viewHost.Content = null; 45 45 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; 48 48 else 49 viewHost.Content = Content. RightSideParameter;49 viewHost.Content = Content.ThresholdParameter; 50 50 } 51 51 }
Note: See TracChangeset
for help on using the changeset viewer.