Changeset 13402 for trunk/sources/HeuristicLab.Algorithms.ALPS/3.3/AlpsOffspringSelectionGeneticAlgorithmMainLoop.cs
- Timestamp:
- 11/25/15 17:50:52 (8 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.ALPS/3.3/AlpsOffspringSelectionGeneticAlgorithmMainLoop.cs
r13326 r13402 32 32 namespace HeuristicLab.Algorithms.ALPS { 33 33 34 [Item("Alps GeneticAlgorithmMainLoop", "An ALPSgenetic algorithm main loop operator.")]34 [Item("AlpsOffspringSelectionGeneticAlgorithmMainLoop", "An ALPS offspring selection genetic algorithm main loop operator.")] 35 35 [StorableClass] 36 public sealed class Alps GeneticAlgorithmMainLoop : AlgorithmOperator {36 public sealed class AlpsOffspringSelectionGeneticAlgorithmMainLoop : AlgorithmOperator { 37 37 #region Parameter Properties 38 38 public IValueLookupParameter<IRandom> GlobalRandomParameter { … … 91 91 get { return (IValueLookupParameter<BoolValue>)Parameters["ReevaluateElites"]; } 92 92 } 93 public IValueLookupParameter<BoolValue> PlusSelectionParameter { 94 get { return (IValueLookupParameter<BoolValue>)Parameters["PlusSelection"]; } 93 94 public IValueLookupParameter<DoubleValue> SuccessRatioParameter { 95 get { return (IValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; } 96 } 97 public ILookupParameter<DoubleValue> ComparisonFactorParameter { 98 get { return (ILookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; } 99 } 100 public IValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter { 101 get { return (IValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; } 102 } 103 public IValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter { 104 get { return (IValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; } 105 } 106 public IValueLookupParameter<BoolValue> FillPopulationWithParentsParameter { 107 get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; } 95 108 } 96 109 … … 121 134 122 135 [StorableConstructor] 123 private Alps GeneticAlgorithmMainLoop(bool deserializing)136 private AlpsOffspringSelectionGeneticAlgorithmMainLoop(bool deserializing) 124 137 : base(deserializing) { } 125 private Alps GeneticAlgorithmMainLoop(AlpsGeneticAlgorithmMainLoop original, Cloner cloner)138 private AlpsOffspringSelectionGeneticAlgorithmMainLoop(AlpsOffspringSelectionGeneticAlgorithmMainLoop original, Cloner cloner) 126 139 : base(original, cloner) { } 127 140 public override IDeepCloneable Clone(Cloner cloner) { 128 return new Alps GeneticAlgorithmMainLoop(this, cloner);129 } 130 public Alps GeneticAlgorithmMainLoop()141 return new AlpsOffspringSelectionGeneticAlgorithmMainLoop(this, cloner); 142 } 143 public AlpsOffspringSelectionGeneticAlgorithmMainLoop() 131 144 : base() { 132 145 Parameters.Add(new ValueLookupParameter<IRandom>("GlobalRandom", "A pseudo random number generator.")); … … 151 164 Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.")); 152 165 Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)")); 153 Parameters.Add(new ValueLookupParameter<BoolValue>("PlusSelection", "Include the parents in the selection of the invividuals for the next generation.")); 166 167 Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.")); 168 Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactor", "The comparison factor is used to determine whether the offspring should be compared to the better parent, the worse parent or a quality value linearly interpolated between them. It is in the range [0;1].")); 169 Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.")); 170 Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.")); 171 Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.")); 154 172 155 173 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Age", "The age of individuals.")); … … 168 186 var layerVariableCreator = new VariableCreator() { Name = "Initialize Layer" }; 169 187 var initLayerAnalyzerPlaceholder = new Placeholder() { Name = "LayerAnalyzer (Placeholder)" }; 188 var layerResultCollector = new ResultsCollector() { Name = "Collect layer results" }; 170 189 var initAnalyzerPlaceholder = new Placeholder() { Name = "Analyzer (Placeholder)" }; 171 190 var resultsCollector = new ResultsCollector(); … … 173 192 var matingPoolProcessor = new UniformSubScopesProcessor() { Name = "Process Mating Pools" }; 174 193 var initializeLayer = new Assigner() { Name = "Reset LayerEvaluatedSolutions" }; 175 var mainOperator = new Alps GeneticAlgorithmMainOperator();194 var mainOperator = new AlpsOffspringSelectionGeneticAlgorithmMainOperator(); 176 195 var generationsIcrementor = new IntCounter() { Name = "Increment Generations" }; 177 196 var evaluatedSolutionsReducer = new DataReducer() { Name = "Increment EvaluatedSolutions" }; … … 195 214 layerVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Layer", new IntValue(0))); 196 215 layerVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("LayerResults")); 216 layerVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0))); 217 layerVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0))); 197 218 layerVariableCreator.Successor = initLayerAnalyzerPlaceholder; 198 219 199 220 initLayerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name; 200 initLayerAnalyzerPlaceholder.Successor = null; 221 initLayerAnalyzerPlaceholder.Successor = layerResultCollector; 222 223 layerResultCollector.ResultsParameter.ActualName = "LayerResults"; 224 layerResultCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", "Displays the rising selection pressure during a generation.", "SelectionPressure")); 225 layerResultCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", "Indicates how many successful children were already found during a generation (relative to the population size).", "CurrentSuccessRatio")); 226 layerResultCollector.Successor = null; 201 227 202 228 initAnalyzerPlaceholder.OperatorParameter.ActualName = AnalyzerParameter.Name; … … 233 259 mainOperator.ElitesParameter.ActualName = ElitesParameter.Name; 234 260 mainOperator.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name; 235 mainOperator.PlusSelectionParameter.ActualName = PlusSelectionParameter.Name; 261 mainOperator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name; 262 mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; 263 mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio"; 264 mainOperator.SelectionPressureParameter.ActualName = "SelectionPressure"; 265 mainOperator.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name; 266 mainOperator.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name; 267 mainOperator.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 236 268 mainOperator.AgeParameter.ActualName = AgeParameter.Name; 237 269 mainOperator.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name; … … 327 359 var updateLayerNumber = new Assigner() { Name = "Layer = OpenLayers" }; 328 360 var historyWiper = new ResultsHistoryWiper() { Name = "Clear History in Results" }; 329 var createChildrenViaCrossover = new Alps GeneticAlgorithmMainOperator();361 var createChildrenViaCrossover = new AlpsOffspringSelectionGeneticAlgorithmMainOperator(); 330 362 var incrEvaluatedSolutionsForNewLayer = new SubScopesCounter() { Name = "Update EvaluatedSolutions" }; 331 363 var incrOpenLayers = new IntCounter() { Name = "Incr. OpenLayers" }; … … 373 405 createChildrenViaCrossover.SelectorParameter.ActualName = SelectorParameter.Name; 374 406 createChildrenViaCrossover.CrossoverParameter.ActualName = CrossoverParameter.Name; 375 createChildrenViaCrossover.MutatorParameter.ActualName = MutatorParameter. Name;407 createChildrenViaCrossover.MutatorParameter.ActualName = MutatorParameter.ActualName; 376 408 createChildrenViaCrossover.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name; 377 409 createChildrenViaCrossover.ElitesParameter.ActualName = ElitesParameter.Name; 378 410 createChildrenViaCrossover.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name; 379 createChildrenViaCrossover.PlusSelectionParameter.ActualName = PlusSelectionParameter.Name; 411 createChildrenViaCrossover.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name; 412 createChildrenViaCrossover.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; 413 createChildrenViaCrossover.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio"; 414 createChildrenViaCrossover.SelectionPressureParameter.ActualName = "SelectionPressure"; 415 createChildrenViaCrossover.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name; 416 createChildrenViaCrossover.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name; 417 createChildrenViaCrossover.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; 380 418 createChildrenViaCrossover.AgeParameter.ActualName = AgeParameter.Name; 381 419 createChildrenViaCrossover.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
Note: See TracChangeset
for help on using the changeset viewer.