source: trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithmMainLoop.cs @ 3446

Last change on this file since 3446 was 3446, checked in by abeham, 11 years ago

updated OSIslandGA #976

File size: 29.2 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.Analysis;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Operators;
26using HeuristicLab.Optimization.Operators;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29using HeuristicLab.Selection;
30
31namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm {
32  /// <summary>
33  /// An operator which represents the main loop of an offspring selection genetic algorithm.
34  /// </summary>
35  [Item("OffspringSelectionGeneticAlgorithmMainLoop", "An operator which represents the main loop of an offspring selection genetic algorithm.")]
36  [StorableClass]
37  public sealed class OffspringSelectionGeneticAlgorithmMainLoop : 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 ValueLookupParameter<IntValue> PopulationSizeParameter {
46      get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; }
47    }
48    public SubScopesLookupParameter<DoubleValue> QualityParameter {
49      get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; }
50    }
51    public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
52      get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
53    }
54    public ValueLookupParameter<IOperator> SelectorParameter {
55      get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
56    }
57    public ValueLookupParameter<IOperator> CrossoverParameter {
58      get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
59    }
60    public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
61      get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
62    }
63    public ValueLookupParameter<IOperator> MutatorParameter {
64      get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
65    }
66    public ValueLookupParameter<IOperator> EvaluatorParameter {
67      get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
68    }
69    public ValueLookupParameter<IntValue> ElitesParameter {
70      get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
71    }
72    public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
73      get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
74    }
75    public ValueLookupParameter<VariableCollection> ResultsParameter {
76      get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; }
77    }
78    public ValueLookupParameter<IOperator> VisualizerParameter {
79      get { return (ValueLookupParameter<IOperator>)Parameters["Visualizer"]; }
80    }
81    public LookupParameter<IItem> VisualizationParameter {
82      get { return (LookupParameter<IItem>)Parameters["Visualization"]; }
83    }
84    public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
85      get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
86    }
87    public ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
88      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorLowerBound"]; }
89    }
90    public ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
91      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorUpperBound"]; }
92    }
93    public ValueLookupParameter<IOperator> ComparisonFactorModifierParameter {
94      get { return (ValueLookupParameter<IOperator>)Parameters["ComparisonFactorModifier"]; }
95    }
96    public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
97      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
98    }
99    public ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
100      get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
101    }
102    #endregion
103
104    [StorableConstructor]
105    private OffspringSelectionGeneticAlgorithmMainLoop(bool deserializing) : base() { }
106    public OffspringSelectionGeneticAlgorithmMainLoop()
107      : base() {
108      Initialize();
109    }
110
111    private void Initialize() {
112      #region Create parameters
113      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
114      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
115      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population."));
116      Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
117      Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
118      Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
119      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
120      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
121      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
122      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
123      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
124      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed."));
125      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
126      Parameters.Add(new ValueLookupParameter<IOperator>("Visualizer", "The operator used to visualize solutions."));
127      Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions."));
128      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
129      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start)."));
130      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end)."));
131      Parameters.Add(new ValueLookupParameter<IOperator>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));
132      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
133      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."));
134      #endregion
135
136      #region Create operators
137      ConditionalBranch initializationBranch = new ConditionalBranch();
138      VariableCreator variableCreator = new VariableCreator();
139      Assigner variableAssigner = new Assigner();
140      BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer();
141      BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer();
142      BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();
143      DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector();
144      DataTableValuesCollector selPressDataTableValuesCollector1 = new DataTableValuesCollector();
145      QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator();
146      Placeholder visualizer1 = new Placeholder();
147      ResultsCollector resultsCollector = new ResultsCollector();
148      Placeholder selector = new Placeholder();
149      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
150      ChildrenCreator childrenCreator = new ChildrenCreator();
151      UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
152      Placeholder crossover = new Placeholder();
153      ConditionalBranch osBeforeMutationBranch = new ConditionalBranch();
154      Placeholder evaluator1 = new Placeholder();
155      IntCounter evaluationCounter1 = new IntCounter();
156      WeightedParentsQualityComparator qualityComparer1 = new WeightedParentsQualityComparator();
157      StochasticBranch mutationBranch1 = new StochasticBranch();
158      Placeholder mutator1 = new Placeholder();
159      Placeholder evaluator2 = new Placeholder();
160      IntCounter evaluationCounter2 = new IntCounter();
161      StochasticBranch mutationBranch2 = new StochasticBranch();
162      Placeholder mutator2 = new Placeholder();
163      Placeholder evaluator3 = new Placeholder();
164      IntCounter evaluationCounter3 = new IntCounter();
165      WeightedParentsQualityComparator qualityComparer2 = new WeightedParentsQualityComparator();
166      SubScopesRemover subScopesRemover = new SubScopesRemover();
167      ConditionalSelector conditionalSelector = new ConditionalSelector();
168      OffspringSelector offspringSelector = new OffspringSelector();
169      SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
170      BestSelector bestSelector = new BestSelector();
171      RightReducer rightReducer = new RightReducer();
172      MergingReducer mergingReducer = new MergingReducer();
173      IntCounter intCounter = new IntCounter();
174      Placeholder comparisonFactorModifier = new Placeholder();
175      Comparator comparator1 = new Comparator();
176      Comparator comparator2 = new Comparator();
177      Assigner evaluatedSolutionsAssigner = new Assigner();
178      ResultsCollector evalSolCollector = new ResultsCollector();
179      BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer();
180      BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer();
181      BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
182      DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector();
183      DataTableValuesCollector selPressDataTableValuesCollector2 = new DataTableValuesCollector();
184      QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
185      Placeholder visualizer2 = new Placeholder();
186      ConditionalBranch conditionalBranch1 = new ConditionalBranch();
187      ConditionalBranch conditionalBranch2 = new ConditionalBranch();
188
189      initializationBranch.ConditionParameter.ActualName = "IsInitialized";
190
191      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
192      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
193      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
194      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
195      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutionsResult", new IntValue(0)));
196      variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("IsInitialized", new BoolValue(true)));
197
198      variableAssigner.LeftSideParameter.ActualName = "ComparisonFactor";
199      variableAssigner.RightSideParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
200
201      bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
202      bestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
203      bestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name;
204
205      bestQualityMemorizer2.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
206      bestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
207      bestQualityMemorizer2.QualityParameter.ActualName = QualityParameter.Name;
208
209      bestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageQuality";
210      bestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestQuality";
211      bestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;
212      bestAverageWorstQualityCalculator1.QualityParameter.ActualName = QualityParameter.Name;
213      bestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstQuality";
214
215      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
216      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
217      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
218      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
219      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
220      dataTableValuesCollector1.DataTableParameter.ActualName = "Qualities";
221
222      selPressDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure"));
223      selPressDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
224      selPressDataTableValuesCollector1.DataTableParameter.ActualName = "SelectionPressures";
225
226      qualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
227      qualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
228      qualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
229      qualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";
230
231      visualizer1.Name = "Visualizer (placeholder)";
232      visualizer1.OperatorParameter.ActualName = VisualizerParameter.Name;
233
234      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
235      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
236      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
237      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
238      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
239      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
240      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
241      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
242      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult"));
243      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Curent Comparison Factor", null, "ComparisonFactor"));
244      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
245      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
246      resultsCollector.CollectedValues.Add(new LookupParameter<IItem>("Solution Visualization", null, VisualizationParameter.Name));
247      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities"));
248      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("SelectionPressures"));
249      resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
250
251      selector.Name = "Selector (placeholder)";
252      selector.OperatorParameter.ActualName = SelectorParameter.Name;
253
254      childrenCreator.ParentsPerChild = new IntValue(2);
255
256      crossover.Name = "Crossover (placeholder)";
257      crossover.OperatorParameter.ActualName = CrossoverParameter.Name;
258
259      osBeforeMutationBranch.Name = "Apply OS before mutation?";
260      osBeforeMutationBranch.ConditionParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
261
262      evaluator1.Name = "Evaluator (placeholder)";
263      evaluator1.OperatorParameter.ActualName = EvaluatorParameter.Name;
264
265      evaluationCounter1.Name = "EvaluatedSolutions++";
266      evaluationCounter1.Increment = new IntValue(1);
267      evaluationCounter1.ValueParameter.ActualName = "EvaluatedSolutions";
268
269      qualityComparer1.ComparisonFactorParameter.ActualName = "ComparisonFactor";
270      qualityComparer1.LeftSideParameter.ActualName = QualityParameter.Name;
271      qualityComparer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
272      qualityComparer1.RightSideParameter.ActualName = QualityParameter.Name;
273      qualityComparer1.ResultParameter.ActualName = "SuccessfulOffspring";
274
275      mutationBranch1.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
276      mutationBranch1.RandomParameter.ActualName = RandomParameter.Name;
277
278      mutator1.Name = "Mutator (placeholder)";
279      mutator1.OperatorParameter.ActualName = MutatorParameter.Name;
280
281      evaluator2.Name = "Evaluator (placeholder)";
282      evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;
283
284      evaluationCounter2.Name = "EvaluatedSolutions++";
285      evaluationCounter2.Increment = new IntValue(1);
286      evaluationCounter2.ValueParameter.ActualName = "EvaluatedSolutions";
287
288      mutationBranch2.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
289      mutationBranch2.RandomParameter.ActualName = RandomParameter.Name;
290
291      mutator2.Name = "Mutator (placeholder)";
292      mutator2.OperatorParameter.ActualName = MutatorParameter.Name;
293
294      evaluator3.Name = "Evaluator (placeholder)";
295      evaluator3.OperatorParameter.ActualName = EvaluatorParameter.Name;
296
297      evaluationCounter3.Name = "EvaluatedSolutions++";
298      evaluationCounter3.Increment = new IntValue(1);
299      evaluationCounter3.ValueParameter.ActualName = "EvaluatedSolutions";
300
301      qualityComparer2.ComparisonFactorParameter.ActualName = "ComparisonFactor";
302      qualityComparer2.LeftSideParameter.ActualName = QualityParameter.Name;
303      qualityComparer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
304      qualityComparer2.RightSideParameter.ActualName = QualityParameter.Name;
305      qualityComparer2.ResultParameter.ActualName = "SuccessfulOffspring";
306
307      subScopesRemover.RemoveAllSubScopes = true;
308
309      conditionalSelector.CopySelected = new BoolValue(false);
310      conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring";
311
312      offspringSelector.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
313      offspringSelector.LuckyLosersParameter.ActualName = "OSLuckyLosers";
314      offspringSelector.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
315      offspringSelector.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
316      offspringSelector.SelectionPressureParameter.ActualName = "SelectionPressure";
317      offspringSelector.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
318      offspringSelector.WinnersParameter.ActualName = "OSWinners";
319
320      bestSelector.CopySelected = new BoolValue(false);
321      bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
322      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = ElitesParameter.Name;
323      bestSelector.QualityParameter.ActualName = QualityParameter.Name;
324
325      intCounter.Increment = new IntValue(1);
326      intCounter.ValueParameter.ActualName = "Generations";
327
328      comparisonFactorModifier.Name = "Modify ComparisonFactor (placeholder)";
329      comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
330
331      comparator1.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
332      comparator1.LeftSideParameter.ActualName = "Generations";
333      comparator1.ResultParameter.ActualName = "TerminateMaximumGenerations";
334      comparator1.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
335
336      comparator2.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
337      comparator2.LeftSideParameter.ActualName = "SelectionPressure";
338      comparator2.ResultParameter.ActualName = "TerminateSelectionPressure";
339      comparator2.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
340
341      evaluatedSolutionsAssigner.LeftSideParameter.ActualName = "EvaluatedSolutionsResult";
342      evaluatedSolutionsAssigner.RightSideParameter.ActualName = "EvaluatedSolutions";
343
344      evalSolCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult"));
345      evalSolCollector.ResultsParameter.ActualName = ResultsParameter.Name;
346
347      bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality";
348      bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name;
349      bestQualityMemorizer3.QualityParameter.ActualName = QualityParameter.Name;
350
351      bestQualityMemorizer4.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
352      bestQualityMemorizer4.MaximizationParameter.ActualName = MaximizationParameter.Name;
353      bestQualityMemorizer4.QualityParameter.ActualName = QualityParameter.Name;
354
355      bestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageQuality";
356      bestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestQuality";
357      bestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name;
358      bestAverageWorstQualityCalculator2.QualityParameter.ActualName = QualityParameter.Name;
359      bestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstQuality";
360
361      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
362      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
363      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
364      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
365      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
366      dataTableValuesCollector2.DataTableParameter.ActualName = "Qualities";
367
368      selPressDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure"));
369      selPressDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
370      selPressDataTableValuesCollector2.DataTableParameter.ActualName = "SelectionPressures";
371
372      qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
373      qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
374      qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
375      qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
376
377      visualizer2.Name = "Visualizer (placeholder)";
378      visualizer2.OperatorParameter.ActualName = VisualizerParameter.Name;
379
380      conditionalBranch1.Name = "MaximumSelectionPressure reached?";
381      conditionalBranch1.ConditionParameter.ActualName = "TerminateSelectionPressure";
382
383      conditionalBranch2.Name = "MaximumGenerations reached?";
384      conditionalBranch2.ConditionParameter.ActualName = "TerminateMaximumGenerations";
385      #endregion
386
387      #region Create operator graph
388      OperatorGraph.InitialOperator = initializationBranch;
389      initializationBranch.FalseBranch = variableCreator;
390      initializationBranch.Successor = selector;
391      variableCreator.Successor = variableAssigner;
392      variableAssigner.Successor = bestQualityMemorizer1;
393      bestQualityMemorizer1.Successor = bestQualityMemorizer2;
394      bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1;
395      bestAverageWorstQualityCalculator1.Successor = dataTableValuesCollector1;
396      dataTableValuesCollector1.Successor = selPressDataTableValuesCollector1;
397      selPressDataTableValuesCollector1.Successor = qualityDifferenceCalculator1;
398      qualityDifferenceCalculator1.Successor = visualizer1;
399      visualizer1.Successor = resultsCollector;
400      resultsCollector.Successor = null;
401      selector.Successor = subScopesProcessor1;
402      subScopesProcessor1.Operators.Add(new EmptyOperator());
403      subScopesProcessor1.Operators.Add(childrenCreator);
404      subScopesProcessor1.Successor = offspringSelector;
405      childrenCreator.Successor = uniformSubScopesProcessor;
406      uniformSubScopesProcessor.Operator = crossover;
407      uniformSubScopesProcessor.Successor = conditionalSelector;
408      crossover.Successor = osBeforeMutationBranch;
409      osBeforeMutationBranch.TrueBranch = evaluator1;
410      osBeforeMutationBranch.FalseBranch = mutationBranch2;
411      osBeforeMutationBranch.Successor = subScopesRemover;
412      evaluator1.Successor = evaluationCounter1;
413      evaluationCounter1.Successor = qualityComparer1;
414      qualityComparer1.Successor = mutationBranch1;
415      mutationBranch1.FirstBranch = mutator1;
416      mutationBranch1.SecondBranch = null;
417      mutationBranch1.Successor = null;
418      mutator1.Successor = evaluator2;
419      evaluator2.Successor = evaluationCounter2;
420      evaluationCounter2.Successor = null;
421      mutationBranch2.FirstBranch = mutator2;
422      mutationBranch2.SecondBranch = null;
423      mutationBranch2.Successor = evaluator3;
424      mutator2.Successor = null;
425      evaluator3.Successor = evaluationCounter3;
426      evaluationCounter3.Successor = qualityComparer2;
427      subScopesRemover.Successor = null;
428      offspringSelector.OffspringCreator = selector;
429      offspringSelector.Successor = subScopesProcessor2;
430      subScopesProcessor2.Operators.Add(bestSelector);
431      subScopesProcessor2.Operators.Add(new EmptyOperator());
432      subScopesProcessor2.Successor = mergingReducer;
433      bestSelector.Successor = rightReducer;
434      rightReducer.Successor = null;
435      mergingReducer.Successor = intCounter;
436      intCounter.Successor = comparisonFactorModifier;
437      comparisonFactorModifier.Successor = comparator1;
438      comparator1.Successor = comparator2;
439      comparator2.Successor = evaluatedSolutionsAssigner;
440      evaluatedSolutionsAssigner.Successor = evalSolCollector;
441      evalSolCollector.Successor = bestQualityMemorizer3;
442      bestQualityMemorizer3.Successor = bestQualityMemorizer4;
443      bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2;
444      bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector2;
445      dataTableValuesCollector2.Successor = selPressDataTableValuesCollector2;
446      selPressDataTableValuesCollector2.Successor = qualityDifferenceCalculator2;
447      qualityDifferenceCalculator2.Successor = visualizer2;
448      visualizer2.Successor = conditionalBranch1;
449      conditionalBranch1.FalseBranch = conditionalBranch2;
450      conditionalBranch1.TrueBranch = null;
451      conditionalBranch1.Successor = null;
452      conditionalBranch2.FalseBranch = selector;
453      conditionalBranch2.TrueBranch = null;
454      conditionalBranch2.Successor = null;
455      #endregion
456    }
457  }
458}
Note: See TracBrowser for help on using the repository browser.