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

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

Added an OS Island GA #976
Wired the parallel parameter in the standard Island GA #971

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