1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using HeuristicLab.Core;
|
---|
23 | using HeuristicLab.Data;
|
---|
24 | using HeuristicLab.Operators;
|
---|
25 | using HeuristicLab.Optimization;
|
---|
26 | using HeuristicLab.Optimization.Operators;
|
---|
27 | using HeuristicLab.Parameters;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm {
|
---|
31 | /// <summary>
|
---|
32 | /// An island offspring selection genetic algorithm main loop operator.
|
---|
33 | /// </summary>
|
---|
34 | [Item("IslandOffspringSelectionGeneticAlgorithmMainLoop", "An island offspring selection genetic algorithm main loop operator.")]
|
---|
35 | [StorableClass]
|
---|
36 | public sealed class IslandOffspringSelectionGeneticAlgorithmMainLoop : AlgorithmOperator {
|
---|
37 | #region Parameter Properties
|
---|
38 | public ValueLookupParameter<IRandom> RandomParameter {
|
---|
39 | get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
|
---|
40 | }
|
---|
41 | public ValueLookupParameter<BoolValue> MaximizationParameter {
|
---|
42 | get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
|
---|
43 | }
|
---|
44 | public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
|
---|
45 | get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
|
---|
46 | }
|
---|
47 | public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
|
---|
48 | get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
|
---|
49 | }
|
---|
50 | public ValueLookupParameter<IntValue> NumberOfIslandsParameter {
|
---|
51 | get { return (ValueLookupParameter<IntValue>)Parameters["NumberOfIslands"]; }
|
---|
52 | }
|
---|
53 | public ValueLookupParameter<IntValue> MigrationIntervalParameter {
|
---|
54 | get { return (ValueLookupParameter<IntValue>)Parameters["MigrationInterval"]; }
|
---|
55 | }
|
---|
56 | public ValueLookupParameter<PercentValue> MigrationRateParameter {
|
---|
57 | get { return (ValueLookupParameter<PercentValue>)Parameters["MigrationRate"]; }
|
---|
58 | }
|
---|
59 | public ValueLookupParameter<IOperator> MigratorParameter {
|
---|
60 | get { return (ValueLookupParameter<IOperator>)Parameters["Migrator"]; }
|
---|
61 | }
|
---|
62 | public ValueLookupParameter<IOperator> EmigrantsSelectorParameter {
|
---|
63 | get { return (ValueLookupParameter<IOperator>)Parameters["EmigrantsSelector"]; }
|
---|
64 | }
|
---|
65 | public ValueLookupParameter<IOperator> ImmigrationReplacerParameter {
|
---|
66 | get { return (ValueLookupParameter<IOperator>)Parameters["ImmigrationReplacer"]; }
|
---|
67 | }
|
---|
68 | public ValueLookupParameter<IntValue> PopulationSizeParameter {
|
---|
69 | get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; }
|
---|
70 | }
|
---|
71 | public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
|
---|
72 | get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
|
---|
73 | }
|
---|
74 | public ValueLookupParameter<IOperator> SelectorParameter {
|
---|
75 | get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
|
---|
76 | }
|
---|
77 | public ValueLookupParameter<IOperator> CrossoverParameter {
|
---|
78 | get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
|
---|
79 | }
|
---|
80 | public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
|
---|
81 | get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
|
---|
82 | }
|
---|
83 | public ValueLookupParameter<IOperator> MutatorParameter {
|
---|
84 | get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
|
---|
85 | }
|
---|
86 | public ValueLookupParameter<IOperator> EvaluatorParameter {
|
---|
87 | get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
|
---|
88 | }
|
---|
89 | public ValueLookupParameter<IntValue> ElitesParameter {
|
---|
90 | get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
|
---|
91 | }
|
---|
92 | public ValueLookupParameter<ResultCollection> ResultsParameter {
|
---|
93 | get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
|
---|
94 | }
|
---|
95 | public ValueLookupParameter<IOperator> VisualizerParameter {
|
---|
96 | get { return (ValueLookupParameter<IOperator>)Parameters["Visualizer"]; }
|
---|
97 | }
|
---|
98 | public LookupParameter<IItem> VisualizationParameter {
|
---|
99 | get { return (LookupParameter<IItem>)Parameters["Visualization"]; }
|
---|
100 | }
|
---|
101 | public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
|
---|
102 | get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
|
---|
103 | }
|
---|
104 | public LookupParameter<DoubleValue> ComparisonFactorParameter {
|
---|
105 | get { return (LookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
|
---|
106 | }
|
---|
107 | public ValueLookupParameter<DoubleValue> ComparisonFactorStartParameter {
|
---|
108 | get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorStart"]; }
|
---|
109 | }
|
---|
110 | public ValueLookupParameter<IOperator> ComparisonFactorModifierParameter {
|
---|
111 | get { return (ValueLookupParameter<IOperator>)Parameters["ComparisonFactorModifier"]; }
|
---|
112 | }
|
---|
113 | public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
|
---|
114 | get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
|
---|
115 | }
|
---|
116 | public ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
|
---|
117 | get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
|
---|
118 | }
|
---|
119 | public ValueLookupParameter<IOperator> AnalyzerParameter {
|
---|
120 | get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
|
---|
121 | }
|
---|
122 | public ValueLookupParameter<IOperator> IslandAnalyzerParameter {
|
---|
123 | get { return (ValueLookupParameter<IOperator>)Parameters["IslandAnalyzer"]; }
|
---|
124 | }
|
---|
125 | #endregion
|
---|
126 |
|
---|
127 | [StorableConstructor]
|
---|
128 | private IslandOffspringSelectionGeneticAlgorithmMainLoop(bool deserializing) : base() { }
|
---|
129 | public IslandOffspringSelectionGeneticAlgorithmMainLoop()
|
---|
130 | : base() {
|
---|
131 | #region Create parameters
|
---|
132 | Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
|
---|
133 | Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
|
---|
134 | Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
|
---|
135 | Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
|
---|
136 | Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfIslands", "The number of islands."));
|
---|
137 | Parameters.Add(new ValueLookupParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases."));
|
---|
138 | Parameters.Add(new ValueLookupParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands."));
|
---|
139 | Parameters.Add(new ValueLookupParameter<IOperator>("Migrator", "The migration strategy."));
|
---|
140 | Parameters.Add(new ValueLookupParameter<IOperator>("EmigrantsSelector", "Selects the individuals that will be migrated."));
|
---|
141 | Parameters.Add(new ValueLookupParameter<IOperator>("ImmigrationReplacer", "Replaces part of the original population with the immigrants."));
|
---|
142 | Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population of solutions."));
|
---|
143 | Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed."));
|
---|
144 | Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
|
---|
145 | Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
|
---|
146 | Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
|
---|
147 | Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
|
---|
148 | Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
|
---|
149 | Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
|
---|
150 | Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results."));
|
---|
151 | Parameters.Add(new ValueLookupParameter<IOperator>("Visualizer", "The operator used to visualize solutions."));
|
---|
152 | Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions."));
|
---|
153 | Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
|
---|
154 | Parameters.Add(new LookupParameter<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]."));
|
---|
155 | Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorStart", "The initial value for the comparison factor."));
|
---|
156 | Parameters.Add(new ValueLookupParameter<IOperator>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));
|
---|
157 | Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
|
---|
158 | 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."));
|
---|
159 | Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to the analyze the islands."));
|
---|
160 | Parameters.Add(new ValueLookupParameter<IOperator>("IslandAnalyzer", "The operator used to analyze each island."));
|
---|
161 | #endregion
|
---|
162 |
|
---|
163 | #region Create operators
|
---|
164 | VariableCreator variableCreator = new VariableCreator();
|
---|
165 | UniformSubScopesProcessor uniformSubScopesProcessor0 = new UniformSubScopesProcessor();
|
---|
166 | VariableCreator islandVariableCreator = new VariableCreator();
|
---|
167 | Placeholder islandAnalyzer1 = new Placeholder();
|
---|
168 | ResultsCollector islandResultsCollector1 = new ResultsCollector();
|
---|
169 | Assigner comparisonFactorInitializer = new Assigner();
|
---|
170 | Placeholder analyzer1 = new Placeholder();
|
---|
171 | ResultsCollector resultsCollector1 = new ResultsCollector();
|
---|
172 | ResultsCollector resultsCollector2 = new ResultsCollector();
|
---|
173 | UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
|
---|
174 | ConditionalBranch islandTerminatedBySelectionPressure1 = new ConditionalBranch();
|
---|
175 | OffspringSelectionGeneticAlgorithmMainOperator mainOperator = new OffspringSelectionGeneticAlgorithmMainOperator();
|
---|
176 | Placeholder islandAnalyzer2 = new Placeholder();
|
---|
177 | ResultsCollector islandResultsCollector2 = new ResultsCollector();
|
---|
178 | IntCounter islandEvaluatedSolutionsCounter = new IntCounter();
|
---|
179 | Assigner islandEvaluatedSolutionsAssigner = new Assigner();
|
---|
180 | Comparator islandSelectionPressureComparator = new Comparator();
|
---|
181 | ConditionalBranch islandTerminatedBySelectionPressure2 = new ConditionalBranch();
|
---|
182 | IntCounter terminatedIslandsCounter = new IntCounter();
|
---|
183 | IntCounter generationsCounter = new IntCounter();
|
---|
184 | IntCounter generationsSinceLastMigrationCounter = new IntCounter();
|
---|
185 | Comparator migrationComparator = new Comparator();
|
---|
186 | ConditionalBranch migrationBranch = new ConditionalBranch();
|
---|
187 | Assigner resetTerminatedIslandsAssigner = new Assigner();
|
---|
188 | Assigner resetGenerationsSinceLastMigrationAssigner = new Assigner();
|
---|
189 | IntCounter migrationsCounter = new IntCounter();
|
---|
190 | UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
|
---|
191 | Assigner reviveIslandAssigner = new Assigner();
|
---|
192 | Placeholder emigrantsSelector = new Placeholder();
|
---|
193 | Placeholder migrator = new Placeholder();
|
---|
194 | UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
|
---|
195 | Placeholder immigrationReplacer = new Placeholder();
|
---|
196 | Comparator generationsComparator = new Comparator();
|
---|
197 | Comparator terminatedIslandsComparator = new Comparator();
|
---|
198 | Comparator maxEvaluatedSolutionsComparator = new Comparator();
|
---|
199 | Placeholder comparisonFactorModifier = new Placeholder();
|
---|
200 | Placeholder analyzer2 = new Placeholder();
|
---|
201 | ResultsCollector resultsCollector3 = new ResultsCollector();
|
---|
202 | ConditionalBranch generationsTerminationCondition = new ConditionalBranch();
|
---|
203 | ConditionalBranch terminatedIslandsCondition = new ConditionalBranch();
|
---|
204 | ConditionalBranch evaluatedSolutionsTerminationCondition = new ConditionalBranch();
|
---|
205 |
|
---|
206 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Migrations", new IntValue(0)));
|
---|
207 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class IslandOffspringSelectionGeneticAlgorithm expects this to be called Generations
|
---|
208 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastMigration", new IntValue(0)));
|
---|
209 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("TerminatedIslands", new IntValue(0)));
|
---|
210 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
|
---|
211 |
|
---|
212 | islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>(ResultsParameter.Name, new ResultCollection()));
|
---|
213 | islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandEvaluatedSolutions", new IntValue(0)));
|
---|
214 | islandVariableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("TerminateSelectionPressure", new BoolValue(false)));
|
---|
215 | islandVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
|
---|
216 |
|
---|
217 | islandAnalyzer1.Name = "Island Analyzer (placeholder)";
|
---|
218 | islandAnalyzer1.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;
|
---|
219 |
|
---|
220 | islandResultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
|
---|
221 | islandResultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
|
---|
222 | islandResultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
|
---|
223 |
|
---|
224 | comparisonFactorInitializer.Name = "Initialize Comparison Factor";
|
---|
225 | comparisonFactorInitializer.LeftSideParameter.ActualName = ComparisonFactorParameter.Name;
|
---|
226 | comparisonFactorInitializer.RightSideParameter.ActualName = ComparisonFactorStartParameter.Name;
|
---|
227 |
|
---|
228 | analyzer1.Name = "Analyzer (placeholder)";
|
---|
229 | analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;
|
---|
230 |
|
---|
231 | resultsCollector1.CopyValue = new BoolValue(false);
|
---|
232 | resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Migrations"));
|
---|
233 | resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
|
---|
234 | resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Comparison Factor", null, ComparisonFactorParameter.Name));
|
---|
235 | resultsCollector1.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("IslandResults", "Result set for each island", ResultsParameter.Name));
|
---|
236 | resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
|
---|
237 |
|
---|
238 | resultsCollector2.CopyValue = new BoolValue(true);
|
---|
239 | resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
|
---|
240 | resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name;
|
---|
241 |
|
---|
242 | islandTerminatedBySelectionPressure1.Name = "Island Terminated ?";
|
---|
243 | islandTerminatedBySelectionPressure1.ConditionParameter.ActualName = "TerminateSelectionPressure";
|
---|
244 |
|
---|
245 | mainOperator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
|
---|
246 | mainOperator.CrossoverParameter.ActualName = CrossoverParameter.Name;
|
---|
247 | mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
|
---|
248 | mainOperator.ElitesParameter.ActualName = ElitesParameter.Name;
|
---|
249 | mainOperator.EvaluatedSolutionsParameter.ActualName = "IslandEvaluatedSolutions";
|
---|
250 | mainOperator.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
|
---|
251 | mainOperator.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
252 | mainOperator.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
|
---|
253 | mainOperator.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
|
---|
254 | mainOperator.MutatorParameter.ActualName = MutatorParameter.Name;
|
---|
255 | mainOperator.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
|
---|
256 | mainOperator.QualityParameter.ActualName = QualityParameter.Name;
|
---|
257 | mainOperator.RandomParameter.ActualName = RandomParameter.Name;
|
---|
258 | mainOperator.SelectionPressureParameter.ActualName = "SelectionPressure";
|
---|
259 | mainOperator.SelectorParameter.ActualName = SelectorParameter.Name;
|
---|
260 | mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
|
---|
261 |
|
---|
262 | islandAnalyzer2.Name = "Island Analyzer (placeholder)";
|
---|
263 | islandAnalyzer2.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;
|
---|
264 |
|
---|
265 | islandResultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
|
---|
266 | islandResultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
|
---|
267 | islandResultsCollector2.ResultsParameter.ActualName = "Results";
|
---|
268 |
|
---|
269 | islandEvaluatedSolutionsCounter.Name = "Update EvaluatedSolutions";
|
---|
270 | islandEvaluatedSolutionsCounter.ValueParameter.ActualName = "EvaluatedSolutions";
|
---|
271 | islandEvaluatedSolutionsCounter.Increment = null;
|
---|
272 | islandEvaluatedSolutionsCounter.IncrementParameter.ActualName = "IslandEvaluatedSolutions";
|
---|
273 |
|
---|
274 | islandEvaluatedSolutionsAssigner.Name = "Reset EvaluatedSolutions";
|
---|
275 | islandEvaluatedSolutionsAssigner.LeftSideParameter.ActualName = "IslandEvaluatedSolutions";
|
---|
276 | islandEvaluatedSolutionsAssigner.RightSideParameter.Value = new IntValue(0);
|
---|
277 |
|
---|
278 | islandSelectionPressureComparator.Name = "SelectionPressure >= MaximumSelectionPressure ?";
|
---|
279 | islandSelectionPressureComparator.LeftSideParameter.ActualName = "SelectionPressure";
|
---|
280 | islandSelectionPressureComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
281 | islandSelectionPressureComparator.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
|
---|
282 | islandSelectionPressureComparator.ResultParameter.ActualName = "TerminateSelectionPressure";
|
---|
283 |
|
---|
284 | islandTerminatedBySelectionPressure2.Name = "Island Terminated ?";
|
---|
285 | islandTerminatedBySelectionPressure2.ConditionParameter.ActualName = "TerminateSelectionPressure";
|
---|
286 |
|
---|
287 | terminatedIslandsCounter.Name = "TerminatedIslands + 1";
|
---|
288 | terminatedIslandsCounter.ValueParameter.ActualName = "TerminatedIslands";
|
---|
289 | terminatedIslandsCounter.Increment = new IntValue(1);
|
---|
290 |
|
---|
291 | generationsCounter.Name = "Generations + 1";
|
---|
292 | generationsCounter.ValueParameter.ActualName = "Generations";
|
---|
293 | generationsCounter.Increment = new IntValue(1);
|
---|
294 |
|
---|
295 | generationsSinceLastMigrationCounter.Name = "GenerationsSinceLastMigration + 1";
|
---|
296 | generationsSinceLastMigrationCounter.ValueParameter.ActualName = "GenerationsSinceLastMigration";
|
---|
297 | generationsSinceLastMigrationCounter.Increment = new IntValue(1);
|
---|
298 |
|
---|
299 | migrationComparator.Name = "GenerationsSinceLastMigration = MigrationInterval ?";
|
---|
300 | migrationComparator.LeftSideParameter.ActualName = "GenerationsSinceLastMigration";
|
---|
301 | migrationComparator.Comparison = new Comparison(ComparisonType.Equal);
|
---|
302 | migrationComparator.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
|
---|
303 | migrationComparator.ResultParameter.ActualName = "Migrate";
|
---|
304 |
|
---|
305 | migrationBranch.Name = "Migrate?";
|
---|
306 | migrationBranch.ConditionParameter.ActualName = "Migrate";
|
---|
307 |
|
---|
308 | resetTerminatedIslandsAssigner.Name = "Reset TerminatedIslands";
|
---|
309 | resetTerminatedIslandsAssigner.LeftSideParameter.ActualName = "TerminatedIslands";
|
---|
310 | resetTerminatedIslandsAssigner.RightSideParameter.Value = new IntValue(0);
|
---|
311 |
|
---|
312 | resetGenerationsSinceLastMigrationAssigner.Name = "Reset GenerationsSinceLastMigration";
|
---|
313 | resetGenerationsSinceLastMigrationAssigner.LeftSideParameter.ActualName = "GenerationsSinceLastMigration";
|
---|
314 | resetGenerationsSinceLastMigrationAssigner.RightSideParameter.Value = new IntValue(0);
|
---|
315 |
|
---|
316 | migrationsCounter.Name = "Migrations + 1";
|
---|
317 | migrationsCounter.IncrementParameter.Value = new IntValue(1);
|
---|
318 | migrationsCounter.ValueParameter.ActualName = "Migrations";
|
---|
319 |
|
---|
320 | reviveIslandAssigner.Name = "Revive Island";
|
---|
321 | reviveIslandAssigner.LeftSideParameter.ActualName = "TerminateSelectionPressure";
|
---|
322 | reviveIslandAssigner.RightSideParameter.Value = new BoolValue(false);
|
---|
323 |
|
---|
324 | emigrantsSelector.Name = "Emigrants Selector (placeholder)";
|
---|
325 | emigrantsSelector.OperatorParameter.ActualName = EmigrantsSelectorParameter.Name;
|
---|
326 |
|
---|
327 | migrator.Name = "Migrator (placeholder)";
|
---|
328 | migrator.OperatorParameter.ActualName = MigratorParameter.Name;
|
---|
329 |
|
---|
330 | immigrationReplacer.Name = "Immigration Replacer (placeholder)";
|
---|
331 | immigrationReplacer.OperatorParameter.ActualName = ImmigrationReplacerParameter.Name;
|
---|
332 |
|
---|
333 | generationsComparator.Name = "Generations >= MaximumGenerations ?";
|
---|
334 | generationsComparator.LeftSideParameter.ActualName = "Generations";
|
---|
335 | generationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
336 | generationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
337 | generationsComparator.ResultParameter.ActualName = "TerminateGenerations";
|
---|
338 |
|
---|
339 | terminatedIslandsComparator.Name = "All Islands terminated ?";
|
---|
340 | terminatedIslandsComparator.LeftSideParameter.ActualName = "TerminatedIslands";
|
---|
341 | terminatedIslandsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
342 | terminatedIslandsComparator.RightSideParameter.ActualName = NumberOfIslandsParameter.Name;
|
---|
343 | terminatedIslandsComparator.ResultParameter.ActualName = "TerminateTerminatedIslands";
|
---|
344 |
|
---|
345 | maxEvaluatedSolutionsComparator.Name = "EvaluatedSolutions >= MaximumEvaluatedSolutions ?";
|
---|
346 | maxEvaluatedSolutionsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
347 | maxEvaluatedSolutionsComparator.LeftSideParameter.ActualName = "EvaluatedSolutions";
|
---|
348 | maxEvaluatedSolutionsComparator.ResultParameter.ActualName = "TerminateEvaluatedSolutions";
|
---|
349 | maxEvaluatedSolutionsComparator.RightSideParameter.ActualName = "MaximumEvaluatedSolutions";
|
---|
350 |
|
---|
351 | comparisonFactorModifier.Name = "Update Comparison Factor (Placeholder)";
|
---|
352 | comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
|
---|
353 |
|
---|
354 | analyzer2.Name = "Analyzer (placeholder)";
|
---|
355 | analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;
|
---|
356 |
|
---|
357 | resultsCollector3.CopyValue = new BoolValue(true);
|
---|
358 | resultsCollector3.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
|
---|
359 | resultsCollector3.ResultsParameter.ActualName = ResultsParameter.Name;
|
---|
360 |
|
---|
361 | generationsTerminationCondition.Name = "Terminate (MaxGenerations) ?";
|
---|
362 | generationsTerminationCondition.ConditionParameter.ActualName = "TerminateGenerations";
|
---|
363 |
|
---|
364 | terminatedIslandsCondition.Name = "Terminate (TerminatedIslands) ?";
|
---|
365 | terminatedIslandsCondition.ConditionParameter.ActualName = "TerminateTerminatedIslands";
|
---|
366 |
|
---|
367 | evaluatedSolutionsTerminationCondition.Name = "Terminate (EvaluatedSolutions) ?";
|
---|
368 | evaluatedSolutionsTerminationCondition.ConditionParameter.ActualName = "TerminateEvaluatedSolutions";
|
---|
369 | #endregion
|
---|
370 |
|
---|
371 | #region Create operator graph
|
---|
372 | OperatorGraph.InitialOperator = variableCreator;
|
---|
373 | variableCreator.Successor = uniformSubScopesProcessor0;
|
---|
374 | uniformSubScopesProcessor0.Operator = islandVariableCreator;
|
---|
375 | uniformSubScopesProcessor0.Successor = comparisonFactorInitializer;
|
---|
376 | islandVariableCreator.Successor = islandAnalyzer1;
|
---|
377 | islandAnalyzer1.Successor = islandResultsCollector1;
|
---|
378 | islandResultsCollector1.Successor = null;
|
---|
379 | comparisonFactorInitializer.Successor = analyzer1;
|
---|
380 | analyzer1.Successor = resultsCollector1;
|
---|
381 | resultsCollector1.Successor = resultsCollector2;
|
---|
382 | resultsCollector2.Successor = uniformSubScopesProcessor1;
|
---|
383 | uniformSubScopesProcessor1.Operator = islandTerminatedBySelectionPressure1;
|
---|
384 | uniformSubScopesProcessor1.Successor = generationsCounter;
|
---|
385 | islandTerminatedBySelectionPressure1.TrueBranch = null;
|
---|
386 | islandTerminatedBySelectionPressure1.FalseBranch = mainOperator;
|
---|
387 | islandTerminatedBySelectionPressure1.Successor = null;
|
---|
388 | mainOperator.Successor = islandAnalyzer2;
|
---|
389 | islandAnalyzer2.Successor = islandResultsCollector2;
|
---|
390 | islandResultsCollector2.Successor = islandEvaluatedSolutionsCounter;
|
---|
391 | islandEvaluatedSolutionsCounter.Successor = islandEvaluatedSolutionsAssigner;
|
---|
392 | islandEvaluatedSolutionsAssigner.Successor = islandSelectionPressureComparator;
|
---|
393 | islandSelectionPressureComparator.Successor = islandTerminatedBySelectionPressure2;
|
---|
394 | islandTerminatedBySelectionPressure2.TrueBranch = terminatedIslandsCounter;
|
---|
395 | islandTerminatedBySelectionPressure2.FalseBranch = null;
|
---|
396 | islandTerminatedBySelectionPressure2.Successor = null;
|
---|
397 | generationsCounter.Successor = generationsSinceLastMigrationCounter;
|
---|
398 | generationsSinceLastMigrationCounter.Successor = migrationComparator;
|
---|
399 | migrationComparator.Successor = migrationBranch;
|
---|
400 | migrationBranch.TrueBranch = resetTerminatedIslandsAssigner;
|
---|
401 | migrationBranch.FalseBranch = null;
|
---|
402 | migrationBranch.Successor = generationsComparator;
|
---|
403 | resetTerminatedIslandsAssigner.Successor = resetGenerationsSinceLastMigrationAssigner;
|
---|
404 | resetGenerationsSinceLastMigrationAssigner.Successor = migrationsCounter;
|
---|
405 | migrationsCounter.Successor = uniformSubScopesProcessor2;
|
---|
406 | uniformSubScopesProcessor2.Operator = reviveIslandAssigner;
|
---|
407 | uniformSubScopesProcessor2.Successor = migrator;
|
---|
408 | reviveIslandAssigner.Successor = emigrantsSelector;
|
---|
409 | emigrantsSelector.Successor = null;
|
---|
410 | migrator.Successor = uniformSubScopesProcessor3;
|
---|
411 | uniformSubScopesProcessor3.Operator = immigrationReplacer;
|
---|
412 | uniformSubScopesProcessor3.Successor = null;
|
---|
413 | immigrationReplacer.Successor = null;
|
---|
414 | generationsComparator.Successor = terminatedIslandsComparator;
|
---|
415 | terminatedIslandsComparator.Successor = maxEvaluatedSolutionsComparator;
|
---|
416 | maxEvaluatedSolutionsComparator.Successor = comparisonFactorModifier;
|
---|
417 | comparisonFactorModifier.Successor = analyzer2;
|
---|
418 | analyzer2.Successor = resultsCollector3;
|
---|
419 | resultsCollector3.Successor = generationsTerminationCondition;
|
---|
420 | generationsTerminationCondition.TrueBranch = null;
|
---|
421 | generationsTerminationCondition.FalseBranch = terminatedIslandsCondition;
|
---|
422 | generationsTerminationCondition.Successor = null;
|
---|
423 | terminatedIslandsCondition.TrueBranch = null;
|
---|
424 | terminatedIslandsCondition.FalseBranch = evaluatedSolutionsTerminationCondition;
|
---|
425 | terminatedIslandsCondition.Successor = null;
|
---|
426 | evaluatedSolutionsTerminationCondition.TrueBranch = null;
|
---|
427 | evaluatedSolutionsTerminationCondition.FalseBranch = uniformSubScopesProcessor1;
|
---|
428 | evaluatedSolutionsTerminationCondition.Successor = null;
|
---|
429 | #endregion
|
---|
430 | }
|
---|
431 |
|
---|
432 | public override IOperation Apply() {
|
---|
433 | if (CrossoverParameter.ActualValue == null)
|
---|
434 | return null;
|
---|
435 | return base.Apply();
|
---|
436 | }
|
---|
437 | }
|
---|
438 | }
|
---|