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

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

Updated Gender Specific Selection, Offspring Selector and other changes related to the OSGA #976
Removed old OS plugin, removed SelectedSubScopesLookupParameter

File size: 26.8 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      VariableCreator variableCreator = new VariableCreator();
138      Assigner variableAssigner = new Assigner();
139      BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer();
140      BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer();
141      BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();
142      DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector();
143      DataTableValuesCollector selPressDataTableValuesCollector1 = new DataTableValuesCollector();
144      QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator();
145      Placeholder visualizer1 = new Placeholder();
146      ResultsCollector resultsCollector = new ResultsCollector();
147      Placeholder selector = new Placeholder();
148      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
149      ChildrenCreator childrenCreator = new ChildrenCreator();
150      UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
151      Placeholder crossover = new Placeholder();
152      ConditionalBranch osBeforeMutationBranch = new ConditionalBranch();
153      Placeholder evaluator1 = new Placeholder();
154      WeightedParentsQualityComparator qualityComparer1 = new WeightedParentsQualityComparator();
155      StochasticBranch mutationBranch1 = new StochasticBranch();
156      Placeholder mutator1 = new Placeholder();
157      Placeholder evaluator2 = new Placeholder();
158      StochasticBranch mutationBranch2 = new StochasticBranch();
159      Placeholder mutator2 = new Placeholder();
160      Placeholder evaluator3 = new Placeholder();
161      WeightedParentsQualityComparator qualityComparer2 = new WeightedParentsQualityComparator();
162      SubScopesRemover subScopesRemover = new SubScopesRemover();
163      ConditionalSelector conditionalSelector = new ConditionalSelector();
164      OffspringSelector offspringSelector = new OffspringSelector();
165      SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
166      BestSelector bestSelector = new BestSelector();
167      RightReducer rightReducer = new RightReducer();
168      MergingReducer mergingReducer = new MergingReducer();
169      IntCounter intCounter = new IntCounter();
170      Placeholder comparisonFactorModifier = new Placeholder();
171      Comparator comparator1 = new Comparator();
172      Comparator comparator2 = new Comparator();
173      BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer();
174      BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer();
175      BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
176      DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector();
177      DataTableValuesCollector selPressDataTableValuesCollector2 = new DataTableValuesCollector();
178      QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
179      Placeholder visualizer2 = new Placeholder();
180      ConditionalBranch conditionalBranch1 = new ConditionalBranch();
181      ConditionalBranch conditionalBranch2 = new ConditionalBranch();
182
183      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
184      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
185      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
186
187      variableAssigner.LeftSideParameter.ActualName = "ComparisonFactor";
188      variableAssigner.RightSideParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
189
190      bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
191      bestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
192      bestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name;
193
194      bestQualityMemorizer2.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
195      bestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
196      bestQualityMemorizer2.QualityParameter.ActualName = QualityParameter.Name;
197
198      bestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageQuality";
199      bestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestQuality";
200      bestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;
201      bestAverageWorstQualityCalculator1.QualityParameter.ActualName = QualityParameter.Name;
202      bestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstQuality";
203
204      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
205      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
206      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
207      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
208      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
209      dataTableValuesCollector1.DataTableParameter.ActualName = "Qualities";
210
211      selPressDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure"));
212      selPressDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
213      selPressDataTableValuesCollector1.DataTableParameter.ActualName = "SelectionPressures";
214
215      qualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
216      qualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
217      qualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
218      qualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";
219
220      visualizer1.Name = "Visualizer (placeholder)";
221      visualizer1.OperatorParameter.ActualName = VisualizerParameter.Name;
222
223      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
224      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
225      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
226      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
227      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
228      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
229      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
230      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
231      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
232      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
233      resultsCollector.CollectedValues.Add(new LookupParameter<IItem>("Solution Visualization", null, VisualizationParameter.Name));
234      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities"));
235      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("SelectionPressures"));
236      resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
237
238      selector.Name = "Selector (placeholder)";
239      selector.OperatorParameter.ActualName = SelectorParameter.Name;
240
241      childrenCreator.ParentsPerChild = new IntValue(2);
242
243      crossover.Name = "Crossover (placeholder)";
244      crossover.OperatorParameter.ActualName = CrossoverParameter.Name;
245
246      osBeforeMutationBranch.Name = "Apply OS before mutation?";
247      osBeforeMutationBranch.ConditionParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
248
249      evaluator1.Name = "Evaluator (placeholder)";
250      evaluator1.OperatorParameter.ActualName = EvaluatorParameter.Name;
251
252      qualityComparer1.ComparisonFactorParameter.ActualName = "ComparisonFactor";
253      qualityComparer1.LeftSideParameter.ActualName = QualityParameter.Name;
254      qualityComparer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
255      qualityComparer1.RightSideParameter.ActualName = QualityParameter.Name;
256      qualityComparer1.ResultParameter.ActualName = "SuccessfulOffspring";
257
258      mutationBranch1.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
259      mutationBranch1.RandomParameter.ActualName = RandomParameter.Name;
260
261      mutator1.Name = "Mutator (placeholder)";
262      mutator1.OperatorParameter.ActualName = MutatorParameter.Name;
263
264      evaluator2.Name = "Evaluator (placeholder)";
265      evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;
266
267      mutationBranch2.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
268      mutationBranch2.RandomParameter.ActualName = RandomParameter.Name;
269
270      mutator2.Name = "Mutator (placeholder)";
271      mutator2.OperatorParameter.ActualName = MutatorParameter.Name;
272
273      evaluator3.Name = "Evaluator (placeholder)";
274      evaluator3.OperatorParameter.ActualName = EvaluatorParameter.Name;
275
276      qualityComparer2.ComparisonFactorParameter.ActualName = "ComparisonFactor";
277      qualityComparer2.LeftSideParameter.ActualName = QualityParameter.Name;
278      qualityComparer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
279      qualityComparer2.RightSideParameter.ActualName = QualityParameter.Name;
280      qualityComparer2.ResultParameter.ActualName = "SuccessfulOffspring";
281
282      subScopesRemover.RemoveAllSubScopes = true;
283
284      conditionalSelector.CopySelected = new BoolValue(false);
285      conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring";
286
287      offspringSelector.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
288      offspringSelector.LuckyLosersParameter.ActualName = "OSLuckyLosers";
289      offspringSelector.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
290      offspringSelector.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
291      offspringSelector.SelectionPressureParameter.ActualName = "SelectionPressure";
292      offspringSelector.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
293      offspringSelector.WinnersParameter.ActualName = "OSWinners";
294
295      bestSelector.CopySelected = new BoolValue(false);
296      bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
297      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = ElitesParameter.Name;
298      bestSelector.QualityParameter.ActualName = QualityParameter.Name;
299
300      intCounter.Increment = new IntValue(1);
301      intCounter.ValueParameter.ActualName = "Generations";
302
303      comparisonFactorModifier.Name = "Modify ComparisonFactor (placeholder)";
304      comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
305
306      comparator1.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
307      comparator1.LeftSideParameter.ActualName = "Generations";
308      comparator1.ResultParameter.ActualName = "TerminateMaximumGenerations";
309      comparator1.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
310
311      comparator2.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
312      comparator2.LeftSideParameter.ActualName = "SelectionPressure";
313      comparator2.ResultParameter.ActualName = "TerminateSelectionPressure";
314      comparator2.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
315
316      bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality";
317      bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name;
318      bestQualityMemorizer3.QualityParameter.ActualName = QualityParameter.Name;
319
320      bestQualityMemorizer4.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
321      bestQualityMemorizer4.MaximizationParameter.ActualName = MaximizationParameter.Name;
322      bestQualityMemorizer4.QualityParameter.ActualName = QualityParameter.Name;
323
324      bestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageQuality";
325      bestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestQuality";
326      bestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name;
327      bestAverageWorstQualityCalculator2.QualityParameter.ActualName = QualityParameter.Name;
328      bestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstQuality";
329
330      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
331      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
332      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
333      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
334      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
335      dataTableValuesCollector2.DataTableParameter.ActualName = "Qualities";
336
337      selPressDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure"));
338      selPressDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
339      selPressDataTableValuesCollector2.DataTableParameter.ActualName = "SelectionPressures";
340
341      qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
342      qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
343      qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
344      qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
345
346      visualizer2.Name = "Visualizer (placeholder)";
347      visualizer2.OperatorParameter.ActualName = VisualizerParameter.Name;
348
349      conditionalBranch1.Name = "MaximumSelectionPressure reached?";
350      conditionalBranch1.ConditionParameter.ActualName = "TerminateSelectionPressure";
351
352      conditionalBranch2.Name = "MaximumGenerations reached?";
353      conditionalBranch2.ConditionParameter.ActualName = "TerminateMaximumGenerations";
354      #endregion
355
356      #region Create operator graph
357      OperatorGraph.InitialOperator = variableCreator;
358      variableCreator.Successor = variableAssigner;
359      variableAssigner.Successor = bestQualityMemorizer1;
360      bestQualityMemorizer1.Successor = bestQualityMemorizer2;
361      bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1;
362      bestAverageWorstQualityCalculator1.Successor = dataTableValuesCollector1;
363      dataTableValuesCollector1.Successor = selPressDataTableValuesCollector1;
364      selPressDataTableValuesCollector1.Successor = qualityDifferenceCalculator1;
365      qualityDifferenceCalculator1.Successor = visualizer1;
366      visualizer1.Successor = resultsCollector;
367      resultsCollector.Successor = selector;
368      selector.Successor = subScopesProcessor1;
369      subScopesProcessor1.Operators.Add(new EmptyOperator());
370      subScopesProcessor1.Operators.Add(childrenCreator);
371      subScopesProcessor1.Successor = offspringSelector;
372      childrenCreator.Successor = uniformSubScopesProcessor;
373      uniformSubScopesProcessor.Operator = crossover;
374      uniformSubScopesProcessor.Successor = conditionalSelector;
375      crossover.Successor = osBeforeMutationBranch;
376      osBeforeMutationBranch.TrueBranch = evaluator1;
377      osBeforeMutationBranch.FalseBranch = mutationBranch2;
378      osBeforeMutationBranch.Successor = subScopesRemover;
379      evaluator1.Successor = qualityComparer1;
380      qualityComparer1.Successor = mutationBranch1;
381      mutationBranch1.FirstBranch = mutator1;
382      mutationBranch1.SecondBranch = null;
383      mutationBranch1.Successor = null;
384      mutator1.Successor = evaluator2;
385      evaluator2.Successor = null;
386      mutationBranch2.FirstBranch = mutator2;
387      mutationBranch2.SecondBranch = null;
388      mutationBranch2.Successor = evaluator3;
389      mutator2.Successor = null;
390      evaluator3.Successor = qualityComparer2;
391      subScopesRemover.Successor = null;
392      offspringSelector.OffspringCreator = selector;
393      offspringSelector.Successor = subScopesProcessor2;
394      subScopesProcessor2.Operators.Add(bestSelector);
395      subScopesProcessor2.Operators.Add(new EmptyOperator());
396      subScopesProcessor2.Successor = mergingReducer;
397      bestSelector.Successor = rightReducer;
398      rightReducer.Successor = null;
399      mergingReducer.Successor = intCounter;
400      intCounter.Successor = comparisonFactorModifier;
401      comparisonFactorModifier.Successor = comparator1;
402      comparator1.Successor = comparator2;
403      comparator2.Successor = bestQualityMemorizer3;
404      bestQualityMemorizer3.Successor = bestQualityMemorizer4;
405      bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2;
406      bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector2;
407      dataTableValuesCollector2.Successor = selPressDataTableValuesCollector2;
408      selPressDataTableValuesCollector2.Successor = qualityDifferenceCalculator2;
409      qualityDifferenceCalculator2.Successor = visualizer2;
410      visualizer2.Successor = conditionalBranch1;
411      conditionalBranch1.FalseBranch = conditionalBranch2;
412      conditionalBranch1.TrueBranch = null;
413      conditionalBranch1.Successor = null;
414      conditionalBranch2.FalseBranch = selector;
415      conditionalBranch2.TrueBranch = null;
416      conditionalBranch2.Successor = null;
417      #endregion
418    }
419  }
420}
Note: See TracBrowser for help on using the repository browser.