source: trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithmMainLoop.cs @ 3615

Last change on this file since 3615 was 3615, checked in by abeham, 12 years ago

updated SASEGASA: removed mainloop
fixed a bug in the island OSGA regarding evaluated solutions
#839

File size: 41.0 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 System;
23using System.Collections.Generic;
24using System.Linq;
25using HeuristicLab.Analysis;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Data;
29using HeuristicLab.Operators;
30using HeuristicLab.Optimization;
31using HeuristicLab.Optimization.Operators;
32using HeuristicLab.Parameters;
33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
34using HeuristicLab.PluginInfrastructure;
35using HeuristicLab.Selection;
36
37namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm {
38  /// <summary>
39  /// An island offspring selection genetic algorithm main loop operator.
40  /// </summary>
41  [Item("IslandOffspringSelectionGeneticAlgorithmMainLoop", "An island offspring selection genetic algorithm main loop operator.")]
42  [StorableClass]
43  public sealed class IslandOffspringSelectionGeneticAlgorithmMainLoop : AlgorithmOperator {
44    #region Parameter Properties
45    public ValueLookupParameter<IRandom> RandomParameter {
46      get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
47    }
48    public ValueLookupParameter<BoolValue> MaximizationParameter {
49      get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
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<IntValue> NumberOfIslandsParameter {
58      get { return (ValueLookupParameter<IntValue>)Parameters["NumberOfIslands"]; }
59    }
60    public ValueLookupParameter<IntValue> MigrationIntervalParameter {
61      get { return (ValueLookupParameter<IntValue>)Parameters["MigrationInterval"]; }
62    }
63    public ValueLookupParameter<PercentValue> MigrationRateParameter {
64      get { return (ValueLookupParameter<PercentValue>)Parameters["MigrationRate"]; }
65    }
66    public ValueLookupParameter<IOperator> MigratorParameter {
67      get { return (ValueLookupParameter<IOperator>)Parameters["Migrator"]; }
68    }
69    public ValueLookupParameter<IOperator> EmigrantsSelectorParameter {
70      get { return (ValueLookupParameter<IOperator>)Parameters["EmigrantsSelector"]; }
71    }
72    public ValueLookupParameter<IOperator> ImmigrationReplacerParameter {
73      get { return (ValueLookupParameter<IOperator>)Parameters["ImmigrationReplacer"]; }
74    }
75    public ValueLookupParameter<IntValue> PopulationSizeParameter {
76      get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; }
77    }
78    public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
79      get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
80    }
81    public ValueLookupParameter<IOperator> SelectorParameter {
82      get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
83    }
84    public ValueLookupParameter<IOperator> CrossoverParameter {
85      get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
86    }
87    public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
88      get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
89    }
90    public ValueLookupParameter<IOperator> MutatorParameter {
91      get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
92    }
93    public ValueLookupParameter<IOperator> EvaluatorParameter {
94      get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
95    }
96    public ValueLookupParameter<IntValue> ElitesParameter {
97      get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
98    }
99    public ValueLookupParameter<ResultCollection> ResultsParameter {
100      get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
101    }
102    public ValueLookupParameter<IOperator> VisualizerParameter {
103      get { return (ValueLookupParameter<IOperator>)Parameters["Visualizer"]; }
104    }
105    public LookupParameter<IItem> VisualizationParameter {
106      get { return (LookupParameter<IItem>)Parameters["Visualization"]; }
107    }
108    public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
109      get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
110    }
111    public LookupParameter<DoubleValue> ComparisonFactorParameter {
112      get { return (LookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
113    }
114    public ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
115      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorLowerBound"]; }
116    }
117    public ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
118      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorUpperBound"]; }
119    }
120    public ValueLookupParameter<IOperator> ComparisonFactorModifierParameter {
121      get { return (ValueLookupParameter<IOperator>)Parameters["ComparisonFactorModifier"]; }
122    }
123    public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
124      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
125    }
126    public ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
127      get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
128    }
129    #endregion
130
131    [StorableConstructor]
132    private IslandOffspringSelectionGeneticAlgorithmMainLoop(bool deserializing) : base() { }
133    public IslandOffspringSelectionGeneticAlgorithmMainLoop()
134      : base() {
135      #region Create parameters
136      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
137      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
138      Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
139      Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
140      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfIslands", "The number of islands."));
141      Parameters.Add(new ValueLookupParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases."));
142      Parameters.Add(new ValueLookupParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands."));
143      Parameters.Add(new ValueLookupParameter<IOperator>("Migrator", "The migration strategy."));
144      Parameters.Add(new ValueLookupParameter<IOperator>("EmigrantsSelector", "Selects the individuals that will be migrated."));
145      Parameters.Add(new ValueLookupParameter<IOperator>("ImmigrationReplacer", "Replaces part of the original population with the immigrants."));
146      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population of solutions."));
147      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed."));
148      Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
149      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
150      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
151      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
152      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
153      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
154      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results."));
155      Parameters.Add(new ValueLookupParameter<IOperator>("Visualizer", "The operator used to visualize solutions."));
156      Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions."));
157      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
158      Parameters.Add(new LookupParameter<DoubleValue>("ComparisonFactor", "The comparison factor is used to determine whether the offspring should be compared to the better parent, the worse parent or a quality value linearly interpolated between them. It is in the range [0;1]."));
159      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start)."));
160      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end)."));
161      Parameters.Add(new ValueLookupParameter<IOperator>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));
162      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
163      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."));
164      #endregion
165
166      #region Create operators
167      VariableCreator variableCreator = new VariableCreator();
168      UniformSubScopesProcessor uniformSubScopesProcessor0 = new UniformSubScopesProcessor();
169      VariableCreator islandVariableCreator = new VariableCreator();
170      BestQualityMemorizer islandBestQualityMemorizer1 = new BestQualityMemorizer();
171      BestAverageWorstQualityCalculator islandBestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();
172      DataTableValuesCollector islandDataTableValuesCollector1 = new DataTableValuesCollector();
173      DataTableValuesCollector islandDataTableValuesCollector2 = new DataTableValuesCollector();
174      QualityDifferenceCalculator islandQualityDifferenceCalculator1 = new QualityDifferenceCalculator();
175      Placeholder islandVisualizer1 = new Placeholder();
176      ResultsCollector islandResultsCollector = new ResultsCollector();
177      BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer();
178      BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer();
179      BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();
180      DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector();
181      DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector();
182      QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator();
183      ResultsCollector resultsCollector = new ResultsCollector();
184      Placeholder comparisonFactorModifier = new Placeholder();
185      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
186      ConditionalBranch islandTerminatedBySelectionPressure1 = new ConditionalBranch();
187      OffspringSelectionGeneticAlgorithmMainOperator mainOperator = new OffspringSelectionGeneticAlgorithmMainOperator();
188      BestQualityMemorizer islandBestQualityMemorizer2 = new BestQualityMemorizer();
189      BestAverageWorstQualityCalculator islandBestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
190      DataTableValuesCollector islandDataTableValuesCollector3 = new DataTableValuesCollector();
191      DataTableValuesCollector islandDataTableValuesCollector4 = new DataTableValuesCollector();
192      QualityDifferenceCalculator islandQualityDifferenceCalculator2 = new QualityDifferenceCalculator();
193      Placeholder islandVisualizer2 = new Placeholder();
194      IntCounter islandEvaluatedSolutionsCounter = new IntCounter();
195      Assigner islandEvaluatedSolutionsAssigner = new Assigner();
196      Comparator islandSelectionPressureComparator = new Comparator();
197      ConditionalBranch islandTerminatedBySelectionPressure2 = new ConditionalBranch();
198      IntCounter terminatedIslandsCounter = new IntCounter();
199      IntCounter generationsCounter = new IntCounter();
200      IntCounter generationsSinceLastMigrationCounter = new IntCounter();
201      Comparator migrationComparator = new Comparator();
202      ConditionalBranch migrationBranch = new ConditionalBranch();
203      Assigner resetTerminatedIslandsAssigner = new Assigner();
204      Assigner resetGenerationsSinceLastMigrationAssigner = new Assigner();
205      IntCounter migrationsCounter = new IntCounter();
206      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
207      Assigner reviveIslandAssigner = new Assigner();
208      Placeholder emigrantsSelector = new Placeholder();
209      Placeholder migrator = new Placeholder();
210      UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
211      Placeholder immigrationReplacer = new Placeholder();
212      Comparator generationsComparator = new Comparator();
213      Comparator terminatedIslandsComparator = new Comparator();
214      BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer();
215      BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer();
216      BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
217      DataTableValuesCollector dataTableValuesCollector3 = new DataTableValuesCollector();
218      DataTableValuesCollector dataTableValuesCollector4 = new DataTableValuesCollector();
219      QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
220      ConditionalBranch generationsTerminationCondition = new ConditionalBranch();
221      ConditionalBranch terminatedIslandsCondition = new ConditionalBranch();
222
223      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Migrations", new IntValue(0)));
224      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
225      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastMigration", new IntValue(0)));
226      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("TerminatedIslands", new IntValue(0)));
227      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
228
229      islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("IslandResults", new ResultCollection()));
230      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandEvaluatedSolutions", new IntValue(0)));
231      islandVariableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("TerminateSelectionPressure", new BoolValue(false)));
232      islandVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
233
234      islandBestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
235      islandBestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
236      islandBestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name;
237
238      islandBestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageQuality";
239      islandBestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestQuality";
240      islandBestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;
241      islandBestAverageWorstQualityCalculator1.QualityParameter.ActualName = QualityParameter.Name;
242      islandBestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstQuality";
243     
244      islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
245      islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
246      islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
247      islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
248      islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
249      islandDataTableValuesCollector1.DataTableParameter.ActualName = "BestQualities";
250
251      islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure"));
252      islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
253      islandDataTableValuesCollector2.DataTableParameter.ActualName = "SelectionPressures";
254
255      islandQualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
256      islandQualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
257      islandQualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
258      islandQualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";
259
260      islandResultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
261      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
262      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
263      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
264      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
265      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
266      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
267      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
268      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Curent Comparison Factor", null, "ComparisonFactor"));
269      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
270      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
271      islandResultsCollector.CollectedValues.Add(new LookupParameter<IItem>("Solution Visualization", null, VisualizationParameter.Name));
272      islandResultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities"));
273      islandResultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("SelectionPressures"));
274      islandResultsCollector.ResultsParameter.ActualName = "IslandResults";
275
276      bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
277      bestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
278      bestQualityMemorizer1.QualityParameter.ActualName = "BestQuality";
279
280      bestQualityMemorizer2.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
281      bestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
282      bestQualityMemorizer2.QualityParameter.ActualName = "BestQuality";
283
284      bestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageBestQuality";
285      bestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestBestQuality";
286      bestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;
287      bestAverageWorstQualityCalculator1.QualityParameter.ActualName = "CurrentBestQuality";
288      bestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstBestQuality";
289
290      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
291      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
292      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
293      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
294      dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
295      dataTableValuesCollector1.DataTableParameter.ActualName = "BestQualities";
296
297      dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
298      dataTableValuesCollector2.CollectedValues.Add(new SubScopesLookupParameter<DoubleValue>("Selection Pressure Island", null, "SelectionPressure"));
299      dataTableValuesCollector2.DataTableParameter.ActualName = "SelectionPressures";
300
301      qualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
302      qualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
303      qualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
304      qualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";
305
306      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Migrations"));
307      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
308      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions"));
309      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
310      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
311      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
312      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
313      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
314      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
315      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
316      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("BestQualities"));
317      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("SelectionPressures"));
318      resultsCollector.CollectedValues.Add(new SubScopesLookupParameter<ResultCollection>("IslandResults", "Result set for each island"));
319      resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
320
321      comparisonFactorModifier.Name = "ComparisonFactorModifier (Placeholder)";
322      comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
323
324      islandTerminatedBySelectionPressure1.Name = "Island Terminated ?";
325      islandTerminatedBySelectionPressure1.ConditionParameter.ActualName = "TerminateSelectionPressure";
326
327      mainOperator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
328      mainOperator.CrossoverParameter.ActualName = CrossoverParameter.Name;
329      mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
330      mainOperator.ElitesParameter.ActualName = ElitesParameter.Name;
331      mainOperator.EvaluatedSolutionsParameter.ActualName = "IslandEvaluatedSolutions";
332      mainOperator.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
333      mainOperator.MaximizationParameter.ActualName = MaximizationParameter.Name;
334      mainOperator.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
335      mainOperator.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
336      mainOperator.MutatorParameter.ActualName = MutatorParameter.Name;
337      mainOperator.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
338      mainOperator.QualityParameter.ActualName = QualityParameter.Name;
339      mainOperator.RandomParameter.ActualName = RandomParameter.Name;
340      mainOperator.SelectionPressureParameter.ActualName = "SelectionPressure";
341      mainOperator.SelectorParameter.ActualName = SelectorParameter.Name;
342      mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
343
344      islandBestQualityMemorizer2.BestQualityParameter.ActualName = "BestQuality";
345      islandBestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
346      islandBestQualityMemorizer2.QualityParameter.ActualName = QualityParameter.Name;
347
348      islandBestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageQuality";
349      islandBestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestQuality";
350      islandBestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name;
351      islandBestAverageWorstQualityCalculator2.QualityParameter.ActualName = QualityParameter.Name;
352      islandBestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstQuality";
353
354      islandDataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
355      islandDataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
356      islandDataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
357      islandDataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
358      islandDataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
359      islandDataTableValuesCollector3.DataTableParameter.ActualName = "BestQualities";
360
361      islandDataTableValuesCollector4.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure"));
362      islandDataTableValuesCollector4.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
363      islandDataTableValuesCollector4.DataTableParameter.ActualName = "SelectionPressures";
364
365      islandQualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
366      islandQualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
367      islandQualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
368      islandQualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
369
370      islandEvaluatedSolutionsCounter.Name = "Update EvaluatedSolutions";
371      islandEvaluatedSolutionsCounter.ValueParameter.ActualName = "EvaluatedSolutions";
372      islandEvaluatedSolutionsCounter.Increment = null;
373      islandEvaluatedSolutionsCounter.IncrementParameter.ActualName = "IslandEvaluatedSolutions";
374
375      islandEvaluatedSolutionsAssigner.Name = "Reset EvaluatedSolutions";
376      islandEvaluatedSolutionsAssigner.LeftSideParameter.ActualName = "IslandEvaluatedSolutions";
377      islandEvaluatedSolutionsAssigner.RightSideParameter.Value = new IntValue(0);
378
379      islandSelectionPressureComparator.Name = "SelectionPressure >= MaximumSelectionPressure ?";
380      islandSelectionPressureComparator.LeftSideParameter.ActualName = "SelectionPressure";
381      islandSelectionPressureComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
382      islandSelectionPressureComparator.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
383      islandSelectionPressureComparator.ResultParameter.ActualName = "TerminateSelectionPressure";
384
385      islandTerminatedBySelectionPressure2.Name = "Island Terminated ?";
386      islandTerminatedBySelectionPressure2.ConditionParameter.ActualName = "TerminateSelectionPressure";
387
388      terminatedIslandsCounter.Name = "TerminatedIslands + 1";
389      terminatedIslandsCounter.ValueParameter.ActualName = "TerminatedIslands";
390      terminatedIslandsCounter.Increment = new IntValue(1);
391
392      generationsCounter.Name = "Generations + 1";
393      generationsCounter.ValueParameter.ActualName = "Generations";
394      generationsCounter.Increment = new IntValue(1);
395
396      generationsSinceLastMigrationCounter.Name = "GenerationsSinceLastMigration + 1";
397      generationsSinceLastMigrationCounter.ValueParameter.ActualName = "GenerationsSinceLastMigration";
398      generationsSinceLastMigrationCounter.Increment = new IntValue(1);
399
400      migrationComparator.Name = "GenerationsSinceLastMigration = MigrationInterval ?";
401      migrationComparator.LeftSideParameter.ActualName = "GenerationsSinceLastMigration";
402      migrationComparator.Comparison = new Comparison(ComparisonType.Equal);
403      migrationComparator.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
404      migrationComparator.ResultParameter.ActualName = "Migrate";
405
406      migrationBranch.Name = "Migrate?";
407      migrationBranch.ConditionParameter.ActualName = "Migrate";
408
409      resetTerminatedIslandsAssigner.Name = "Reset TerminatedIslands";
410      resetTerminatedIslandsAssigner.LeftSideParameter.ActualName = "TerminatedIslands";
411      resetTerminatedIslandsAssigner.RightSideParameter.Value = new IntValue(0);
412
413      resetGenerationsSinceLastMigrationAssigner.Name = "Reset GenerationsSinceLastMigration";
414      resetGenerationsSinceLastMigrationAssigner.LeftSideParameter.ActualName = "GenerationsSinceLastMigration";
415      resetGenerationsSinceLastMigrationAssigner.RightSideParameter.Value = new IntValue(0);
416
417      migrationsCounter.Name = "Migrations + 1";
418      migrationsCounter.IncrementParameter.Value = new IntValue(1);
419      migrationsCounter.ValueParameter.ActualName = "Migrations";
420
421      reviveIslandAssigner.Name = "Revive Island";
422      reviveIslandAssigner.LeftSideParameter.ActualName = "TerminateSelectionPressure";
423      reviveIslandAssigner.RightSideParameter.Value = new BoolValue(false);
424
425      emigrantsSelector.Name = "Emigrants Selector (placeholder)";
426      emigrantsSelector.OperatorParameter.ActualName = EmigrantsSelectorParameter.Name;
427
428      migrator.Name = "Migrator (placeholder)";
429      migrator.OperatorParameter.ActualName = MigratorParameter.Name;
430
431      immigrationReplacer.Name = "Immigration Replacer (placeholder)";
432      immigrationReplacer.OperatorParameter.ActualName = ImmigrationReplacerParameter.Name;
433
434      generationsComparator.Name = "Generations >= MaximumGenerations ?";
435      generationsComparator.LeftSideParameter.ActualName = "Generations";
436      generationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
437      generationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
438      generationsComparator.ResultParameter.ActualName = "TerminateGenerations";
439
440      terminatedIslandsComparator.Name = "All Islands terminated ?";
441      terminatedIslandsComparator.LeftSideParameter.ActualName = "TerminatedIslands";
442      terminatedIslandsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
443      terminatedIslandsComparator.RightSideParameter.ActualName = NumberOfIslandsParameter.Name;
444      terminatedIslandsComparator.ResultParameter.ActualName = "TerminateTerminatedIslands";
445     
446      bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality";
447      bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name;
448      bestQualityMemorizer3.QualityParameter.ActualName = "BestQuality";
449
450      bestQualityMemorizer4.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
451      bestQualityMemorizer4.MaximizationParameter.ActualName = MaximizationParameter.Name;
452      bestQualityMemorizer4.QualityParameter.ActualName = "BestQuality";
453
454      bestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageBestQuality";
455      bestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestBestQuality";
456      bestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name;
457      bestAverageWorstQualityCalculator2.QualityParameter.ActualName = "CurrentBestQuality";
458      bestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstBestQuality";
459
460      dataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
461      dataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
462      dataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
463      dataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
464      dataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
465      dataTableValuesCollector3.DataTableParameter.ActualName = "BestQualities";
466
467      dataTableValuesCollector4.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
468      dataTableValuesCollector4.CollectedValues.Add(new SubScopesLookupParameter<DoubleValue>("Selection Pressure Island", null, "SelectionPressure"));
469      dataTableValuesCollector4.DataTableParameter.ActualName = "SelectionPressures";
470
471      qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
472      qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
473      qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
474      qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
475
476      generationsTerminationCondition.Name = "Terminate (MaxGenerations) ?";
477      generationsTerminationCondition.ConditionParameter.ActualName = "TerminateGenerations";
478
479      terminatedIslandsCondition.Name = "Terminate (TerminatedIslands) ?";
480      terminatedIslandsCondition.ConditionParameter.ActualName = "TerminateTerminatedIslands";
481      #endregion
482
483      #region Create operator graph
484      OperatorGraph.InitialOperator = variableCreator;
485      variableCreator.Successor = uniformSubScopesProcessor0;
486      uniformSubScopesProcessor0.Operator = islandVariableCreator;
487      uniformSubScopesProcessor0.Successor = bestQualityMemorizer1;
488      islandVariableCreator.Successor = islandBestQualityMemorizer1;
489      islandBestQualityMemorizer1.Successor = islandBestAverageWorstQualityCalculator1;
490      islandBestAverageWorstQualityCalculator1.Successor = islandDataTableValuesCollector1;
491      islandDataTableValuesCollector1.Successor = islandDataTableValuesCollector2;
492      islandDataTableValuesCollector2.Successor = islandQualityDifferenceCalculator1;
493      islandQualityDifferenceCalculator1.Successor = islandVisualizer1;
494      islandVisualizer1.Successor = islandResultsCollector;
495      islandResultsCollector.Successor = null;
496      bestQualityMemorizer1.Successor = bestQualityMemorizer2;
497      bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1;
498      bestAverageWorstQualityCalculator1.Successor = dataTableValuesCollector1;
499      dataTableValuesCollector1.Successor = dataTableValuesCollector2;
500      dataTableValuesCollector2.Successor = qualityDifferenceCalculator1;
501      qualityDifferenceCalculator1.Successor = resultsCollector;
502      resultsCollector.Successor = comparisonFactorModifier;
503      comparisonFactorModifier.Successor = uniformSubScopesProcessor1;
504      uniformSubScopesProcessor1.Operator = islandTerminatedBySelectionPressure1;
505      uniformSubScopesProcessor1.Successor = generationsCounter;
506      islandTerminatedBySelectionPressure1.TrueBranch = null;
507      islandTerminatedBySelectionPressure1.FalseBranch = mainOperator;
508      islandTerminatedBySelectionPressure1.Successor = null;
509      mainOperator.Successor = islandBestQualityMemorizer2;
510      islandBestQualityMemorizer2.Successor = islandBestAverageWorstQualityCalculator2;
511      islandBestAverageWorstQualityCalculator2.Successor = islandDataTableValuesCollector3;
512      islandDataTableValuesCollector3.Successor = islandDataTableValuesCollector4;
513      islandDataTableValuesCollector4.Successor = islandQualityDifferenceCalculator2;
514      islandQualityDifferenceCalculator2.Successor = islandVisualizer2;
515      islandVisualizer2.Successor = islandEvaluatedSolutionsCounter;
516      islandEvaluatedSolutionsCounter.Successor = islandEvaluatedSolutionsAssigner;
517      islandEvaluatedSolutionsAssigner.Successor = islandSelectionPressureComparator;
518      islandSelectionPressureComparator.Successor = islandTerminatedBySelectionPressure2;
519      islandTerminatedBySelectionPressure2.TrueBranch = terminatedIslandsCounter;
520      islandTerminatedBySelectionPressure2.FalseBranch = null;
521      islandTerminatedBySelectionPressure2.Successor = null;
522      generationsCounter.Successor = generationsSinceLastMigrationCounter;
523      generationsSinceLastMigrationCounter.Successor = migrationComparator;
524      migrationComparator.Successor = migrationBranch;
525      migrationBranch.TrueBranch = resetTerminatedIslandsAssigner;
526      migrationBranch.FalseBranch = null;
527      migrationBranch.Successor = generationsComparator;
528      resetTerminatedIslandsAssigner.Successor = resetGenerationsSinceLastMigrationAssigner;
529      resetGenerationsSinceLastMigrationAssigner.Successor = migrationsCounter;
530      migrationsCounter.Successor = uniformSubScopesProcessor2;
531      uniformSubScopesProcessor2.Operator = reviveIslandAssigner;
532      uniformSubScopesProcessor2.Successor = migrator;
533      reviveIslandAssigner.Successor = emigrantsSelector;
534      emigrantsSelector.Successor = null;
535      migrator.Successor = uniformSubScopesProcessor3;
536      uniformSubScopesProcessor3.Operator = immigrationReplacer;
537      uniformSubScopesProcessor3.Successor = null;
538      immigrationReplacer.Successor = null;
539      generationsComparator.Successor = terminatedIslandsComparator;
540      terminatedIslandsComparator.Successor = bestQualityMemorizer3;
541      bestQualityMemorizer3.Successor = bestQualityMemorizer4;
542      bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2;
543      bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector3;
544      dataTableValuesCollector3.Successor = dataTableValuesCollector4;
545      dataTableValuesCollector4.Successor = qualityDifferenceCalculator2;
546      qualityDifferenceCalculator2.Successor = generationsTerminationCondition;
547      generationsTerminationCondition.TrueBranch = null;
548      generationsTerminationCondition.FalseBranch = terminatedIslandsCondition;
549      generationsTerminationCondition.Successor = null;
550      terminatedIslandsCondition.TrueBranch = null;
551      terminatedIslandsCondition.FalseBranch = comparisonFactorModifier;
552      terminatedIslandsCondition.Successor = null;
553      #endregion
554    }
555  }
556}
Note: See TracBrowser for help on using the repository browser.