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

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

Added evaluated solutions result to OSGA (this slows down execution extremely if the update is not decoupled in some way)
Made comparison factor modifier an optional parameter #976

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