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

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

Changed Island OSGA #976

  • removed mainloop
  • added mainoperator
File size: 40.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using 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      Comparator islandSelectionPressureComparator = new Comparator();
196      ConditionalBranch islandTerminatedBySelectionPressure2 = new ConditionalBranch();
197      IntCounter terminatedIslandsCounter = new IntCounter();
198      IntCounter generationsCounter = new IntCounter();
199      IntCounter generationsSinceLastMigrationCounter = new IntCounter();
200      Comparator migrationComparator = new Comparator();
201      ConditionalBranch migrationBranch = new ConditionalBranch();
202      Assigner resetTerminatedIslandsAssigner = new Assigner();
203      Assigner resetGenerationsSinceLastMigrationAssigner = new Assigner();
204      IntCounter migrationsCounter = new IntCounter();
205      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
206      Assigner reviveIslandAssigner = new Assigner();
207      Placeholder emigrantsSelector = new Placeholder();
208      Placeholder migrator = new Placeholder();
209      UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
210      Placeholder immigrationReplacer = new Placeholder();
211      Comparator generationsComparator = new Comparator();
212      Comparator terminatedIslandsComparator = new Comparator();
213      BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer();
214      BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer();
215      BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
216      DataTableValuesCollector dataTableValuesCollector3 = new DataTableValuesCollector();
217      DataTableValuesCollector dataTableValuesCollector4 = new DataTableValuesCollector();
218      QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
219      ConditionalBranch generationsTerminationCondition = new ConditionalBranch();
220      ConditionalBranch terminatedIslandsCondition = new ConditionalBranch();
221
222      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Migrations", new IntValue(0)));
223      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
224      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastMigration", new IntValue(0)));
225      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("TerminatedIslands", new IntValue(0)));
226      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
227
228      islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("IslandResults", new ResultCollection()));
229      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandEvaluatedSolutions", new IntValue(0)));
230      islandVariableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("TerminateSelectionPressure", new BoolValue(false)));
231      islandVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
232
233      islandBestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
234      islandBestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
235      islandBestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name;
236
237      islandBestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageQuality";
238      islandBestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestQuality";
239      islandBestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;
240      islandBestAverageWorstQualityCalculator1.QualityParameter.ActualName = QualityParameter.Name;
241      islandBestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstQuality";
242     
243      islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
244      islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
245      islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
246      islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
247      islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
248      islandDataTableValuesCollector1.DataTableParameter.ActualName = "BestQualities";
249
250      islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure"));
251      islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
252      islandDataTableValuesCollector2.DataTableParameter.ActualName = "SelectionPressures";
253
254      islandQualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
255      islandQualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
256      islandQualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
257      islandQualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";
258
259      islandResultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
260      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
261      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
262      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
263      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
264      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
265      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
266      islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
267      islandResultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "IslandEvaluatedSolutions"));
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      islandSelectionPressureComparator.Name = "SelectionPressure >= MaximumSelectionPressure ?";
376      islandSelectionPressureComparator.LeftSideParameter.ActualName = "SelectionPressure";
377      islandSelectionPressureComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
378      islandSelectionPressureComparator.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
379      islandSelectionPressureComparator.ResultParameter.ActualName = "TerminateSelectionPressure";
380
381      islandTerminatedBySelectionPressure2.Name = "Island Terminated ?";
382      islandTerminatedBySelectionPressure2.ConditionParameter.ActualName = "TerminateSelectionPressure";
383
384      terminatedIslandsCounter.Name = "TerminatedIslands + 1";
385      terminatedIslandsCounter.ValueParameter.ActualName = "TerminatedIslands";
386      terminatedIslandsCounter.Increment = new IntValue(1);
387
388      generationsCounter.Name = "Generations + 1";
389      generationsCounter.ValueParameter.ActualName = "Generations";
390      generationsCounter.Increment = new IntValue(1);
391
392      generationsSinceLastMigrationCounter.Name = "GenerationsSinceLastMigration + 1";
393      generationsSinceLastMigrationCounter.ValueParameter.ActualName = "GenerationsSinceLastMigration";
394      generationsSinceLastMigrationCounter.Increment = new IntValue(1);
395
396      migrationComparator.Name = "GenerationsSinceLastMigration = MigrationInterval ?";
397      migrationComparator.LeftSideParameter.ActualName = "GenerationsSinceLastMigration";
398      migrationComparator.Comparison = new Comparison(ComparisonType.Equal);
399      migrationComparator.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
400      migrationComparator.ResultParameter.ActualName = "Migrate";
401
402      migrationBranch.Name = "Migrate?";
403      migrationBranch.ConditionParameter.ActualName = "Migrate";
404
405      resetTerminatedIslandsAssigner.Name = "Reset TerminatedIslands";
406      resetTerminatedIslandsAssigner.LeftSideParameter.ActualName = "TerminatedIslands";
407      resetTerminatedIslandsAssigner.RightSideParameter.Value = new IntValue(0);
408
409      resetGenerationsSinceLastMigrationAssigner.Name = "Reset GenerationsSinceLastMigration";
410      resetGenerationsSinceLastMigrationAssigner.LeftSideParameter.ActualName = "GenerationsSinceLastMigration";
411      resetGenerationsSinceLastMigrationAssigner.RightSideParameter.Value = new IntValue(0);
412
413      migrationsCounter.Name = "Migrations + 1";
414      migrationsCounter.IncrementParameter.Value = new IntValue(1);
415      migrationsCounter.ValueParameter.ActualName = "Migrations";
416
417      reviveIslandAssigner.Name = "Revive Island";
418      reviveIslandAssigner.LeftSideParameter.ActualName = "TerminateSelectionPressure";
419      reviveIslandAssigner.RightSideParameter.Value = new BoolValue(false);
420
421      emigrantsSelector.Name = "Emigrants Selector (placeholder)";
422      emigrantsSelector.OperatorParameter.ActualName = EmigrantsSelectorParameter.Name;
423
424      migrator.Name = "Migrator (placeholder)";
425      migrator.OperatorParameter.ActualName = MigratorParameter.Name;
426
427      immigrationReplacer.Name = "Immigration Replacer (placeholder)";
428      immigrationReplacer.OperatorParameter.ActualName = ImmigrationReplacerParameter.Name;
429
430      generationsComparator.Name = "Generations >= MaximumGenerations ?";
431      generationsComparator.LeftSideParameter.ActualName = "Generations";
432      generationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
433      generationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
434      generationsComparator.ResultParameter.ActualName = "TerminateGenerations";
435
436      terminatedIslandsComparator.Name = "All Islands terminated ?";
437      terminatedIslandsComparator.LeftSideParameter.ActualName = "TerminatedIslands";
438      terminatedIslandsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
439      terminatedIslandsComparator.RightSideParameter.ActualName = NumberOfIslandsParameter.Name;
440      terminatedIslandsComparator.ResultParameter.ActualName = "TerminateTerminatedIslands";
441     
442      bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality";
443      bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name;
444      bestQualityMemorizer3.QualityParameter.ActualName = "BestQuality";
445
446      bestQualityMemorizer4.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
447      bestQualityMemorizer4.MaximizationParameter.ActualName = MaximizationParameter.Name;
448      bestQualityMemorizer4.QualityParameter.ActualName = "BestQuality";
449
450      bestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageBestQuality";
451      bestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestBestQuality";
452      bestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name;
453      bestAverageWorstQualityCalculator2.QualityParameter.ActualName = "CurrentBestQuality";
454      bestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstBestQuality";
455
456      dataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
457      dataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
458      dataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
459      dataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
460      dataTableValuesCollector3.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
461      dataTableValuesCollector3.DataTableParameter.ActualName = "BestQualities";
462
463      dataTableValuesCollector4.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
464      dataTableValuesCollector4.CollectedValues.Add(new SubScopesLookupParameter<DoubleValue>("Selection Pressure Island", null, "SelectionPressure"));
465      dataTableValuesCollector4.DataTableParameter.ActualName = "SelectionPressures";
466
467      qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
468      qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
469      qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
470      qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
471
472      generationsTerminationCondition.Name = "Terminate (MaxGenerations) ?";
473      generationsTerminationCondition.ConditionParameter.ActualName = "TerminateGenerations";
474
475      terminatedIslandsCondition.Name = "Terminate (TerminatedIslands) ?";
476      terminatedIslandsCondition.ConditionParameter.ActualName = "TerminateTerminatedIslands";
477      #endregion
478
479      #region Create operator graph
480      OperatorGraph.InitialOperator = variableCreator;
481      variableCreator.Successor = uniformSubScopesProcessor0;
482      uniformSubScopesProcessor0.Operator = islandVariableCreator;
483      uniformSubScopesProcessor0.Successor = bestQualityMemorizer1;
484      islandVariableCreator.Successor = islandBestQualityMemorizer1;
485      islandBestQualityMemorizer1.Successor = islandBestAverageWorstQualityCalculator1;
486      islandBestAverageWorstQualityCalculator1.Successor = islandDataTableValuesCollector1;
487      islandDataTableValuesCollector1.Successor = islandDataTableValuesCollector2;
488      islandDataTableValuesCollector2.Successor = islandQualityDifferenceCalculator1;
489      islandQualityDifferenceCalculator1.Successor = islandVisualizer1;
490      islandVisualizer1.Successor = islandResultsCollector;
491      islandResultsCollector.Successor = null;
492      bestQualityMemorizer1.Successor = bestQualityMemorizer2;
493      bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1;
494      bestAverageWorstQualityCalculator1.Successor = dataTableValuesCollector1;
495      dataTableValuesCollector1.Successor = dataTableValuesCollector2;
496      dataTableValuesCollector2.Successor = qualityDifferenceCalculator1;
497      qualityDifferenceCalculator1.Successor = resultsCollector;
498      resultsCollector.Successor = comparisonFactorModifier;
499      comparisonFactorModifier.Successor = uniformSubScopesProcessor1;
500      uniformSubScopesProcessor1.Operator = islandTerminatedBySelectionPressure1;
501      uniformSubScopesProcessor1.Successor = generationsCounter;
502      islandTerminatedBySelectionPressure1.TrueBranch = null;
503      islandTerminatedBySelectionPressure1.FalseBranch = mainOperator;
504      islandTerminatedBySelectionPressure1.Successor = null;
505      mainOperator.Successor = islandBestQualityMemorizer2;
506      islandBestQualityMemorizer2.Successor = islandBestAverageWorstQualityCalculator2;
507      islandBestAverageWorstQualityCalculator2.Successor = islandDataTableValuesCollector3;
508      islandDataTableValuesCollector3.Successor = islandDataTableValuesCollector4;
509      islandDataTableValuesCollector4.Successor = islandQualityDifferenceCalculator2;
510      islandQualityDifferenceCalculator2.Successor = islandVisualizer2;
511      islandVisualizer2.Successor = islandEvaluatedSolutionsCounter;
512      islandEvaluatedSolutionsCounter.Successor = islandSelectionPressureComparator;
513      islandSelectionPressureComparator.Successor = islandTerminatedBySelectionPressure2;
514      islandTerminatedBySelectionPressure2.TrueBranch = terminatedIslandsCounter;
515      islandTerminatedBySelectionPressure2.FalseBranch = null;
516      islandTerminatedBySelectionPressure2.Successor = null;
517      generationsCounter.Successor = generationsSinceLastMigrationCounter;
518      generationsSinceLastMigrationCounter.Successor = migrationComparator;
519      migrationComparator.Successor = migrationBranch;
520      migrationBranch.TrueBranch = resetTerminatedIslandsAssigner;
521      migrationBranch.FalseBranch = null;
522      migrationBranch.Successor = generationsComparator;
523      resetTerminatedIslandsAssigner.Successor = resetGenerationsSinceLastMigrationAssigner;
524      resetGenerationsSinceLastMigrationAssigner.Successor = migrationsCounter;
525      migrationsCounter.Successor = uniformSubScopesProcessor2;
526      uniformSubScopesProcessor2.Operator = reviveIslandAssigner;
527      uniformSubScopesProcessor2.Successor = migrator;
528      reviveIslandAssigner.Successor = emigrantsSelector;
529      emigrantsSelector.Successor = null;
530      migrator.Successor = uniformSubScopesProcessor3;
531      uniformSubScopesProcessor3.Operator = immigrationReplacer;
532      uniformSubScopesProcessor3.Successor = null;
533      immigrationReplacer.Successor = null;
534      generationsComparator.Successor = terminatedIslandsComparator;
535      terminatedIslandsComparator.Successor = bestQualityMemorizer3;
536      bestQualityMemorizer3.Successor = bestQualityMemorizer4;
537      bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2;
538      bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector3;
539      dataTableValuesCollector3.Successor = dataTableValuesCollector4;
540      dataTableValuesCollector4.Successor = qualityDifferenceCalculator2;
541      qualityDifferenceCalculator2.Successor = generationsTerminationCondition;
542      generationsTerminationCondition.TrueBranch = null;
543      generationsTerminationCondition.FalseBranch = terminatedIslandsCondition;
544      generationsTerminationCondition.Successor = null;
545      terminatedIslandsCondition.TrueBranch = null;
546      terminatedIslandsCondition.FalseBranch = comparisonFactorModifier;
547      terminatedIslandsCondition.Successor = null;
548      #endregion
549    }
550  }
551}
Note: See TracBrowser for help on using the repository browser.