Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASAMainLoop.cs @ 3690

Last change on this file since 3690 was 3673, checked in by abeham, 15 years ago

#999

  • updated Island OSGA, SASEGASA
  • minor changes to Island GA and OSGA
File size: 28.3 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 System;
23using System.Collections.Generic;
24using System.Linq;
25using HeuristicLab.Analysis;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Data;
29using HeuristicLab.Operators;
30using HeuristicLab.Optimization;
31using HeuristicLab.Optimization.Operators;
32using HeuristicLab.Parameters;
33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
34using HeuristicLab.PluginInfrastructure;
35using HeuristicLab.Selection;
36
37namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm {
38  /// <summary>
39  /// A SASEGASA main loop operator.
40  /// </summary>
41  [Item("SASEGASAMainLoop", "A SASEGASA main loop operator.")]
42  [StorableClass]
43  public sealed class SASEGASAMainLoop : AlgorithmOperator {
44    #region Parameter Properties
45    public ValueLookupParameter<IRandom> RandomParameter {
46      get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
47    }
48    public ValueLookupParameter<IntValue> NumberOfVillagesParameter {
49      get { return (ValueLookupParameter<IntValue>)Parameters["NumberOfVillages"]; }
50    }
51    public ValueLookupParameter<IntValue> MigrationIntervalParameter {
52      get { return (ValueLookupParameter<IntValue>)Parameters["MigrationInterval"]; }
53    }
54    public ValueLookupParameter<BoolValue> MaximizationParameter {
55      get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
56    }
57    public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
58      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
59    }
60    public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
61      get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
62    }
63    public ValueLookupParameter<IOperator> SelectorParameter {
64      get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
65    }
66    public ValueLookupParameter<IOperator> CrossoverParameter {
67      get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
68    }
69    public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
70      get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
71    }
72    public ValueLookupParameter<IOperator> MutatorParameter {
73      get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
74    }
75    public ValueLookupParameter<IOperator> EvaluatorParameter {
76      get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
77    }
78    public ValueLookupParameter<IntValue> ElitesParameter {
79      get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
80    }
81    public ValueLookupParameter<ResultCollection> ResultsParameter {
82      get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
83    }
84    public ValueLookupParameter<IOperator> AnalyzerParameter {
85      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
86    }
87    public ValueLookupParameter<IOperator> VillageAnalyzerParameter {
88      get { return (ValueLookupParameter<IOperator>)Parameters["VillageAnalyzer"]; }
89    }
90    public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
91      get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
92    }
93    public LookupParameter<DoubleValue> ComparisonFactorParameter {
94      get { return (LookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
95    }
96    public ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
97      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorLowerBound"]; }
98    }
99    public ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
100      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorUpperBound"]; }
101    }
102    public ValueLookupParameter<IOperator> ComparisonFactorModifierParameter {
103      get { return (ValueLookupParameter<IOperator>)Parameters["ComparisonFactorModifier"]; }
104    }
105    public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
106      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
107    }
108    public ValueLookupParameter<DoubleValue> FinalMaximumSelectionPressureParameter {
109      get { return (ValueLookupParameter<DoubleValue>)Parameters["FinalMaximumSelectionPressure"]; }
110    }
111    public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
112      get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
113    }
114    public ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
115      get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
116    }
117    #endregion
118
119    [StorableConstructor]
120    private SASEGASAMainLoop(bool deserializing) : base() { }
121    public SASEGASAMainLoop()
122      : base() {
123      #region Create parameters
124      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
125      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
126      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
127      Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
128      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfVillages", "The initial number of villages."));
129      Parameters.Add(new ValueLookupParameter<IntValue>("MigrationInterval", "The fixed period after which migration occurs."));
130      Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
131      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
132      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
133      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
134      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
135      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
136      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results."));
137      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to the analyze the villages."));
138      Parameters.Add(new ValueLookupParameter<IOperator>("VillageAnalyzer", "The operator used to analyze each village."));
139      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
140      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]."));
141      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start)."));
142      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end)."));
143      Parameters.Add(new ValueLookupParameter<IOperator>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));
144      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
145      Parameters.Add(new ValueLookupParameter<DoubleValue>("FinalMaximumSelectionPressure", "The maximum selection pressure used when there is only one village left."));
146      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum genreation that terminates the algorithm."));
147      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."));
148      #endregion
149
150      #region Create operators
151      VariableCreator variableCreator = new VariableCreator();
152      Assigner maxSelPressAssigner = new Assigner();
153      Assigner villageCountAssigner = new Assigner();
154      Assigner comparisonFactorInitializer = new Assigner();
155      UniformSubScopesProcessor uniformSubScopesProcessor0 = new UniformSubScopesProcessor();
156      VariableCreator villageVariableCreator = new VariableCreator();
157      Placeholder villageAnalyzer1 = new Placeholder();
158      ResultsCollector villageResultsCollector1 = new ResultsCollector();
159      Placeholder analyzer1 = new Placeholder();
160      ResultsCollector resultsCollector1 = new ResultsCollector();
161      ResultsCollector resultsCollector2 = new ResultsCollector();
162      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
163      ConditionalBranch villageTerminatedBySelectionPressure1 = new ConditionalBranch();
164      OffspringSelectionGeneticAlgorithmMainOperator mainOperator = new OffspringSelectionGeneticAlgorithmMainOperator();
165      Placeholder villageAnalyzer2 = new Placeholder();
166      ResultsCollector villageResultsCollector2 = new ResultsCollector();
167      IntCounter evaluatedSolutionsCounter = new IntCounter();
168      Assigner villageEvaluatedSolutionsAssigner = new Assigner();
169      Comparator villageSelectionPressureComparator = new Comparator();
170      ConditionalBranch villageTerminatedBySelectionPressure2 = new ConditionalBranch();
171      IntCounter terminatedVillagesCounter = new IntCounter();
172      IntCounter generationsCounter = new IntCounter();
173      IntCounter generationsSinceLastReunificationCounter = new IntCounter();
174      Comparator reunificationComparator1 = new Comparator();
175      ConditionalBranch reunificationConditionalBranch1 = new ConditionalBranch();
176      Comparator reunificationComparator2 = new Comparator();
177      ConditionalBranch reunificationConditionalBranch2 = new ConditionalBranch();
178      Comparator reunificationComparator3 = new Comparator();
179      ConditionalBranch reunificationConditionalBranch3 = new ConditionalBranch();
180      Assigner resetTerminatedVillagesAssigner = new Assigner();
181      Assigner resetGenerationsSinceLastReunificationAssigner = new Assigner();
182      SASEGASAReunificator reunificator = new SASEGASAReunificator();
183      IntCounter reunificationCounter = new IntCounter();
184      Placeholder comparisonFactorModifier = new Placeholder();
185      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
186      Assigner villageReviver = new Assigner();
187      Comparator villageCountComparator = new Comparator();
188      ConditionalBranch villageCountConditionalBranch = new ConditionalBranch();
189      Assigner finalMaxSelPressAssigner = new Assigner();
190      Comparator maximumGenerationsComparator = new Comparator();
191      Placeholder analyzer2 = new Placeholder();
192      ResultsCollector resultsCollector3 = new ResultsCollector();
193      ConditionalBranch terminationCondition = new ConditionalBranch();
194      ConditionalBranch maximumGenerationsTerminationCondition = new ConditionalBranch();
195
196      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Reunifications", new IntValue(0)));
197      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
198      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastReunification", new IntValue(0)));
199      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
200      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("TerminatedVillages", new IntValue(0)));
201
202      villageCountAssigner.LeftSideParameter.ActualName = "VillageCount";
203      villageCountAssigner.RightSideParameter.ActualName = NumberOfVillagesParameter.Name;
204
205      maxSelPressAssigner.LeftSideParameter.ActualName = "CurrentMaximumSelectionPressure";
206      maxSelPressAssigner.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
207
208      comparisonFactorInitializer.LeftSideParameter.ActualName = "ComparisonFactor";
209      comparisonFactorInitializer.RightSideParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
210
211      villageVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("Results", new ResultCollection()));
212      villageVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("VillageEvaluatedSolutions", new IntValue(0)));
213      villageVariableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("TerminateSelectionPressure", new BoolValue(false)));
214      villageVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
215      villageVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
216
217      villageAnalyzer1.Name = "Village Analyzer (placeholder)";
218      villageAnalyzer1.OperatorParameter.ActualName = VillageAnalyzerParameter.Name;
219
220      villageResultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
221      villageResultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
222      villageResultsCollector1.ResultsParameter.ActualName = "Results";
223
224      analyzer1.Name = "Analyzer (placeholder)";
225      analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;
226
227      resultsCollector1.CopyValue = new BoolValue(false);
228      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
229      resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("ComparisonFactor", null, "ComparisonFactor"));
230      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Terminated Villages", null, "TerminatedVillages"));
231      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Total Active Villages", null, "VillageCount"));
232      resultsCollector1.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("VillageResults", "Result set for each village", "Results"));
233      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
234
235      resultsCollector2.CopyValue = new BoolValue(true);
236      resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
237      resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name;
238
239      villageTerminatedBySelectionPressure1.Name = "Village Terminated ?";
240      villageTerminatedBySelectionPressure1.ConditionParameter.ActualName = "TerminateSelectionPressure";
241
242      mainOperator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
243      mainOperator.CrossoverParameter.ActualName = CrossoverParameter.Name;
244      mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
245      mainOperator.ElitesParameter.ActualName = ElitesParameter.Name;
246      mainOperator.EvaluatedSolutionsParameter.ActualName = "VillageEvaluatedSolutions";
247      mainOperator.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
248      mainOperator.MaximizationParameter.ActualName = MaximizationParameter.Name;
249      mainOperator.MaximumSelectionPressureParameter.ActualName = "CurrentMaximumSelectionPressure";
250      mainOperator.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
251      mainOperator.MutatorParameter.ActualName = MutatorParameter.Name;
252      mainOperator.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
253      mainOperator.QualityParameter.ActualName = QualityParameter.Name;
254      mainOperator.RandomParameter.ActualName = RandomParameter.Name;
255      mainOperator.SelectionPressureParameter.ActualName = "SelectionPressure";
256      mainOperator.SelectorParameter.ActualName = SelectorParameter.Name;
257      mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
258
259      villageAnalyzer2.Name = "Village Analyzer (placeholder)";
260      villageAnalyzer2.OperatorParameter.ActualName = VillageAnalyzerParameter.Name;
261
262      villageResultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
263      villageResultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
264      villageResultsCollector2.ResultsParameter.ActualName = "Results";
265
266      evaluatedSolutionsCounter.Name = "Update EvaluatedSolutions";
267      evaluatedSolutionsCounter.ValueParameter.ActualName = "EvaluatedSolutions";
268      evaluatedSolutionsCounter.Increment = null;
269      evaluatedSolutionsCounter.IncrementParameter.ActualName = "VillageEvaluatedSolutions";
270
271      villageEvaluatedSolutionsAssigner.Name = "Reset EvaluatedSolutions";
272      villageEvaluatedSolutionsAssigner.LeftSideParameter.ActualName = "VillageEvaluatedSolutions";
273      villageEvaluatedSolutionsAssigner.RightSideParameter.Value = new IntValue(0);
274
275      villageSelectionPressureComparator.Name = "SelectionPressure >= MaximumSelectionPressure ?";
276      villageSelectionPressureComparator.LeftSideParameter.ActualName = "SelectionPressure";
277      villageSelectionPressureComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
278      villageSelectionPressureComparator.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
279      villageSelectionPressureComparator.ResultParameter.ActualName = "TerminateSelectionPressure";
280
281      villageTerminatedBySelectionPressure2.Name = "Village Terminated ?";
282      villageTerminatedBySelectionPressure2.ConditionParameter.ActualName = "TerminateSelectionPressure";
283
284      terminatedVillagesCounter.Name = "TerminatedVillages + 1";
285      terminatedVillagesCounter.ValueParameter.ActualName = "TerminatedVillages";
286      terminatedVillagesCounter.Increment = new IntValue(1);
287
288      generationsCounter.Name = "Generations + 1";
289      generationsCounter.ValueParameter.ActualName = "Generations";
290      generationsCounter.Increment = new IntValue(1);
291
292      generationsSinceLastReunificationCounter.Name = "GenerationsSinceLastReunification + 1";
293      generationsSinceLastReunificationCounter.ValueParameter.ActualName = "GenerationsSinceLastReunification";
294      generationsSinceLastReunificationCounter.Increment = new IntValue(1);
295
296      reunificationComparator1.Name = "TerminatedVillages = VillageCount ?";
297      reunificationComparator1.LeftSideParameter.ActualName = "TerminatedVillages";
298      reunificationComparator1.Comparison = new Comparison(ComparisonType.Equal);
299      reunificationComparator1.RightSideParameter.ActualName = "VillageCount";
300      reunificationComparator1.ResultParameter.ActualName = "Reunificate";
301
302      reunificationConditionalBranch1.Name = "Reunificate ?";
303      reunificationConditionalBranch1.ConditionParameter.ActualName = "Reunificate";
304
305      reunificationComparator2.Name = "GenerationsSinceLastReunification = MigrationInterval ?";
306      reunificationComparator2.LeftSideParameter.ActualName = "GenerationsSinceLastReunification";
307      reunificationComparator2.Comparison = new Comparison(ComparisonType.Equal);
308      reunificationComparator2.RightSideParameter.ActualName = "MigrationInterval";
309      reunificationComparator2.ResultParameter.ActualName = "Reunificate";
310
311      reunificationConditionalBranch2.Name = "Reunificate ?";
312      reunificationConditionalBranch2.ConditionParameter.ActualName = "Reunificate";
313
314      // if there's just one village left and we're getting to this point SASEGASA terminates
315      reunificationComparator3.Name = "VillageCount <= 1 ?";
316      reunificationComparator3.LeftSideParameter.ActualName = "VillageCount";
317      reunificationComparator3.RightSideParameter.Value = new IntValue(1);
318      reunificationComparator3.Comparison.Value = ComparisonType.LessOrEqual;
319      reunificationComparator3.ResultParameter.ActualName = "TerminateSASEGASA";
320
321      reunificationConditionalBranch3.Name = "Skip reunification?";
322      reunificationConditionalBranch3.ConditionParameter.ActualName = "TerminateSASEGASA";
323
324      resetTerminatedVillagesAssigner.Name = "Reset TerminatedVillages";
325      resetTerminatedVillagesAssigner.LeftSideParameter.ActualName = "TerminatedVillages";
326      resetTerminatedVillagesAssigner.RightSideParameter.Value = new IntValue(0);
327
328      resetGenerationsSinceLastReunificationAssigner.Name = "Reset GenerationsSinceLastReunification";
329      resetGenerationsSinceLastReunificationAssigner.LeftSideParameter.ActualName = "GenerationsSinceLastReunification";
330      resetGenerationsSinceLastReunificationAssigner.RightSideParameter.Value = new IntValue(0);
331
332      reunificator.VillageCountParameter.ActualName = "VillageCount";
333
334      reunificationCounter.ValueParameter.ActualName = "Reunifications"; // this variable is referenced in SASEGASA, do not change!
335      reunificationCounter.IncrementParameter.Value = new IntValue(1);
336
337      comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
338
339      villageReviver.Name = "Village Reviver";
340      villageReviver.LeftSideParameter.ActualName = "TerminateSelectionPressure";
341      villageReviver.RightSideParameter.Value = new BoolValue(false);
342
343      villageCountComparator.Name = "VillageCount == 1 ?";
344      villageCountComparator.LeftSideParameter.ActualName = "VillageCount";
345      villageCountComparator.RightSideParameter.Value = new IntValue(1);
346      villageCountComparator.Comparison.Value = ComparisonType.Equal;
347      villageCountComparator.ResultParameter.ActualName = "ChangeMaxSelPress";
348
349      villageCountConditionalBranch.Name = "Change max selection pressure?";
350      villageCountConditionalBranch.ConditionParameter.ActualName = "ChangeMaxSelPress";
351
352      finalMaxSelPressAssigner.LeftSideParameter.ActualName = "CurrentMaximumSelectionPressure";
353      finalMaxSelPressAssigner.RightSideParameter.ActualName = FinalMaximumSelectionPressureParameter.Name;
354
355      // if Generations is reaching MaximumGenerations we're also terminating
356      maximumGenerationsComparator.LeftSideParameter.ActualName = "Generations";
357      maximumGenerationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
358      maximumGenerationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
359      maximumGenerationsComparator.ResultParameter.ActualName = "TerminateMaximumGenerations";
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      terminationCondition.ConditionParameter.ActualName = "TerminateSASEGASA";
369      maximumGenerationsTerminationCondition.ConditionParameter.ActualName = "TerminateMaximumGenerations";
370      #endregion
371
372      #region Create operator graph
373      OperatorGraph.InitialOperator = variableCreator;
374      variableCreator.Successor = maxSelPressAssigner;
375      maxSelPressAssigner.Successor = villageCountAssigner;
376      villageCountAssigner.Successor = comparisonFactorInitializer;
377      comparisonFactorInitializer.Successor = uniformSubScopesProcessor0;
378      uniformSubScopesProcessor0.Operator = villageVariableCreator;
379      uniformSubScopesProcessor0.Successor = analyzer1;
380      villageVariableCreator.Successor = villageAnalyzer1;
381      villageAnalyzer1.Successor = villageResultsCollector1;
382      analyzer1.Successor = resultsCollector1;
383      resultsCollector1.Successor = resultsCollector2;
384      resultsCollector2.Successor = uniformSubScopesProcessor1;
385      uniformSubScopesProcessor1.Operator = villageTerminatedBySelectionPressure1;
386      uniformSubScopesProcessor1.Successor = generationsCounter;
387      villageTerminatedBySelectionPressure1.TrueBranch = null;
388      villageTerminatedBySelectionPressure1.FalseBranch = mainOperator;
389      villageTerminatedBySelectionPressure1.Successor = null;
390      mainOperator.Successor = villageAnalyzer2;
391      villageAnalyzer2.Successor = villageResultsCollector2;
392      villageResultsCollector2.Successor = evaluatedSolutionsCounter;
393      evaluatedSolutionsCounter.Successor = villageEvaluatedSolutionsAssigner;
394      villageEvaluatedSolutionsAssigner.Successor = villageSelectionPressureComparator;
395      villageSelectionPressureComparator.Successor = villageTerminatedBySelectionPressure2;
396      villageTerminatedBySelectionPressure2.TrueBranch = terminatedVillagesCounter;
397      villageTerminatedBySelectionPressure2.FalseBranch = null;
398      villageTerminatedBySelectionPressure2.Successor = null;
399      terminatedVillagesCounter.Successor = null;
400      generationsCounter.Successor = generationsSinceLastReunificationCounter;
401      generationsSinceLastReunificationCounter.Successor = reunificationComparator1;
402      reunificationComparator1.Successor = reunificationConditionalBranch1;
403      reunificationConditionalBranch1.TrueBranch = reunificationComparator3;
404      reunificationConditionalBranch1.FalseBranch = reunificationComparator2;
405      reunificationConditionalBranch1.Successor = maximumGenerationsComparator;
406      reunificationComparator2.Successor = reunificationConditionalBranch2;
407      reunificationConditionalBranch2.TrueBranch = reunificationComparator3;
408      reunificationConditionalBranch2.FalseBranch = null;
409      reunificationConditionalBranch2.Successor = null;
410      reunificationComparator3.Successor = reunificationConditionalBranch3;
411      reunificationConditionalBranch3.TrueBranch = null;
412      reunificationConditionalBranch3.FalseBranch = resetTerminatedVillagesAssigner;
413      reunificationConditionalBranch3.Successor = null;
414      resetTerminatedVillagesAssigner.Successor = resetGenerationsSinceLastReunificationAssigner;
415      resetGenerationsSinceLastReunificationAssigner.Successor = reunificator;
416      reunificator.Successor = reunificationCounter;
417      reunificationCounter.Successor = comparisonFactorModifier;
418      comparisonFactorModifier.Successor = uniformSubScopesProcessor2;
419      uniformSubScopesProcessor2.Operator = villageReviver;
420      uniformSubScopesProcessor2.Successor = villageCountComparator;
421      villageReviver.Successor = null;
422      villageCountComparator.Successor = villageCountConditionalBranch;
423      villageCountConditionalBranch.TrueBranch = finalMaxSelPressAssigner;
424      villageCountConditionalBranch.FalseBranch = null;
425      villageCountConditionalBranch.Successor = null;
426      finalMaxSelPressAssigner.Successor = null;
427      maximumGenerationsComparator.Successor = analyzer2;
428      analyzer2.Successor = resultsCollector3;
429      resultsCollector3.Successor = terminationCondition;
430      terminationCondition.TrueBranch = null;
431      terminationCondition.FalseBranch = maximumGenerationsTerminationCondition;
432      terminationCondition.Successor = null;
433      maximumGenerationsTerminationCondition.TrueBranch = null;
434      maximumGenerationsTerminationCondition.FalseBranch = uniformSubScopesProcessor1;
435      maximumGenerationsTerminationCondition.Successor = null;
436      #endregion
437    }
438  }
439}
Note: See TracBrowser for help on using the repository browser.