Changeset 12410 for branches/TerminationCriteria
- Timestamp:
- 06/01/15 14:21:02 (9 years ago)
- Location:
- branches/TerminationCriteria
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/TerminationCriteria/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r12408 r12410 83 83 get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateElites"]; } 84 84 } 85 private ValueParameter<IntValue> MaximumGenerationsParameter {86 get { return ( ValueParameter<IntValue>)Parameters["MaximumGenerations"]; }85 private IFixedValueParameter<IntValue> MaximumGenerationsParameter { 86 get { return (IFixedValueParameter<IntValue>)Parameters["MaximumGenerations"]; } 87 87 } 88 88 private ValueLookupParameter<DoubleValue> SuccessRatioParameter { … … 158 158 set { ReevaluateElitesParameter.Value.Value = value; } 159 159 } 160 public IntValueMaximumGenerations {161 get { return MaximumGenerationsParameter.Value ; }162 set { MaximumGenerationsParameter.Value = value; }160 public int MaximumGenerations { 161 get { return MaximumGenerationsParameter.Value.Value; } 162 set { MaximumGenerationsParameter.Value.Value = value; } 163 163 } 164 164 public DoubleValue SuccessRatio { … … 194 194 set { AnalyzerParameter.Value = value; } 195 195 } 196 197 196 public IntValue MaximumEvaluatedSolutions { 198 197 get { return MaximumEvaluatedSolutionsParameter.Value; } … … 222 221 private SuccessfulOffspringAnalyzer successfulOffspringAnalyzer; 223 222 [Storable] 224 private ComparisonTerminator<IntValue>generationsTerminator;223 private MaximumIterationsTerminator generationsTerminator; 225 224 [Storable] 226 225 private ComparisonTerminator<IntValue> evaluatedSolutionsTerminator; … … 228 227 private ComparisonTerminator<DoubleValue> selectionPressureTerminator; 229 228 [Storable] 230 private ComparisonTerminator<DoubleValue>qualityTerminator;229 private SingleObjectiveQualityTerminator qualityTerminator; 231 230 [Storable] 232 231 private ExecutionTimeTerminator executionTimeTerminator; … … 276 275 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 277 276 Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true }); 278 Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));277 Parameters.Add(new FixedValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000))); 279 278 Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1))); 280 279 Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0))); … … 339 338 ParameterizeSelectors(); 340 339 340 qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 341 selectionPressureAnalyzer = new ValueAnalyzer(); 342 successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); 343 ParameterizeAnalyzers(); 344 UpdateAnalyzers(); 345 346 generationsTerminator = new MaximumIterationsTerminator(); 347 evaluatedSolutionsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue)) { Name = "Evaluations" }; 348 selectionPressureTerminator = new ComparisonTerminator<DoubleValue>("SelectionPressure", ComparisonType.Less, new DoubleValue(200)) { Name = "Selection Pressure" }; 349 qualityTerminator = new SingleObjectiveQualityTerminator(); 350 executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5))) { Name = "Execution Time" }; 351 ParameterizeTerminators(); 352 UpdateTerminators(); 353 341 354 foreach (IDiscreteDoubleValueModifier modifier in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name)) 342 355 ComparisonFactorModifierParameter.ValidValues.Add(modifier); … … 344 357 if (linearModifier != null) ComparisonFactorModifierParameter.Value = linearModifier; 345 358 ParameterizeComparisonFactorModifiers(); 346 347 qualityAnalyzer = new BestAverageWorstQualityAnalyzer();348 selectionPressureAnalyzer = new ValueAnalyzer();349 successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();350 ParameterizeAnalyzers();351 UpdateAnalyzers();352 353 generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.Less, new IntValue(50)) { Name = "Generations" };354 evaluatedSolutionsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue)) { Name = "Evaluations" };355 selectionPressureTerminator = new ComparisonTerminator<DoubleValue>("SelectionPressure", ComparisonType.Less, new DoubleValue(200)) { Name = "Selection Pressure" };356 qualityTerminator = new ComparisonTerminator<DoubleValue>(new DoubleValue()) { Name = "Quality" };357 executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5))) { Name = "Execution Time" };358 ParameterizeTerminators();359 UpdateTerminators();360 359 361 360 Initialize(); … … 504 503 } 505 504 private void ParameterizeTerminators() { 506 qualityTerminator.ComparisonValueParameter.ActualName = qualityAnalyzer.CurrentBestQualityParameter.Name; 507 if (Problem != null) { 508 var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter; 509 if (maximizationParameter != null) { 510 bool maximization = maximizationParameter.Value.Value; 511 qualityTerminator.Comparison = maximization ? ComparisonType.Less : ComparisonType.Greater; 512 qualityTerminator.Threshold.Value = maximization ? double.MaxValue : double.MinValue; 513 } 514 } 505 generationsTerminator.IterationsParameter.ActualName = "Generations"; 506 generationsTerminator.MaximumIterationsParameter = MaximumGenerationsParameter; 507 508 qualityTerminator.Parameterize(qualityAnalyzer.CurrentBestQualityParameter, Problem); 515 509 } 516 510 private void ParameterizeComparisonFactorModifiers() { … … 572 566 } 573 567 private void UpdateTerminators() { 568 // ToDo restore checked state 574 569 Terminators.Operators.Clear(); 575 570 if (Problem != null) { -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/HeuristicLab.Termination-3.3.csproj
r12402 r12410 73 73 </PropertyGroup> 74 74 <ItemGroup> 75 <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 76 <SpecificVersion>False</SpecificVersion> 77 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath> 78 </Reference> 75 79 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 76 80 <SpecificVersion>False</SpecificVersion> … … 141 145 </ItemGroup> 142 146 <ItemGroup> 147 <Compile Include="IThresholdTerminator.cs" /> 148 <Compile Include="MaximumIterationsTerminator.cs" /> 149 <Compile Include="SingleObjectiveQualityTerminator.cs" /> 143 150 <Compile Include="ThresholdTerminator.cs" /> 144 151 <Compile Include="Views\ThresholdTerminatorView.cs"> -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/TerminationOperator.cs
r12405 r12410 82 82 public override IOperation InstrumentedApply() { 83 83 var next = new OperationCollection(base.InstrumentedApply()); 84 if (TerminateParameter.ActualValue != null && TerminateParameter.ActualValue.Value) {84 if (TerminateParameter.ActualValue.Value) { 85 85 if (TerminateBranch != null) next.Insert(0, ExecutionContext.CreateOperation(TerminateBranch)); 86 86 } else { -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/ThresholdTerminator.cs
r12408 r12410 31 31 [Item("ThresholdTerminator", "Base class for all termination criteria which specifies some threshold.")] 32 32 [StorableClass] 33 public abstract class ThresholdTerminator<T> : Terminator where T : class, IItem, IStringConvertibleValue, new() {33 public abstract class ThresholdTerminator<T> : Terminator, IThresholdTerminator where T : class, IItem, IStringConvertibleValue, new() { 34 34 public IFixedValueParameter<T> ThresholdParameter { 35 35 get { return (IFixedValueParameter<T>)Parameters["Threshold"]; } 36 } 37 IParameter IThresholdTerminator.ThresholdParameter { 38 get { return ThresholdParameter; } 36 39 } 37 40 -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/Views/ThresholdTerminatorView.Designer.cs
r12408 r12410 25 25 26 26 namespace HeuristicLab.Termination.Views { 27 partial class ThresholdTerminatorView <T> where T : class, IItem, IComparable, IStringConvertibleValue, new(){27 partial class ThresholdTerminatorView { 28 28 /// <summary> 29 29 /// Required designer variable. -
branches/TerminationCriteria/HeuristicLab.Termination/3.3/Views/ThresholdTerminatorView.cs
r12408 r12410 20 20 #endregion 21 21 22 using System;23 using HeuristicLab.Core;24 22 using HeuristicLab.Core.Views; 25 using HeuristicLab.Data;26 23 using HeuristicLab.MainForm; 27 24 … … 29 26 30 27 [View("ThresholdTerminator View")] 31 [Content(typeof( ThresholdTerminator<>), true)]32 public partial class ThresholdTerminatorView <T> : ItemView where T : class, IItem, IComparable, IStringConvertibleValue, new(){28 [Content(typeof(IThresholdTerminator), true)] 29 public partial class ThresholdTerminatorView : ItemView { 33 30 34 public new ThresholdTerminator<T>Content {35 get { return ( ThresholdTerminator<T>)base.Content; }31 public new IThresholdTerminator Content { 32 get { return (IThresholdTerminator)base.Content; } 36 33 set { base.Content = value; } 37 34 } … … 45 42 viewHost.Content = null; 46 43 if (Content != null) { 47 if (Content.ThresholdParameter. Value != null)48 viewHost.Content = Content.ThresholdParameter. Value;44 if (Content.ThresholdParameter.ActualValue != null) 45 viewHost.Content = Content.ThresholdParameter.ActualValue; 49 46 else 50 47 viewHost.Content = Content.ThresholdParameter;
Note: See TracChangeset
for help on using the changeset viewer.