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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using HeuristicLab.Analysis;
|
---|
26 | using HeuristicLab.Common;
|
---|
27 | using HeuristicLab.Core;
|
---|
28 | using HeuristicLab.Data;
|
---|
29 | using HeuristicLab.Operators;
|
---|
30 | using HeuristicLab.Optimization;
|
---|
31 | using HeuristicLab.Optimization.Operators;
|
---|
32 | using HeuristicLab.Parameters;
|
---|
33 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
34 | using HeuristicLab.PluginInfrastructure;
|
---|
35 | using HeuristicLab.Selection;
|
---|
36 |
|
---|
37 | namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm {
|
---|
38 | /// <summary>
|
---|
39 | /// A SASEGASA main loop operator.
|
---|
40 | /// </summary>
|
---|
41 | [Item("SASEGASAMainLoop", "A SASEGASA main loop operator.")]
|
---|
42 | [StorableClass]
|
---|
43 | public sealed class SASEGASAMainLoop : AlgorithmOperator {
|
---|
44 | #region Parameter Properties
|
---|
45 | public ValueLookupParameter<IRandom> RandomParameter {
|
---|
46 | get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
|
---|
47 | }
|
---|
48 | public ValueLookupParameter<IntValue> NumberOfVillagesParameter {
|
---|
49 | get { return (ValueLookupParameter<IntValue>)Parameters["NumberOfVillages"]; }
|
---|
50 | }
|
---|
51 | public ValueLookupParameter<IntValue> MigrationIntervalParameter {
|
---|
52 | get { return (ValueLookupParameter<IntValue>)Parameters["MigrationInterval"]; }
|
---|
53 | }
|
---|
54 | public ValueLookupParameter<BoolValue> MaximizationParameter {
|
---|
55 | get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
|
---|
56 | }
|
---|
57 | public SubScopesLookupParameter<DoubleValue> QualityParameter {
|
---|
58 | get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; }
|
---|
59 | }
|
---|
60 | public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
|
---|
61 | get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
|
---|
62 | }
|
---|
63 | public ValueLookupParameter<IOperator> SelectorParameter {
|
---|
64 | get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
|
---|
65 | }
|
---|
66 | public ValueLookupParameter<IOperator> CrossoverParameter {
|
---|
67 | get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
|
---|
68 | }
|
---|
69 | public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
|
---|
70 | get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
|
---|
71 | }
|
---|
72 | public ValueLookupParameter<IOperator> MutatorParameter {
|
---|
73 | get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
|
---|
74 | }
|
---|
75 | public ValueLookupParameter<IOperator> EvaluatorParameter {
|
---|
76 | get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
|
---|
77 | }
|
---|
78 | public ValueLookupParameter<IntValue> ElitesParameter {
|
---|
79 | get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
|
---|
80 | }
|
---|
81 | public ValueLookupParameter<ResultCollection> ResultsParameter {
|
---|
82 | get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
|
---|
83 | }
|
---|
84 | public ValueLookupParameter<IOperator> VisualizerParameter {
|
---|
85 | get { return (ValueLookupParameter<IOperator>)Parameters["Visualizer"]; }
|
---|
86 | }
|
---|
87 | public LookupParameter<IItem> VisualizationParameter {
|
---|
88 | get { return (LookupParameter<IItem>)Parameters["Visualization"]; }
|
---|
89 | }
|
---|
90 | public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
|
---|
91 | get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
|
---|
92 | }
|
---|
93 | public ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
|
---|
94 | get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorLowerBound"]; }
|
---|
95 | }
|
---|
96 | public ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
|
---|
97 | get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorUpperBound"]; }
|
---|
98 | }
|
---|
99 | public ValueLookupParameter<IOperator> ComparisonFactorModifierParameter {
|
---|
100 | get { return (ValueLookupParameter<IOperator>)Parameters["ComparisonFactorModifier"]; }
|
---|
101 | }
|
---|
102 | public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
|
---|
103 | get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
|
---|
104 | }
|
---|
105 | public ValueLookupParameter<DoubleValue> FinalMaximumSelectionPressureParameter {
|
---|
106 | get { return (ValueLookupParameter<DoubleValue>)Parameters["FinalMaximumSelectionPressure"]; }
|
---|
107 | }
|
---|
108 | public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
|
---|
109 | get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
|
---|
110 | }
|
---|
111 | public ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
|
---|
112 | get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
|
---|
113 | }
|
---|
114 | #endregion
|
---|
115 |
|
---|
116 | [StorableConstructor]
|
---|
117 | private SASEGASAMainLoop(bool deserializing) : base() { }
|
---|
118 | public SASEGASAMainLoop()
|
---|
119 | : base() {
|
---|
120 | #region Create parameters
|
---|
121 | Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
|
---|
122 | Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
|
---|
123 | Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
|
---|
124 | Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
|
---|
125 | Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfVillages", "The initial number of villages."));
|
---|
126 | Parameters.Add(new ValueLookupParameter<IntValue>("MigrationInterval", "The fixed period after which migration occurs."));
|
---|
127 | Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
|
---|
128 | Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
|
---|
129 | Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
|
---|
130 | Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
|
---|
131 | Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
|
---|
132 | Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
|
---|
133 | Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results."));
|
---|
134 | Parameters.Add(new ValueLookupParameter<IOperator>("Visualizer", "The operator used to visualize solutions."));
|
---|
135 | Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions."));
|
---|
136 | Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
|
---|
137 | Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start)."));
|
---|
138 | Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end)."));
|
---|
139 | Parameters.Add(new ValueLookupParameter<IOperator>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));
|
---|
140 | Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
|
---|
141 | Parameters.Add(new ValueLookupParameter<DoubleValue>("FinalMaximumSelectionPressure", "The maximum selection pressure used when there is only one village left."));
|
---|
142 | Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum genreation that terminates the algorithm."));
|
---|
143 | 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."));
|
---|
144 | #endregion
|
---|
145 |
|
---|
146 | #region Create operators
|
---|
147 | VariableCreator variableCreator = new VariableCreator();
|
---|
148 | Assigner maxSelPressAssigner = new Assigner();
|
---|
149 | Assigner villageCountAssigner = new Assigner();
|
---|
150 | Assigner comparisonFactorInitializer = new Assigner();
|
---|
151 | UniformSubScopesProcessor ussp0 = new UniformSubScopesProcessor();
|
---|
152 | VariableCreator islandVariableCreator = new VariableCreator();
|
---|
153 | Assigner islandVariableAssigner = new Assigner();
|
---|
154 | BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer();
|
---|
155 | BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();
|
---|
156 | BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer();
|
---|
157 | BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
|
---|
158 | DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector();
|
---|
159 | DataTableValuesCollector selPressValuesCollector1 = new DataTableValuesCollector();
|
---|
160 | QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator();
|
---|
161 | ResultsCollector resultsCollector = new ResultsCollector();
|
---|
162 | Assigner fixedReunificationStepConditionInitializer = new Assigner();
|
---|
163 | UniformSubScopesProcessor ussp1 = new UniformSubScopesProcessor();
|
---|
164 | // MAINLOOP
|
---|
165 | OffspringSelectionGeneticAlgorithmMainLoop mainLoop = new OffspringSelectionGeneticAlgorithmMainLoop();
|
---|
166 | // MAINLOOP
|
---|
167 | Comparator sasegasaGenVillageGenComparator = new Comparator();
|
---|
168 | ConditionalBranch sasegasaGenerationsUpdateBranch = new ConditionalBranch();
|
---|
169 | Assigner sasegasaGenerationsUpdater = new Assigner();
|
---|
170 | ConditionalBranch villageMaximumGenerationsConditionalBranch1 = new ConditionalBranch();
|
---|
171 | Assigner fixedReunificationStepConditionUpdater = new Assigner();
|
---|
172 | ResultsCollector sasegasaGenerationsCollector = new ResultsCollector();
|
---|
173 | UniformSubScopesProcessor ussp2 = new UniformSubScopesProcessor();
|
---|
174 | ConditionalBranch villageMaximumGenerationsConditionalBranch2 = new ConditionalBranch();
|
---|
175 | Assigner villageMaximumGenerationsToGenerationsAssigner = new Assigner();
|
---|
176 | IntCounter villageMaximumGenerationsCounter = new IntCounter();
|
---|
177 | DataTableValuesCollector selPressValuesCollector2 = new DataTableValuesCollector();
|
---|
178 | Comparator villageCountComparator1 = new Comparator();
|
---|
179 | ConditionalBranch villageTerminationCondition1 = new ConditionalBranch();
|
---|
180 | SASEGASAReunificator reunificator = new SASEGASAReunificator();
|
---|
181 | IntCounter reunificationCounter = new IntCounter();
|
---|
182 | Placeholder comparisonFactorModifier = new Placeholder();
|
---|
183 | Comparator villageCountComparator2 = new Comparator();
|
---|
184 | ConditionalBranch villageTerminationCondition2 = new ConditionalBranch();
|
---|
185 | Assigner finalMaxSelPressAssigner = new Assigner();
|
---|
186 | Comparator maximumGenerationsComparator = new Comparator();
|
---|
187 | BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer();
|
---|
188 | BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator3 = new BestAverageWorstQualityCalculator();
|
---|
189 | DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector();
|
---|
190 | QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
|
---|
191 | ConditionalBranch villagesTerminationCondition3 = new ConditionalBranch();
|
---|
192 | ConditionalBranch maximumGenerationsTerminationCondition = new ConditionalBranch();
|
---|
193 |
|
---|
194 | // The generations of SASEGASA progress with the generations of its villages
|
---|
195 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("SASEGASAGenerations", new IntValue(0)));
|
---|
196 |
|
---|
197 | villageCountAssigner.LeftSideParameter.ActualName = "VillageCount";
|
---|
198 | villageCountAssigner.RightSideParameter.ActualName = NumberOfVillagesParameter.Name;
|
---|
199 |
|
---|
200 | maxSelPressAssigner.LeftSideParameter.ActualName = "CurrentMaximumSelectionPressure";
|
---|
201 | maxSelPressAssigner.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
|
---|
202 |
|
---|
203 | comparisonFactorInitializer.LeftSideParameter.ActualName = "ComparisonFactor";
|
---|
204 | comparisonFactorInitializer.RightSideParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
|
---|
205 |
|
---|
206 | islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("VillageResults", new ResultCollection()));
|
---|
207 | islandVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
|
---|
208 |
|
---|
209 | islandVariableAssigner.LeftSideParameter.ActualName = "VillageMaximumGenerations";
|
---|
210 | islandVariableAssigner.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
|
---|
211 |
|
---|
212 | bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
|
---|
213 | bestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
214 | bestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name;
|
---|
215 |
|
---|
216 | bestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageQuality";
|
---|
217 | bestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestQuality";
|
---|
218 | bestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
219 | bestAverageWorstQualityCalculator1.QualityParameter.ActualName = QualityParameter.Name;
|
---|
220 | bestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstQuality";
|
---|
221 |
|
---|
222 | bestQualityMemorizer2.BestQualityParameter.ActualName = "BestQuality";
|
---|
223 | bestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
224 | bestQualityMemorizer2.QualityParameter.ActualName = "BestQuality";
|
---|
225 |
|
---|
226 | bestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageBestQuality";
|
---|
227 | bestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestBestQuality";
|
---|
228 | bestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
229 | bestAverageWorstQualityCalculator2.QualityParameter.ActualName = "CurrentBestQuality";
|
---|
230 | bestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstBestQuality";
|
---|
231 |
|
---|
232 | dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
|
---|
233 | dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
|
---|
234 | dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
|
---|
235 | dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
|
---|
236 | dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
|
---|
237 | dataTableValuesCollector1.DataTableParameter.ActualName = "BestQualities";
|
---|
238 |
|
---|
239 | selPressValuesCollector1.CollectedValues.Add(new SubScopesLookupParameter<DoubleValue>("Selection Pressure Village", null, "SelectionPressure"));
|
---|
240 | selPressValuesCollector1.DataTableParameter.ActualName = "VillagesSelectionPressures";
|
---|
241 |
|
---|
242 | qualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
|
---|
243 | qualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
|
---|
244 | qualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
|
---|
245 | qualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";
|
---|
246 |
|
---|
247 | resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations", null, "SASEGASAGenerations"));
|
---|
248 | resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Current Villages", null, "VillageCount"));
|
---|
249 | resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
|
---|
250 | resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
|
---|
251 | resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
|
---|
252 | resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
|
---|
253 | resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
|
---|
254 | resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
|
---|
255 | resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
|
---|
256 | resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("BestQualities"));
|
---|
257 | resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("VillagesSelectionPressures"));
|
---|
258 | resultsCollector.CollectedValues.Add(new SubScopesLookupParameter<ResultCollection>("VillageResults", "Result set for each village"));
|
---|
259 | resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
|
---|
260 |
|
---|
261 | fixedReunificationStepConditionInitializer.LeftSideParameter.ActualName = "PerformFixedReunification";
|
---|
262 | fixedReunificationStepConditionInitializer.RightSideParameter.Value = new BoolValue(false);
|
---|
263 |
|
---|
264 | mainLoop.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
|
---|
265 | mainLoop.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
266 | mainLoop.QualityParameter.ActualName = QualityParameter.Name;
|
---|
267 | mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
|
---|
268 | mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
|
---|
269 | mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
|
---|
270 | mainLoop.MaximumGenerationsParameter.ActualName = "VillageMaximumGenerations";
|
---|
271 | mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
|
---|
272 | mainLoop.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
|
---|
273 | mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
|
---|
274 | mainLoop.RandomParameter.ActualName = RandomParameter.Name;
|
---|
275 | mainLoop.ResultsParameter.ActualName = "VillageResults";
|
---|
276 | mainLoop.VisualizerParameter.ActualName = VisualizerParameter.Name;
|
---|
277 | mainLoop.VisualizationParameter.ActualName = VisualizationParameter.Name;
|
---|
278 | mainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
|
---|
279 | mainLoop.ComparisonFactorLowerBoundParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
|
---|
280 | mainLoop.ComparisonFactorModifierParameter.Value = new EmptyOperator(); // comparison factor is modified here
|
---|
281 | mainLoop.ComparisonFactorUpperBoundParameter.ActualName = ComparisonFactorUpperBoundParameter.Name;
|
---|
282 | mainLoop.MaximumSelectionPressureParameter.ActualName = "CurrentMaximumSelectionPressure";
|
---|
283 | mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
|
---|
284 |
|
---|
285 | // SASEGASAGenerations is the maximum of all village generations
|
---|
286 | sasegasaGenVillageGenComparator.LeftSideParameter.ActualName = "SASEGASAGenerations";
|
---|
287 | sasegasaGenVillageGenComparator.RightSideParameter.ActualName = "Generations";
|
---|
288 | sasegasaGenVillageGenComparator.Comparison = new Comparison(ComparisonType.Less);
|
---|
289 | sasegasaGenVillageGenComparator.ResultParameter.ActualName = "UpdateSASEGASAGenerations";
|
---|
290 |
|
---|
291 | sasegasaGenerationsUpdateBranch.ConditionParameter.ActualName = "UpdateSASEGASAGenerations";
|
---|
292 |
|
---|
293 | sasegasaGenerationsUpdater.LeftSideParameter.ActualName = "SASEGASAGenerations";
|
---|
294 | sasegasaGenerationsUpdater.RightSideParameter.ActualName = "Generations";
|
---|
295 |
|
---|
296 | // check if the village has terminated due to reaching maximum generations (in that case we need to increase in each village the maximum generations by the migration interval)
|
---|
297 | villageMaximumGenerationsConditionalBranch1.ConditionParameter.ActualName = "TerminateMaximumGenerations";
|
---|
298 |
|
---|
299 | fixedReunificationStepConditionUpdater.LeftSideParameter.ActualName = "PerformFixedReunification";
|
---|
300 | fixedReunificationStepConditionUpdater.RightSideParameter.Value = new BoolValue(true);
|
---|
301 |
|
---|
302 | sasegasaGenerationsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations", null, "SASEGASAGenerations"));
|
---|
303 |
|
---|
304 | villageMaximumGenerationsConditionalBranch2.ConditionParameter.ActualName = "PerformFixedReunification";
|
---|
305 |
|
---|
306 | // if the village terminated because of maximum generations first set the maxgen of a village back to its generation
|
---|
307 | villageMaximumGenerationsToGenerationsAssigner.LeftSideParameter.ActualName = "VillageMaximumGenerations";
|
---|
308 | villageMaximumGenerationsToGenerationsAssigner.RightSideParameter.ActualName = "Generations";
|
---|
309 |
|
---|
310 | // if the village terminated because of maximum generations and then increase the maximum generations by the fixed migration interval
|
---|
311 | villageMaximumGenerationsCounter.ValueParameter.ActualName = "VillageMaximumGenerations";
|
---|
312 | villageMaximumGenerationsCounter.Increment = null;
|
---|
313 | villageMaximumGenerationsCounter.IncrementParameter.ActualName = "MigrationInterval";
|
---|
314 |
|
---|
315 | selPressValuesCollector2.CollectedValues.Add(new SubScopesLookupParameter<DoubleValue>("Selection Pressure Village", null, "SelectionPressure"));
|
---|
316 | selPressValuesCollector2.DataTableParameter.ActualName = "VillagesSelectionPressures";
|
---|
317 |
|
---|
318 | // if there's just one island left and we're getting to this point SASEGASA terminates
|
---|
319 | villageCountComparator1.Name = "VillageCount <= 1 ?";
|
---|
320 | villageCountComparator1.LeftSideParameter.ActualName = "VillageCount";
|
---|
321 | villageCountComparator1.RightSideParameter.Value = new IntValue(1);
|
---|
322 | villageCountComparator1.Comparison.Value = ComparisonType.LessOrEqual;
|
---|
323 | villageCountComparator1.ResultParameter.ActualName = "TerminateVillages";
|
---|
324 |
|
---|
325 | villageTerminationCondition1.Name = "Skip reunification?";
|
---|
326 | villageTerminationCondition1.ConditionParameter.ActualName = "TerminateVillages";
|
---|
327 |
|
---|
328 | reunificator.VillageCountParameter.ActualName = "VillageCount";
|
---|
329 |
|
---|
330 | reunificationCounter.ValueParameter.ActualName = "Reunifications"; // this variable is referenced in SASEGASA, do not change!
|
---|
331 | reunificationCounter.IncrementParameter.Value = new IntValue(1);
|
---|
332 |
|
---|
333 | comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
|
---|
334 |
|
---|
335 | villageCountComparator2.Name = "VillageCount == 1 ?";
|
---|
336 | villageCountComparator2.LeftSideParameter.ActualName = "VillageCount";
|
---|
337 | villageCountComparator2.RightSideParameter.Value = new IntValue(1);
|
---|
338 | villageCountComparator2.Comparison.Value = ComparisonType.Equal;
|
---|
339 | villageCountComparator2.ResultParameter.ActualName = "ChangeMaxSelPress";
|
---|
340 |
|
---|
341 | villageTerminationCondition2.Name = "Change max selection pressure?";
|
---|
342 | villageTerminationCondition2.ConditionParameter.ActualName = "ChangeMaxSelPress";
|
---|
343 |
|
---|
344 | finalMaxSelPressAssigner.LeftSideParameter.ActualName = "CurrentMaximumSelectionPressure";
|
---|
345 | finalMaxSelPressAssigner.RightSideParameter.ActualName = FinalMaximumSelectionPressureParameter.Name;
|
---|
346 |
|
---|
347 | // if SASEGASAGenerations is reaching MaximumGenerations we're also terminating
|
---|
348 | maximumGenerationsComparator.LeftSideParameter.ActualName = "SASEGASAGenerations";
|
---|
349 | maximumGenerationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
350 | maximumGenerationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
351 | maximumGenerationsComparator.ResultParameter.ActualName = "TerminateMaximumGenerations";
|
---|
352 |
|
---|
353 | bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality";
|
---|
354 | bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
355 | bestQualityMemorizer3.QualityParameter.ActualName = "BestQuality";
|
---|
356 |
|
---|
357 | bestAverageWorstQualityCalculator3.AverageQualityParameter.ActualName = "CurrentAverageBestQuality";
|
---|
358 | bestAverageWorstQualityCalculator3.BestQualityParameter.ActualName = "CurrentBestBestQuality";
|
---|
359 | bestAverageWorstQualityCalculator3.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
360 | bestAverageWorstQualityCalculator3.QualityParameter.ActualName = "CurrentBestQuality";
|
---|
361 | bestAverageWorstQualityCalculator3.WorstQualityParameter.ActualName = "CurrentWorstBestQuality";
|
---|
362 |
|
---|
363 | dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
|
---|
364 | dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
|
---|
365 | dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
|
---|
366 | dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
|
---|
367 | dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
|
---|
368 | dataTableValuesCollector2.DataTableParameter.ActualName = "BestQualities";
|
---|
369 |
|
---|
370 | qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
|
---|
371 | qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
|
---|
372 | qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
|
---|
373 | qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
|
---|
374 |
|
---|
375 | villagesTerminationCondition3.ConditionParameter.ActualName = "TerminateVillages";
|
---|
376 | villageMaximumGenerationsConditionalBranch1.ConditionParameter.ActualName = "TerminateMaximumGenerations";
|
---|
377 | #endregion
|
---|
378 |
|
---|
379 | #region Create operator graph
|
---|
380 | OperatorGraph.InitialOperator = variableCreator;
|
---|
381 | variableCreator.Successor = villageCountAssigner;
|
---|
382 | villageCountAssigner.Successor = maxSelPressAssigner;
|
---|
383 | maxSelPressAssigner.Successor = comparisonFactorInitializer;
|
---|
384 | comparisonFactorInitializer.Successor = ussp0;
|
---|
385 | ussp0.Operator = islandVariableCreator;
|
---|
386 | ussp0.Successor = bestQualityMemorizer2;
|
---|
387 | islandVariableCreator.Successor = islandVariableAssigner;
|
---|
388 | islandVariableAssigner.Successor = bestQualityMemorizer1;
|
---|
389 | bestQualityMemorizer1.Successor = bestAverageWorstQualityCalculator1;
|
---|
390 | bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator2;
|
---|
391 | bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector1;
|
---|
392 | dataTableValuesCollector1.Successor = selPressValuesCollector1;
|
---|
393 | selPressValuesCollector1.Successor = qualityDifferenceCalculator1;
|
---|
394 | qualityDifferenceCalculator1.Successor = resultsCollector;
|
---|
395 | resultsCollector.Successor = fixedReunificationStepConditionInitializer;
|
---|
396 | fixedReunificationStepConditionInitializer.Successor = ussp1;
|
---|
397 | ussp1.Operator = mainLoop;
|
---|
398 | ussp1.Successor = sasegasaGenerationsCollector;
|
---|
399 | mainLoop.Successor = sasegasaGenVillageGenComparator;
|
---|
400 | sasegasaGenVillageGenComparator.Successor = sasegasaGenerationsUpdateBranch;
|
---|
401 | sasegasaGenerationsUpdateBranch.TrueBranch = sasegasaGenerationsUpdater;
|
---|
402 | sasegasaGenerationsUpdateBranch.FalseBranch = null;
|
---|
403 | sasegasaGenerationsUpdateBranch.Successor = villageMaximumGenerationsConditionalBranch1;
|
---|
404 | villageMaximumGenerationsConditionalBranch1.TrueBranch = fixedReunificationStepConditionUpdater;
|
---|
405 | villageMaximumGenerationsConditionalBranch1.FalseBranch = null;
|
---|
406 | villageMaximumGenerationsConditionalBranch1.Successor = null;
|
---|
407 | sasegasaGenerationsCollector.Successor = ussp2;
|
---|
408 | ussp2.Operator = villageMaximumGenerationsConditionalBranch2;
|
---|
409 | ussp2.Successor = selPressValuesCollector2;
|
---|
410 | villageMaximumGenerationsConditionalBranch2.TrueBranch = villageMaximumGenerationsToGenerationsAssigner;
|
---|
411 | villageMaximumGenerationsConditionalBranch2.FalseBranch = null;
|
---|
412 | villageMaximumGenerationsConditionalBranch2.Successor = null;
|
---|
413 | villageMaximumGenerationsToGenerationsAssigner.Successor = villageMaximumGenerationsCounter;
|
---|
414 | villageMaximumGenerationsCounter.Successor = null;
|
---|
415 | selPressValuesCollector2.Successor = villageCountComparator1;
|
---|
416 | villageCountComparator1.Successor = villageTerminationCondition1;
|
---|
417 | villageTerminationCondition1.TrueBranch = null;
|
---|
418 | villageTerminationCondition1.FalseBranch = reunificator;
|
---|
419 | villageTerminationCondition1.Successor = maximumGenerationsComparator;
|
---|
420 | reunificator.Successor = reunificationCounter;
|
---|
421 | reunificationCounter.Successor = comparisonFactorModifier;
|
---|
422 | comparisonFactorModifier.Successor = villageCountComparator2;
|
---|
423 | villageCountComparator2.Successor = villageTerminationCondition2;
|
---|
424 | villageTerminationCondition2.TrueBranch = finalMaxSelPressAssigner;
|
---|
425 | villageTerminationCondition2.FalseBranch = null;
|
---|
426 | villageTerminationCondition2.Successor = null;
|
---|
427 | finalMaxSelPressAssigner.Successor = null;
|
---|
428 | maximumGenerationsComparator.Successor = bestQualityMemorizer3;
|
---|
429 | bestQualityMemorizer3.Successor = bestAverageWorstQualityCalculator3;
|
---|
430 | bestAverageWorstQualityCalculator3.Successor = dataTableValuesCollector2;
|
---|
431 | dataTableValuesCollector2.Successor = qualityDifferenceCalculator2;
|
---|
432 | qualityDifferenceCalculator2.Successor = villagesTerminationCondition3;
|
---|
433 | villagesTerminationCondition3.FalseBranch = maximumGenerationsTerminationCondition;
|
---|
434 | villagesTerminationCondition3.TrueBranch = null;
|
---|
435 | villagesTerminationCondition3.Successor = null;
|
---|
436 | maximumGenerationsTerminationCondition.FalseBranch = fixedReunificationStepConditionInitializer;
|
---|
437 | maximumGenerationsTerminationCondition.TrueBranch = null;
|
---|
438 | maximumGenerationsTerminationCondition.Successor = null;
|
---|
439 | #endregion
|
---|
440 | }
|
---|
441 | }
|
---|
442 | }
|
---|