Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 3580 was 3479, checked in by abeham, 15 years ago

added first draft of SASEGASA #839

File size: 29.1 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 SubScopesLookupParameter<DoubleValue> QualityParameter {
46      get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; }
47    }
48    public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
49      get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
50    }
51    public ValueLookupParameter<IOperator> SelectorParameter {
52      get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
53    }
54    public ValueLookupParameter<IOperator> CrossoverParameter {
55      get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
56    }
57    public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
58      get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
59    }
60    public ValueLookupParameter<IOperator> MutatorParameter {
61      get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
62    }
63    public ValueLookupParameter<IOperator> EvaluatorParameter {
64      get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
65    }
66    public ValueLookupParameter<IntValue> ElitesParameter {
67      get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
68    }
69    public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
70      get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
71    }
72    public ValueLookupParameter<VariableCollection> ResultsParameter {
73      get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; }
74    }
75    public ValueLookupParameter<IOperator> VisualizerParameter {
76      get { return (ValueLookupParameter<IOperator>)Parameters["Visualizer"]; }
77    }
78    public LookupParameter<IItem> VisualizationParameter {
79      get { return (LookupParameter<IItem>)Parameters["Visualization"]; }
80    }
81    public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
82      get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
83    }
84    public ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
85      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorLowerBound"]; }
86    }
87    public ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
88      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorUpperBound"]; }
89    }
90    public ValueLookupParameter<IOperator> ComparisonFactorModifierParameter {
91      get { return (ValueLookupParameter<IOperator>)Parameters["ComparisonFactorModifier"]; }
92    }
93    public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
94      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
95    }
96    public ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
97      get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
98    }
99    #endregion
100
101    [StorableConstructor]
102    private OffspringSelectionGeneticAlgorithmMainLoop(bool deserializing) : base() { }
103    public OffspringSelectionGeneticAlgorithmMainLoop()
104      : base() {
105      Initialize();
106    }
107
108    private void Initialize() {
109      #region Create parameters
110      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
111      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
112      Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
113      Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
114      Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
115      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
116      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
117      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
118      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
119      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
120      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed."));
121      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
122      Parameters.Add(new ValueLookupParameter<IOperator>("Visualizer", "The operator used to visualize solutions."));
123      Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions."));
124      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
125      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start)."));
126      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end)."));
127      Parameters.Add(new ValueLookupParameter<IOperator>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));
128      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
129      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."));
130      #endregion
131
132      #region Create operators
133      ConditionalBranch initializationBranch = new ConditionalBranch();
134      VariableCreator variableCreator = new VariableCreator();
135      Assigner variableAssigner = new Assigner();
136      BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer();
137      BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer();
138      BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();
139      DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector();
140      DataTableValuesCollector selPressDataTableValuesCollector1 = new DataTableValuesCollector();
141      QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator();
142      Placeholder visualizer1 = new Placeholder();
143      ResultsCollector resultsCollector = new ResultsCollector();
144      Placeholder selector = new Placeholder();
145      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
146      ChildrenCreator childrenCreator = new ChildrenCreator();
147      UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
148      Placeholder crossover = new Placeholder();
149      ConditionalBranch osBeforeMutationBranch = new ConditionalBranch();
150      Placeholder evaluator1 = new Placeholder();
151      IntCounter evaluationCounter1 = new IntCounter();
152      WeightedParentsQualityComparator qualityComparer1 = new WeightedParentsQualityComparator();
153      StochasticBranch mutationBranch1 = new StochasticBranch();
154      Placeholder mutator1 = new Placeholder();
155      Placeholder evaluator2 = new Placeholder();
156      IntCounter evaluationCounter2 = new IntCounter();
157      StochasticBranch mutationBranch2 = new StochasticBranch();
158      Placeholder mutator2 = new Placeholder();
159      Placeholder evaluator3 = new Placeholder();
160      IntCounter evaluationCounter3 = new IntCounter();
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      Assigner evaluatedSolutionsAssigner = new Assigner();
174      ResultsCollector evalSolCollector = new ResultsCollector();
175      BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer();
176      BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer();
177      BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
178      DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector();
179      DataTableValuesCollector selPressDataTableValuesCollector2 = new DataTableValuesCollector();
180      QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
181      Placeholder visualizer2 = new Placeholder();
182      ConditionalBranch conditionalBranch1 = new ConditionalBranch();
183      ConditionalBranch conditionalBranch2 = new ConditionalBranch();
184
185      initializationBranch.ConditionParameter.ActualName = "IsInitialized";
186
187      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // this variable is referenced in SASEGASAMainLoop, do not change!
188      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", 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>("EvaluatedSolutionsResult", new IntValue(0)));
192      variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("IsInitialized", new BoolValue(true)));
193
194      variableAssigner.LeftSideParameter.ActualName = "ComparisonFactor"; // this variable is referenced in SASEGASA, OffspringSelectionGeneticAlgorithm, do not change!
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<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
232      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
233      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
234      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
235      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
236      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
237      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
238      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult"));
239      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Curent Comparison Factor", null, "ComparisonFactor"));
240      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
241      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
242      resultsCollector.CollectedValues.Add(new LookupParameter<IItem>("Solution Visualization", null, VisualizationParameter.Name));
243      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities"));
244      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("SelectionPressures"));
245      resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
246
247      selector.Name = "Selector (placeholder)";
248      selector.OperatorParameter.ActualName = SelectorParameter.Name;
249
250      childrenCreator.ParentsPerChild = new IntValue(2);
251
252      crossover.Name = "Crossover (placeholder)";
253      crossover.OperatorParameter.ActualName = CrossoverParameter.Name;
254
255      osBeforeMutationBranch.Name = "Apply OS before mutation?";
256      osBeforeMutationBranch.ConditionParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
257
258      evaluator1.Name = "Evaluator (placeholder)";
259      evaluator1.OperatorParameter.ActualName = EvaluatorParameter.Name;
260
261      evaluationCounter1.Name = "EvaluatedSolutions++";
262      evaluationCounter1.Increment = new IntValue(1);
263      evaluationCounter1.ValueParameter.ActualName = "EvaluatedSolutions";
264
265      qualityComparer1.ComparisonFactorParameter.ActualName = "ComparisonFactor";
266      qualityComparer1.LeftSideParameter.ActualName = QualityParameter.Name;
267      qualityComparer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
268      qualityComparer1.RightSideParameter.ActualName = QualityParameter.Name;
269      qualityComparer1.ResultParameter.ActualName = "SuccessfulOffspring";
270
271      mutationBranch1.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
272      mutationBranch1.RandomParameter.ActualName = RandomParameter.Name;
273
274      mutator1.Name = "Mutator (placeholder)";
275      mutator1.OperatorParameter.ActualName = MutatorParameter.Name;
276
277      evaluator2.Name = "Evaluator (placeholder)";
278      evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;
279
280      evaluationCounter2.Name = "EvaluatedSolutions++";
281      evaluationCounter2.Increment = new IntValue(1);
282      evaluationCounter2.ValueParameter.ActualName = "EvaluatedSolutions";
283
284      mutationBranch2.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
285      mutationBranch2.RandomParameter.ActualName = RandomParameter.Name;
286
287      mutator2.Name = "Mutator (placeholder)";
288      mutator2.OperatorParameter.ActualName = MutatorParameter.Name;
289
290      evaluator3.Name = "Evaluator (placeholder)";
291      evaluator3.OperatorParameter.ActualName = EvaluatorParameter.Name;
292
293      evaluationCounter3.Name = "EvaluatedSolutions++";
294      evaluationCounter3.Increment = new IntValue(1);
295      evaluationCounter3.ValueParameter.ActualName = "EvaluatedSolutions";
296
297      qualityComparer2.ComparisonFactorParameter.ActualName = "ComparisonFactor";
298      qualityComparer2.LeftSideParameter.ActualName = QualityParameter.Name;
299      qualityComparer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
300      qualityComparer2.RightSideParameter.ActualName = QualityParameter.Name;
301      qualityComparer2.ResultParameter.ActualName = "SuccessfulOffspring";
302
303      subScopesRemover.RemoveAllSubScopes = true;
304
305      conditionalSelector.CopySelected = new BoolValue(false);
306      conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring";
307
308      offspringSelector.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
309      offspringSelector.LuckyLosersParameter.ActualName = "OSLuckyLosers";
310      offspringSelector.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.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"; // this variable is referenced in SASEGASAMainLoop, do not change!
380      #endregion
381
382      #region Create operator graph
383      OperatorGraph.InitialOperator = initializationBranch;
384      initializationBranch.FalseBranch = variableCreator;
385      initializationBranch.Successor = selector;
386      variableCreator.Successor = variableAssigner;
387      variableAssigner.Successor = bestQualityMemorizer1;
388      bestQualityMemorizer1.Successor = bestQualityMemorizer2;
389      bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1;
390      bestAverageWorstQualityCalculator1.Successor = dataTableValuesCollector1;
391      dataTableValuesCollector1.Successor = selPressDataTableValuesCollector1;
392      selPressDataTableValuesCollector1.Successor = qualityDifferenceCalculator1;
393      qualityDifferenceCalculator1.Successor = visualizer1;
394      visualizer1.Successor = resultsCollector;
395      resultsCollector.Successor = null;
396      selector.Successor = subScopesProcessor1;
397      subScopesProcessor1.Operators.Add(new EmptyOperator());
398      subScopesProcessor1.Operators.Add(childrenCreator);
399      subScopesProcessor1.Successor = offspringSelector;
400      childrenCreator.Successor = uniformSubScopesProcessor;
401      uniformSubScopesProcessor.Operator = crossover;
402      uniformSubScopesProcessor.Successor = conditionalSelector;
403      crossover.Successor = osBeforeMutationBranch;
404      osBeforeMutationBranch.TrueBranch = evaluator1;
405      osBeforeMutationBranch.FalseBranch = mutationBranch2;
406      osBeforeMutationBranch.Successor = subScopesRemover;
407      evaluator1.Successor = evaluationCounter1;
408      evaluationCounter1.Successor = qualityComparer1;
409      qualityComparer1.Successor = mutationBranch1;
410      mutationBranch1.FirstBranch = mutator1;
411      mutationBranch1.SecondBranch = null;
412      mutationBranch1.Successor = null;
413      mutator1.Successor = evaluator2;
414      evaluator2.Successor = evaluationCounter2;
415      evaluationCounter2.Successor = null;
416      mutationBranch2.FirstBranch = mutator2;
417      mutationBranch2.SecondBranch = null;
418      mutationBranch2.Successor = evaluator3;
419      mutator2.Successor = null;
420      evaluator3.Successor = evaluationCounter3;
421      evaluationCounter3.Successor = qualityComparer2;
422      subScopesRemover.Successor = null;
423      offspringSelector.OffspringCreator = selector;
424      offspringSelector.Successor = subScopesProcessor2;
425      subScopesProcessor2.Operators.Add(bestSelector);
426      subScopesProcessor2.Operators.Add(new EmptyOperator());
427      subScopesProcessor2.Successor = mergingReducer;
428      bestSelector.Successor = rightReducer;
429      rightReducer.Successor = null;
430      mergingReducer.Successor = intCounter;
431      intCounter.Successor = comparisonFactorModifier;
432      comparisonFactorModifier.Successor = comparator1;
433      comparator1.Successor = comparator2;
434      comparator2.Successor = evaluatedSolutionsAssigner;
435      evaluatedSolutionsAssigner.Successor = evalSolCollector;
436      evalSolCollector.Successor = bestQualityMemorizer3;
437      bestQualityMemorizer3.Successor = bestQualityMemorizer4;
438      bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2;
439      bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector2;
440      dataTableValuesCollector2.Successor = selPressDataTableValuesCollector2;
441      selPressDataTableValuesCollector2.Successor = qualityDifferenceCalculator2;
442      qualityDifferenceCalculator2.Successor = visualizer2;
443      visualizer2.Successor = conditionalBranch1;
444      conditionalBranch1.FalseBranch = conditionalBranch2;
445      conditionalBranch1.TrueBranch = null;
446      conditionalBranch1.Successor = null;
447      conditionalBranch2.FalseBranch = selector;
448      conditionalBranch2.TrueBranch = null;
449      conditionalBranch2.Successor = null;
450      #endregion
451    }
452  }
453}
Note: See TracBrowser for help on using the repository browser.