Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithmMainLoop.cs @ 10155

Last change on this file since 10155 was 10155, checked in by mkommend, 10 years ago

#1997: Added possibility to reevaluate immigrants to the IslandGA and IslandOSGA.

File size: 24.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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;
30using HeuristicLab.Selection;
31
32namespace HeuristicLab.Algorithms.GeneticAlgorithm {
33  /// <summary>
34  /// An island genetic algorithm main loop operator.
35  /// </summary>
36  [Item("IslandGeneticAlgorithmMainLoop", "An island genetic algorithm main loop operator.")]
37  [StorableClass]
38  public sealed class IslandGeneticAlgorithmMainLoop : AlgorithmOperator {
39    #region Parameter Properties
40    public ValueLookupParameter<IRandom> RandomParameter {
41      get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
42    }
43    public ValueLookupParameter<BoolValue> MaximizationParameter {
44      get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
45    }
46    public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
47      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
48    }
49    public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
50      get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
51    }
52    public ValueLookupParameter<IntValue> NumberOfIslandsParameter {
53      get { return (ValueLookupParameter<IntValue>)Parameters["NumberOfIslands"]; }
54    }
55    public ValueLookupParameter<IntValue> MigrationIntervalParameter {
56      get { return (ValueLookupParameter<IntValue>)Parameters["MigrationInterval"]; }
57    }
58    public ValueLookupParameter<PercentValue> MigrationRateParameter {
59      get { return (ValueLookupParameter<PercentValue>)Parameters["MigrationRate"]; }
60    }
61    public ValueLookupParameter<IOperator> MigratorParameter {
62      get { return (ValueLookupParameter<IOperator>)Parameters["Migrator"]; }
63    }
64    public ValueLookupParameter<IOperator> EmigrantsSelectorParameter {
65      get { return (ValueLookupParameter<IOperator>)Parameters["EmigrantsSelector"]; }
66    }
67    public ValueLookupParameter<IOperator> ImmigrationReplacerParameter {
68      get { return (ValueLookupParameter<IOperator>)Parameters["ImmigrationReplacer"]; }
69    }
70    public ValueLookupParameter<IntValue> PopulationSizeParameter {
71      get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; }
72    }
73    public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
74      get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
75    }
76    public ValueLookupParameter<IOperator> SelectorParameter {
77      get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
78    }
79    public ValueLookupParameter<IOperator> CrossoverParameter {
80      get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
81    }
82    public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
83      get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
84    }
85    public ValueLookupParameter<IOperator> MutatorParameter {
86      get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
87    }
88    public ValueLookupParameter<IOperator> EvaluatorParameter {
89      get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
90    }
91    public ValueLookupParameter<IntValue> ElitesParameter {
92      get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
93    }
94    public IValueLookupParameter<BoolValue> ReevaluateElitesParameter {
95      get { return (IValueLookupParameter<BoolValue>)Parameters["ReevaluateElites"]; }
96    }
97    public ValueLookupParameter<ResultCollection> ResultsParameter {
98      get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
99    }
100    public ValueLookupParameter<IOperator> AnalyzerParameter {
101      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
102    }
103    public ValueLookupParameter<IOperator> IslandAnalyzerParameter {
104      get { return (ValueLookupParameter<IOperator>)Parameters["IslandAnalyzer"]; }
105    }
106    public LookupParameter<IntValue> EvaluatedSolutionsParameter {
107      get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
108    }
109    public LookupParameter<IntValue> IslandGenerations {
110      get { return (LookupParameter<IntValue>)Parameters["IslandGenerations"]; }
111    }
112    public LookupParameter<IntValue> IslandEvaluatedSolutions {
113      get { return (LookupParameter<IntValue>)Parameters["IslandEvaluatedSolutions"]; }
114    }
115    public ValueLookupParameter<BoolValue> Migrate {
116      get { return (ValueLookupParameter<BoolValue>)Parameters["Migrate"]; }
117    }
118
119    public ValueLookupParameter<BoolValue> ReevaluateImmigrants {
120      get { return (ValueLookupParameter<BoolValue>)Parameters["ReevaluateImmigrants"]; }
121    }
122    #endregion
123
124    [StorableConstructor]
125    private IslandGeneticAlgorithmMainLoop(bool deserializing) : base(deserializing) { }
126    private IslandGeneticAlgorithmMainLoop(IslandGeneticAlgorithmMainLoop original, Cloner cloner)
127      : base(original, cloner) {
128    }
129    public override IDeepCloneable Clone(Cloner cloner) {
130      return new IslandGeneticAlgorithmMainLoop(this, cloner);
131    }
132    public IslandGeneticAlgorithmMainLoop()
133      : base() {
134      #region Create parameters
135      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
136      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
137      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
138      Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
139      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfIslands", "The number of islands."));
140      Parameters.Add(new ValueLookupParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases."));
141      Parameters.Add(new ValueLookupParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands."));
142      Parameters.Add(new ValueLookupParameter<IOperator>("Migrator", "The migration strategy."));
143      Parameters.Add(new ValueLookupParameter<IOperator>("EmigrantsSelector", "Selects the individuals that will be migrated."));
144      Parameters.Add(new ValueLookupParameter<IOperator>("ImmigrationReplacer", "Replaces some of the original population with the immigrants."));
145      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population of solutions."));
146      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations that the algorithm should process."));
147      Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
148      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
149      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
150      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
151      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
152      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
153      Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
154      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results."));
155      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to the analyze the islands."));
156      Parameters.Add(new ValueLookupParameter<IOperator>("IslandAnalyzer", "The operator used to analyze each island."));
157      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times a solution has been evaluated."));
158      Parameters.Add(new LookupParameter<IntValue>("IslandGenerations", "The number of generations calculated on one island."));
159      Parameters.Add(new LookupParameter<IntValue>("IslandEvaluatedSolutions", "The number of times a solution has been evaluated on one island."));
160      Parameters.Add(new ValueLookupParameter<BoolValue>("Migrate", "Migrate the island?"));
161      Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateImmigrants", "Flag which indicates if inviduals should be reevaluated before they are immigrated."));
162      #endregion
163
164      #region Create operators
165      VariableCreator variableCreator = new VariableCreator();
166      UniformSubScopesProcessor uniformSubScopesProcessor0 = new UniformSubScopesProcessor();
167      VariableCreator islandVariableCreator = new VariableCreator();
168      Placeholder islandAnalyzer1 = new Placeholder();
169      LocalRandomCreator localRandomCreator = new LocalRandomCreator();
170      Placeholder analyzer1 = new Placeholder();
171      ResultsCollector resultsCollector1 = new ResultsCollector();
172      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
173      Assigner generationsAssigner = new Assigner();
174      Assigner evaluatedSolutionsAssigner = new Assigner();
175      Placeholder selector = new Placeholder();
176      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
177      ChildrenCreator childrenCreator = new ChildrenCreator();
178      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
179      Placeholder crossover = new Placeholder();
180      StochasticBranch stochasticBranch = new StochasticBranch();
181      Placeholder mutator = new Placeholder();
182      SubScopesRemover subScopesRemover = new SubScopesRemover();
183      UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
184      Placeholder evaluator = new Placeholder();
185      SubScopesCounter subScopesCounter = new SubScopesCounter();
186      SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
187      BestSelector bestSelector = new BestSelector();
188      RightReducer rightReducer = new RightReducer();
189      MergingReducer mergingReducer = new MergingReducer();
190      IntCounter islandGenerationsCounter = new IntCounter();
191      Comparator checkIslandGenerationsReachedMaximum = new Comparator();
192      ConditionalBranch checkContinueEvolution = new ConditionalBranch();
193      DataReducer generationsReducer = new DataReducer();
194      DataReducer evaluatedSolutionsReducer = new DataReducer();
195      Placeholder islandAnalyzer2 = new Placeholder();
196      UniformSubScopesProcessor uniformSubScopesProcessor5 = new UniformSubScopesProcessor();
197      Placeholder emigrantsSelector = new Placeholder();
198      IntCounter migrationsCounter = new IntCounter();
199      Placeholder migrator = new Placeholder();
200      ConditionalBranch reevaluateImmigrantsBranch = new ConditionalBranch();
201      Assigner evaluatedSolutionsAssigner2 = new Assigner();
202      UniformSubScopesProcessor uniformSubScopesProcessor6 = new UniformSubScopesProcessor();
203      SubScopesProcessor subScopesProcessor3 = new SubScopesProcessor();
204      DataReducer evaluatedSolutionsReducer2 = new DataReducer();
205      UniformSubScopesProcessor uniformSubScopesProcessor7 = new UniformSubScopesProcessor();
206      Placeholder immigrationReplacer = new Placeholder();
207      Comparator generationsComparator = new Comparator();
208      Placeholder analyzer2 = new Placeholder();
209      ConditionalBranch generationsTerminationCondition = new ConditionalBranch();
210      ConditionalBranch reevaluateElitesBranch = new ConditionalBranch();
211
212      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Migrations", new IntValue(0)));
213      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastMigration", new IntValue(0)));
214      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class IslandGeneticAlgorithm expects this to be called Generations
215
216      islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("Results", new ResultCollection()));
217      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandGenerations", new IntValue(0)));
218      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandEvaluatedSolutions", new IntValue(0)));
219
220      islandAnalyzer1.Name = "Island Analyzer (placeholder)";
221      islandAnalyzer1.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;
222
223      analyzer1.Name = "Analyzer (placeholder)";
224      analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;
225
226      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Migrations"));
227      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
228      resultsCollector1.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("IslandResults", "Result set for each island", "Results"));
229      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
230
231      uniformSubScopesProcessor1.Parallel.Value = true;
232
233      generationsAssigner.Name = "Initialize Island Generations";
234      generationsAssigner.LeftSideParameter.ActualName = IslandGenerations.Name;
235      generationsAssigner.RightSideParameter.Value = new IntValue(0);
236
237      evaluatedSolutionsAssigner.Name = "Initialize Island evaluated solutions";
238      evaluatedSolutionsAssigner.LeftSideParameter.ActualName = IslandEvaluatedSolutions.Name;
239      evaluatedSolutionsAssigner.RightSideParameter.Value = new IntValue(0);
240
241      selector.Name = "Selector (placeholder)";
242      selector.OperatorParameter.ActualName = SelectorParameter.Name;
243
244      childrenCreator.ParentsPerChild = new IntValue(2);
245
246      crossover.Name = "Crossover (placeholder)";
247      crossover.OperatorParameter.ActualName = CrossoverParameter.Name;
248
249      stochasticBranch.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
250      //set it to the random number generator of the island
251      stochasticBranch.RandomParameter.ActualName = "LocalRandom";
252
253      mutator.Name = "Mutator (placeholder)";
254      mutator.OperatorParameter.ActualName = MutatorParameter.Name;
255
256      subScopesRemover.RemoveAllSubScopes = true;
257
258      evaluator.Name = "Evaluator (placeholder)";
259      evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name;
260
261      subScopesCounter.Name = "Increment EvaluatedSolutions";
262      subScopesCounter.ValueParameter.ActualName = IslandEvaluatedSolutions.Name;
263
264      bestSelector.CopySelected = new BoolValue(false);
265      bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
266      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = ElitesParameter.Name;
267      bestSelector.QualityParameter.ActualName = QualityParameter.Name;
268
269      islandGenerationsCounter.Name = "Increment island generatrions";
270      islandGenerationsCounter.ValueParameter.ActualName = IslandGenerations.Name;
271      islandGenerationsCounter.Increment = new IntValue(1);
272
273      checkIslandGenerationsReachedMaximum.LeftSideParameter.ActualName = IslandGenerations.Name;
274      checkIslandGenerationsReachedMaximum.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
275      checkIslandGenerationsReachedMaximum.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
276      checkIslandGenerationsReachedMaximum.ResultParameter.ActualName = Migrate.Name;
277
278      checkContinueEvolution.Name = "Migrate?";
279      checkContinueEvolution.ConditionParameter.ActualName = Migrate.Name;
280      checkContinueEvolution.FalseBranch = selector;
281
282      islandAnalyzer2.Name = "Island Analyzer (placeholder)";
283      islandAnalyzer2.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;
284
285      generationsReducer.Name = "Increment Generations";
286      generationsReducer.ParameterToReduce.ActualName = islandGenerationsCounter.ValueParameter.ActualName;
287      generationsReducer.TargetParameter.ActualName = "Generations";
288      generationsReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Min);
289      generationsReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);
290
291      evaluatedSolutionsReducer.Name = "Increment Evaluated Solutions";
292      evaluatedSolutionsReducer.ParameterToReduce.ActualName = IslandEvaluatedSolutions.Name;
293      evaluatedSolutionsReducer.TargetParameter.ActualName = EvaluatedSolutionsParameter.Name;
294      evaluatedSolutionsReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
295      evaluatedSolutionsReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);
296
297      emigrantsSelector.Name = "Emigrants Selector (placeholder)";
298      emigrantsSelector.OperatorParameter.ActualName = EmigrantsSelectorParameter.Name;
299
300      migrationsCounter.Name = "Increment number of Migrations";
301      migrationsCounter.ValueParameter.ActualName = "Migrations";
302      migrationsCounter.Increment = new IntValue(1);
303
304      migrator.Name = "Migrator (placeholder)";
305      migrator.OperatorParameter.ActualName = MigratorParameter.Name;
306
307      reevaluateImmigrantsBranch.ConditionParameter.ActualName = "ReevaluateImmigrants";
308      reevaluateImmigrantsBranch.Name = "Reevaluate Immigrants ?";
309
310      evaluatedSolutionsAssigner2.Name = "Reset Island evaluated solutions";
311      evaluatedSolutionsAssigner2.LeftSideParameter.ActualName = IslandEvaluatedSolutions.Name;
312      evaluatedSolutionsAssigner2.RightSideParameter.Value = new IntValue(0);
313
314      evaluatedSolutionsReducer2.Name = "Increment Evaluated Solutions";
315      evaluatedSolutionsReducer2.ParameterToReduce.ActualName = IslandEvaluatedSolutions.Name;
316      evaluatedSolutionsReducer2.TargetParameter.ActualName = EvaluatedSolutionsParameter.Name;
317      evaluatedSolutionsReducer2.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
318      evaluatedSolutionsReducer2.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);
319
320      immigrationReplacer.Name = "Immigration Replacer (placeholder)";
321      immigrationReplacer.OperatorParameter.ActualName = ImmigrationReplacerParameter.Name;
322
323      generationsComparator.Name = "Generations >= MaximumGenerations ?";
324      generationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
325      generationsComparator.LeftSideParameter.ActualName = "Generations";
326      generationsComparator.ResultParameter.ActualName = "TerminateGenerations";
327      generationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
328
329      analyzer2.Name = "Analyzer (placeholder)";
330      analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;
331
332      generationsTerminationCondition.Name = "Terminate?";
333      generationsTerminationCondition.ConditionParameter.ActualName = "TerminateGenerations";
334
335      reevaluateElitesBranch.ConditionParameter.ActualName = "ReevaluateElites";
336      reevaluateElitesBranch.Name = "Reevaluate elites ?";
337      #endregion
338
339      #region Create operator graph
340      OperatorGraph.InitialOperator = variableCreator;
341      variableCreator.Successor = uniformSubScopesProcessor0;
342      uniformSubScopesProcessor0.Operator = islandVariableCreator;
343      uniformSubScopesProcessor0.Successor = analyzer1;
344      islandVariableCreator.Successor = islandAnalyzer1;
345      // BackwardsCompatibility3.3
346      //the local randoms are created by the island GA itself and are only here to ensure same algorithm results
347      #region Backwards compatible code, remove local random creator with 3.4 and rewire the operator graph
348      islandAnalyzer1.Successor = localRandomCreator;
349      localRandomCreator.Successor = null;
350      #endregion
351      analyzer1.Successor = resultsCollector1;
352      resultsCollector1.Successor = uniformSubScopesProcessor1;
353      uniformSubScopesProcessor1.Operator = generationsAssigner;
354      uniformSubScopesProcessor1.Successor = generationsReducer;
355      generationsReducer.Successor = evaluatedSolutionsReducer;
356      evaluatedSolutionsReducer.Successor = migrationsCounter;
357      migrationsCounter.Successor = uniformSubScopesProcessor5;
358      generationsAssigner.Successor = evaluatedSolutionsAssigner;
359      evaluatedSolutionsAssigner.Successor = selector;
360      selector.Successor = subScopesProcessor1;
361      subScopesProcessor1.Operators.Add(new EmptyOperator());
362      subScopesProcessor1.Operators.Add(childrenCreator);
363      subScopesProcessor1.Successor = subScopesProcessor2;
364      childrenCreator.Successor = uniformSubScopesProcessor2;
365      uniformSubScopesProcessor2.Operator = crossover;
366      uniformSubScopesProcessor2.Successor = uniformSubScopesProcessor3;
367      crossover.Successor = stochasticBranch;
368      stochasticBranch.FirstBranch = mutator;
369      stochasticBranch.SecondBranch = null;
370      stochasticBranch.Successor = subScopesRemover;
371      mutator.Successor = null;
372      subScopesRemover.Successor = null;
373      uniformSubScopesProcessor3.Operator = evaluator;
374      uniformSubScopesProcessor3.Successor = subScopesCounter;
375      evaluator.Successor = null;
376      subScopesCounter.Successor = null;
377      subScopesProcessor2.Operators.Add(bestSelector);
378      subScopesProcessor2.Operators.Add(new EmptyOperator());
379      subScopesProcessor2.Successor = mergingReducer;
380      mergingReducer.Successor = islandAnalyzer2;
381      bestSelector.Successor = rightReducer;
382      rightReducer.Successor = reevaluateElitesBranch;
383      reevaluateElitesBranch.TrueBranch = uniformSubScopesProcessor3;
384      reevaluateElitesBranch.FalseBranch = null;
385      reevaluateElitesBranch.Successor = null;
386      islandAnalyzer2.Successor = islandGenerationsCounter;
387      islandGenerationsCounter.Successor = checkIslandGenerationsReachedMaximum;
388      checkIslandGenerationsReachedMaximum.Successor = checkContinueEvolution;
389      uniformSubScopesProcessor5.Operator = emigrantsSelector;
390      emigrantsSelector.Successor = null;
391      uniformSubScopesProcessor5.Successor = migrator;
392      migrator.Successor = reevaluateImmigrantsBranch;
393      reevaluateImmigrantsBranch.FalseBranch = null;
394      reevaluateImmigrantsBranch.Successor = uniformSubScopesProcessor7;
395      reevaluateImmigrantsBranch.TrueBranch = uniformSubScopesProcessor6;
396      uniformSubScopesProcessor6.Successor = evaluatedSolutionsReducer2;
397      uniformSubScopesProcessor6.Operator = evaluatedSolutionsAssigner2;
398      evaluatedSolutionsReducer2.Successor = null;
399      evaluatedSolutionsAssigner2.Successor = subScopesProcessor3;
400      subScopesProcessor3.Operators.Add(new EmptyOperator());
401      subScopesProcessor3.Operators.Add(uniformSubScopesProcessor3);
402      uniformSubScopesProcessor7.Operator = immigrationReplacer;
403      uniformSubScopesProcessor7.Successor = generationsComparator;
404      generationsComparator.Successor = analyzer2;
405      analyzer2.Successor = generationsTerminationCondition;
406      generationsTerminationCondition.TrueBranch = null;
407      generationsTerminationCondition.FalseBranch = uniformSubScopesProcessor1;
408      generationsTerminationCondition.Successor = null;
409      #endregion
410    }
411
412    [StorableHook(HookType.AfterDeserialization)]
413    private void AfterDeserialization() {
414      // BackwardsCompatibility3.3
415      #region Backwards compatible code, remove with 3.4
416      if (!Parameters.ContainsKey("ReevaluateElites")) {
417        Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
418      }
419      #endregion
420    }
421
422    public override IOperation Apply() {
423      if (CrossoverParameter.ActualValue == null)
424        return null;
425      return base.Apply();
426    }
427  }
428}
Note: See TracBrowser for help on using the repository browser.