Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ParameterBinding/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithmMainLoop.cs @ 7347

Last change on this file since 7347 was 4722, checked in by swagner, 14 years ago

Merged cloning refactoring branch back into trunk (#922)

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