Changeset 12534 for branches/ALPS
- Timestamp:
- 06/29/15 17:09:30 (9 years ago)
- Location:
- branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3
- Files:
-
- 2 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; -
branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/AlpsSsGeneticAlgorithmMainLoop.cs
r12270 r12534 20 20 #endregion 21 21 22 using System.Linq;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 29 28 using HeuristicLab.Parameters; 30 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Selection;32 30 33 31 namespace HeuristicLab.Algorithms.ALPS.SteadyState { … … 107 105 var layerAnalyzer = new Placeholder() { Name = "LayerAnalyzer (Placeholder)" }; 108 106 var analyzer = new Placeholder() { Name = "Analyzer (Placeholder)" }; 109 var iterationsComparator = new Comparator() { Name = "Iterations >= MaximumIterations" }; 110 var terminateBranch = new ConditionalBranch() { Name = "Terminate?" }; 107 var termination = new TerminationOperator(); 111 108 112 109 … … 253 250 254 251 analyzer.OperatorParameter.ActualName = "Analyzer"; 255 analyzer.Successor = iterationsComparator; 256 257 iterationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual); 258 iterationsComparator.LeftSideParameter.ActualName = "Iterations"; 259 iterationsComparator.RightSideParameter.ActualName = MaximumIterationsParameter.Name; 260 iterationsComparator.ResultParameter.ActualName = "Terminate"; 261 iterationsComparator.Successor = terminateBranch; 262 263 terminateBranch.ConditionParameter.ActualName = "Terminate"; 264 terminateBranch.FalseBranch = initializeBatchIteration; 252 analyzer.Successor = termination; 253 254 termination.ContinueBranch = initializeBatchIteration; 265 255 } 266 256 }
Note: See TracChangeset
for help on using the changeset viewer.