Changeset 12534 for branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/AlpsSsGeneticAlgorithm.cs
- Timestamp:
- 06/29/15 17:09:30 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/AlpsSsGeneticAlgorithm.cs
r12271 r12534 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HeuristicLab.Common; … … 43 44 get { return (IValueParameter<IntValue>)Parameters["LayerSize"]; } 44 45 } 45 private IValueParameter<IntValue> MaximumIterationsParameter {46 get { return (IValueParameter<IntValue>)Parameters["MaximumIterations"]; }47 }48 46 public IConstrainedValueParameter<ISelector> SelectorParameter { 49 47 get { return (IConstrainedValueParameter<ISelector>)Parameters["Selector"]; } … … 74 72 set { LayerSizeParameter.Value = value; } 75 73 } 76 public IntValueMaximumIterations {77 get { return MaximumIterationsParameter.Value; }78 set { MaximumIterationsParameter.Value = value; }74 public int MaximumIterations { 75 get { return iterationsTerminator.Threshold.Value; } 76 set { iterationsTerminator.Threshold.Value = value; } 79 77 } 80 78 … … 108 106 get { return OperatorGraph.Iterate().OfType<AlpsSsGeneticAlgorithmMainLoop>().First(); } 109 107 } 108 109 [Storable] 110 private ComparisonTerminator<IntValue> iterationsTerminator; 110 111 111 112 [StorableConstructor] … … 114 115 private AlpsSsGeneticAlgorithm(AlpsSsGeneticAlgorithm original, Cloner cloner) 115 116 : base(original, cloner) { 117 iterationsTerminator = cloner.Clone(original.iterationsTerminator); 116 118 Initialize(); 117 119 } … … 123 125 : base() { 124 126 Parameters.Add(new ValueParameter<IntValue>("LayerSize", "The size of the population of solutions each layer.", new IntValue(100))); 125 Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of iterations that should be processed.", new IntValue(1000)));126 127 Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction.")); 127 128 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); … … 275 276 @operator.IterationsParameter.ActualName = "Iteration"; 276 277 @operator.IterationsParameter.Hidden = true; 277 @operator.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;278 @operator.MaximumIterationsParameter.ActualName = iterationsTerminator.ThresholdParameter.Name; 278 279 @operator.MaximumIterationsParameter.Hidden = true; 279 280 } … … 307 308 308 309 #region Updates 310 protected override void UpdateTerminators() { 311 var newTerminators = new Dictionary<ITerminator, bool> { 312 {iterationsTerminator, !Terminators.Operators.Contains(iterationsTerminator) || Terminators.Operators.ItemChecked(iterationsTerminator)}, 313 }; 314 315 base.UpdateTerminators(); 316 317 foreach (var newTerminator in newTerminators) 318 Terminators.Operators.Insert(0, newTerminator.Key, newTerminator.Value); 319 } 320 protected override void CreateTerminators() { 321 iterationsTerminator = new ComparisonTerminator<IntValue>("Iterations", ComparisonType.Less, new IntValue(1000)) { Name = "Iterations" }; 322 base.CreateTerminators(); 323 } 309 324 private void UpdateCrossovers() { 310 325 var oldCrossover = CrossoverParameter.Value;
Note: See TracChangeset
for help on using the changeset viewer.