1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2019 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 HeuristicLab.Common;
|
---|
23 | using HeuristicLab.Core;
|
---|
24 | using HeuristicLab.Data;
|
---|
25 | using HeuristicLab.Operators;
|
---|
26 | using HeuristicLab.Optimization.Operators;
|
---|
27 | using HeuristicLab.Parameters;
|
---|
28 | using HEAL.Attic;
|
---|
29 | using HeuristicLab.Selection;
|
---|
30 |
|
---|
31 | namespace HeuristicLab.Algorithms.OffspringSelectionEvolutionStrategy {
|
---|
32 | /// <summary>
|
---|
33 | /// An operator which represents the main loop of an evolution strategy (OffspringSelectionEvolutionStrategy).
|
---|
34 | /// </summary>
|
---|
35 | [Item("OffspringSelectionEvolutionStrategyMainLoop", "An operator which represents the main loop of an evolution strategy with offspring selection (OffspringSelectionEvolutionStrategy).")]
|
---|
36 | [StorableType("D5F331A5-AE66-415B-990A-D0E6AED6E102")]
|
---|
37 | public sealed class OffspringSelectionEvolutionStrategyMainLoop : AlgorithmOperator {
|
---|
38 | #region Parameter properties
|
---|
39 | public ValueLookupParameter<IRandom> RandomParameter {
|
---|
40 | get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
|
---|
41 | }
|
---|
42 | public ValueLookupParameter<BoolValue> MaximizationParameter {
|
---|
43 | get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
|
---|
44 | }
|
---|
45 | public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
|
---|
46 | get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
|
---|
47 | }
|
---|
48 | public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
|
---|
49 | get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
|
---|
50 | }
|
---|
51 | public ValueLookupParameter<IntValue> PopulationSizeParameter {
|
---|
52 | get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; }
|
---|
53 | }
|
---|
54 | public ValueLookupParameter<IntValue> ParentsPerChildParameter {
|
---|
55 | get { return (ValueLookupParameter<IntValue>)Parameters["ParentsPerChild"]; }
|
---|
56 | }
|
---|
57 | public ValueLookupParameter<BoolValue> PlusSelectionParameter {
|
---|
58 | get { return (ValueLookupParameter<BoolValue>)Parameters["PlusSelection"]; }
|
---|
59 | }
|
---|
60 | public IValueLookupParameter<BoolValue> ReevaluateElitesParameter {
|
---|
61 | get { return (IValueLookupParameter<BoolValue>)Parameters["ReevaluateElites"]; }
|
---|
62 | }
|
---|
63 | public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
|
---|
64 | get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
|
---|
65 | }
|
---|
66 | public ValueLookupParameter<IOperator> MutatorParameter {
|
---|
67 | get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
|
---|
68 | }
|
---|
69 | public ValueLookupParameter<IOperator> RecombinatorParameter {
|
---|
70 | get { return (ValueLookupParameter<IOperator>)Parameters["Recombinator"]; }
|
---|
71 | }
|
---|
72 | public ValueLookupParameter<IOperator> EvaluatorParameter {
|
---|
73 | get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
|
---|
74 | }
|
---|
75 | public ValueLookupParameter<VariableCollection> ResultsParameter {
|
---|
76 | get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; }
|
---|
77 | }
|
---|
78 | public ValueLookupParameter<IOperator> AnalyzerParameter {
|
---|
79 | get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
|
---|
80 | }
|
---|
81 | public LookupParameter<IntValue> EvaluatedSolutionsParameter {
|
---|
82 | get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
|
---|
83 | }
|
---|
84 | private ScopeParameter CurrentScopeParameter {
|
---|
85 | get { return (ScopeParameter)Parameters["CurrentScope"]; }
|
---|
86 | }
|
---|
87 | private ValueLookupParameter<IOperator> StrategyParameterManipulatorParameter {
|
---|
88 | get { return (ValueLookupParameter<IOperator>)Parameters["StrategyParameterManipulator"]; }
|
---|
89 | }
|
---|
90 | private ValueLookupParameter<IOperator> StrategyParameterCrossoverParameter {
|
---|
91 | get { return (ValueLookupParameter<IOperator>)Parameters["StrategyParameterCrossover"]; }
|
---|
92 | }
|
---|
93 |
|
---|
94 | public LookupParameter<DoubleValue> CurrentSuccessRatioParameter {
|
---|
95 | get { return (LookupParameter<DoubleValue>)Parameters["CurrentSuccessRatio"]; }
|
---|
96 | }
|
---|
97 | public LookupParameter<DoubleValue> SelectionPressureParameter {
|
---|
98 | get { return (LookupParameter<DoubleValue>)Parameters["SelectionPressure"]; }
|
---|
99 | }
|
---|
100 | public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
|
---|
101 | get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
|
---|
102 | }
|
---|
103 | public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
|
---|
104 | get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
|
---|
105 | }
|
---|
106 | public ValueLookupParameter<IntValue> MaximumEvaluatedSolutionsParameter {
|
---|
107 | get { return (ValueLookupParameter<IntValue>)Parameters["MaximumEvaluatedSolutions"]; }
|
---|
108 | }
|
---|
109 | public ValueLookupParameter<IntValue> SelectedParentsParameter {
|
---|
110 | get { return (ValueLookupParameter<IntValue>)Parameters["SelectedParents"]; }
|
---|
111 | }
|
---|
112 | public LookupParameter<DoubleValue> ComparisonFactorParameter {
|
---|
113 | get { return (LookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
|
---|
114 | }
|
---|
115 |
|
---|
116 | public IScope CurrentScope {
|
---|
117 | get { return CurrentScopeParameter.ActualValue; }
|
---|
118 | }
|
---|
119 | #endregion
|
---|
120 |
|
---|
121 | [StorableConstructor]
|
---|
122 | private OffspringSelectionEvolutionStrategyMainLoop(StorableConstructorFlag _) : base(_) { }
|
---|
123 | private OffspringSelectionEvolutionStrategyMainLoop(OffspringSelectionEvolutionStrategyMainLoop original, Cloner cloner)
|
---|
124 | : base(original, cloner) {
|
---|
125 | }
|
---|
126 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
127 | return new OffspringSelectionEvolutionStrategyMainLoop(this, cloner);
|
---|
128 | }
|
---|
129 | public OffspringSelectionEvolutionStrategyMainLoop()
|
---|
130 | : base() {
|
---|
131 | Initialize();
|
---|
132 | }
|
---|
133 |
|
---|
134 | [StorableHook(HookType.AfterDeserialization)]
|
---|
135 | private void AfterDeserialization() {
|
---|
136 | }
|
---|
137 |
|
---|
138 | private void Initialize() {
|
---|
139 | #region Create parameters
|
---|
140 | Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
|
---|
141 | Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
|
---|
142 | Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
|
---|
143 | Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
|
---|
144 | Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "µ (mu) - the size of the population."));
|
---|
145 | Parameters.Add(new ValueLookupParameter<IntValue>("ParentsPerChild", "ρ (rho) - how many parents should be recombined."));
|
---|
146 | Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed."));
|
---|
147 | Parameters.Add(new ValueLookupParameter<BoolValue>("PlusSelection", "True for plus selection (elitist population), false for comma selection (non-elitist population)."));
|
---|
148 | Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
|
---|
149 | Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
|
---|
150 | Parameters.Add(new ValueLookupParameter<IOperator>("Recombinator", "The operator used to cross solutions."));
|
---|
151 | Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions. This operator is executed in parallel, if an engine is used which supports parallelization."));
|
---|
152 | Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
|
---|
153 | Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
|
---|
154 | Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
|
---|
155 | Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the OffspringSelectionEvolutionStrategy should be applied."));
|
---|
156 | Parameters.Add(new ValueLookupParameter<IOperator>("StrategyParameterManipulator", "The operator to mutate the endogeneous strategy parameters."));
|
---|
157 | Parameters.Add(new ValueLookupParameter<IOperator>("StrategyParameterCrossover", "The operator to cross the endogeneous strategy parameters."));
|
---|
158 |
|
---|
159 | Parameters.Add(new LookupParameter<DoubleValue>("CurrentSuccessRatio", "The current success ratio."));
|
---|
160 | Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
|
---|
161 | Parameters.Add(new LookupParameter<DoubleValue>("SelectionPressure", "The actual selection pressure."));
|
---|
162 | Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
|
---|
163 | Parameters.Add(new ValueLookupParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions."));
|
---|
164 | Parameters.Add(new ValueLookupParameter<IntValue>("SelectedParents", "How much parents should be selected each time the offspring selection step is performed until the population is filled. This parameter should be about the same or twice the size of PopulationSize for smaller problems, and less for large problems."));
|
---|
165 | 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]."));
|
---|
166 |
|
---|
167 | #endregion
|
---|
168 |
|
---|
169 | #region Create operators
|
---|
170 | VariableCreator variableCreator = new VariableCreator();
|
---|
171 | ResultsCollector resultsCollector1 = new ResultsCollector();
|
---|
172 | Placeholder analyzer1 = new Placeholder();
|
---|
173 | WithoutRepeatingBatchedRandomSelector selector = new WithoutRepeatingBatchedRandomSelector();
|
---|
174 | SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
|
---|
175 | Comparator useRecombinationComparator = new Comparator();
|
---|
176 | ConditionalBranch useRecombinationBranch = new ConditionalBranch();
|
---|
177 | ChildrenCreator childrenCreator = new ChildrenCreator();
|
---|
178 | UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
|
---|
179 | Placeholder recombinator = new Placeholder();
|
---|
180 | Placeholder strategyRecombinator = new Placeholder();
|
---|
181 | Placeholder strategyMutator1 = new Placeholder();
|
---|
182 | Placeholder mutator1 = new Placeholder();
|
---|
183 | SubScopesRemover subScopesRemover = new SubScopesRemover();
|
---|
184 | UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
|
---|
185 | Placeholder strategyMutator2 = new Placeholder();
|
---|
186 | Placeholder mutator2 = new Placeholder();
|
---|
187 | UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
|
---|
188 | Placeholder evaluator = new Placeholder();
|
---|
189 | SubScopesCounter subScopesCounter = new SubScopesCounter();
|
---|
190 | ConditionalBranch plusOrCommaReplacementBranch = new ConditionalBranch();
|
---|
191 | MergingReducer plusReplacement = new MergingReducer();
|
---|
192 | RightReducer commaReplacement = new RightReducer();
|
---|
193 | BestSelector bestSelector = new BestSelector();
|
---|
194 | RightReducer rightReducer = new RightReducer();
|
---|
195 | IntCounter intCounter = new IntCounter();
|
---|
196 | Comparator maxGenerationsComparator = new Comparator();
|
---|
197 | Placeholder analyzer2 = new Placeholder();
|
---|
198 | ConditionalBranch conditionalBranchTerminate = new ConditionalBranch();
|
---|
199 | ConditionalBranch reevaluateElitesBranch = new ConditionalBranch();
|
---|
200 | SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
|
---|
201 | UniformSubScopesProcessor uniformSubScopesProcessor4 = new UniformSubScopesProcessor();
|
---|
202 | Placeholder evaluator2 = new Placeholder();
|
---|
203 | SubScopesCounter subScopesCounter2 = new SubScopesCounter();
|
---|
204 | WeightedParentsQualityComparator parentsComparator = new WeightedParentsQualityComparator();
|
---|
205 | SubScopesRemover subScopesRemover_afterCompare = new SubScopesRemover();
|
---|
206 | EvolutionStrategyOffspringSelector offspringSelector = new EvolutionStrategyOffspringSelector();
|
---|
207 | ChildrenCopyCreator childrenCopyCreator = new ChildrenCopyCreator();
|
---|
208 | Comparator maxSelectionPressureComparator = new Comparator();
|
---|
209 | ConditionalBranch conditionalBranchTerminateSelPressure = new ConditionalBranch();
|
---|
210 | Comparator maxEvaluatedSolutionsComparator = new Comparator();
|
---|
211 | ConditionalBranch conditionalBranchTerminateEvalSolutions = new ConditionalBranch();
|
---|
212 |
|
---|
213 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class OffspringSelectionEvolutionStrategy expects this to be called Generations
|
---|
214 | variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
|
---|
215 | variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
|
---|
216 |
|
---|
217 | resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
|
---|
218 | resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", "Displays the rising selection pressure during a generation.", "SelectionPressure"));
|
---|
219 | resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", "Indicates how many successful children were already found during a generation (relative to the population size).", "CurrentSuccessRatio"));
|
---|
220 | resultsCollector1.CopyValue = new BoolValue(false);
|
---|
221 | resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
|
---|
222 |
|
---|
223 | analyzer1.Name = "Analyzer (placeholder)";
|
---|
224 | analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;
|
---|
225 |
|
---|
226 | selector.Name = "ES Random Selector";
|
---|
227 | selector.RandomParameter.ActualName = RandomParameter.Name;
|
---|
228 | selector.ParentsPerChildParameter.ActualName = ParentsPerChildParameter.Name;
|
---|
229 | selector.ChildrenParameter.ActualName = SelectedParentsParameter.Name;
|
---|
230 |
|
---|
231 | useRecombinationComparator.Name = "ParentsPerChild > 1";
|
---|
232 | useRecombinationComparator.LeftSideParameter.ActualName = ParentsPerChildParameter.Name;
|
---|
233 | useRecombinationComparator.RightSideParameter.Value = new IntValue(1);
|
---|
234 | useRecombinationComparator.Comparison = new Comparison(ComparisonType.Greater);
|
---|
235 | useRecombinationComparator.ResultParameter.ActualName = "UseRecombination";
|
---|
236 |
|
---|
237 | useRecombinationBranch.Name = "Use Recombination?";
|
---|
238 | useRecombinationBranch.ConditionParameter.ActualName = "UseRecombination";
|
---|
239 |
|
---|
240 | childrenCreator.ParentsPerChild = null;
|
---|
241 | childrenCreator.ParentsPerChildParameter.ActualName = ParentsPerChildParameter.Name;
|
---|
242 |
|
---|
243 | recombinator.Name = "Recombinator (placeholder)";
|
---|
244 | recombinator.OperatorParameter.ActualName = RecombinatorParameter.Name;
|
---|
245 |
|
---|
246 | strategyRecombinator.Name = "Strategy Parameter Recombinator (placeholder)";
|
---|
247 | strategyRecombinator.OperatorParameter.ActualName = StrategyParameterCrossoverParameter.Name;
|
---|
248 |
|
---|
249 | strategyMutator1.Name = "Strategy Parameter Manipulator (placeholder)";
|
---|
250 | strategyMutator1.OperatorParameter.ActualName = StrategyParameterManipulatorParameter.Name;
|
---|
251 |
|
---|
252 | mutator1.Name = "Mutator (placeholder)";
|
---|
253 | mutator1.OperatorParameter.ActualName = MutatorParameter.Name;
|
---|
254 |
|
---|
255 | subScopesRemover.RemoveAllSubScopes = true;
|
---|
256 |
|
---|
257 | strategyMutator2.Name = "Strategy Parameter Manipulator (placeholder)";
|
---|
258 | strategyMutator2.OperatorParameter.ActualName = StrategyParameterManipulatorParameter.Name;
|
---|
259 |
|
---|
260 | mutator2.Name = "Mutator (placeholder)";
|
---|
261 | mutator2.OperatorParameter.ActualName = MutatorParameter.Name;
|
---|
262 |
|
---|
263 | uniformSubScopesProcessor3.Parallel.Value = true;
|
---|
264 |
|
---|
265 | evaluator.Name = "Evaluator (placeholder)";
|
---|
266 | evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name;
|
---|
267 |
|
---|
268 | subScopesCounter.Name = "Increment EvaluatedSolutions";
|
---|
269 | subScopesCounter.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
|
---|
270 |
|
---|
271 | plusOrCommaReplacementBranch.ConditionParameter.ActualName = PlusSelectionParameter.Name;
|
---|
272 |
|
---|
273 | bestSelector.CopySelected = new BoolValue(false);
|
---|
274 | bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
275 | bestSelector.NumberOfSelectedSubScopesParameter.ActualName = PopulationSizeParameter.Name;
|
---|
276 | bestSelector.QualityParameter.ActualName = QualityParameter.Name;
|
---|
277 |
|
---|
278 | intCounter.Increment = new IntValue(1);
|
---|
279 | intCounter.ValueParameter.ActualName = "Generations";
|
---|
280 |
|
---|
281 | maxGenerationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
282 | maxGenerationsComparator.LeftSideParameter.ActualName = "Generations";
|
---|
283 | maxGenerationsComparator.ResultParameter.ActualName = "Terminate";
|
---|
284 | maxGenerationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
285 |
|
---|
286 | analyzer2.Name = "Analyzer (placeholder)";
|
---|
287 | analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;
|
---|
288 |
|
---|
289 | conditionalBranchTerminate.ConditionParameter.ActualName = "Terminate";
|
---|
290 |
|
---|
291 | reevaluateElitesBranch.ConditionParameter.ActualName = "ReevaluateElites";
|
---|
292 | reevaluateElitesBranch.Name = "Reevaluate elites ?";
|
---|
293 |
|
---|
294 | uniformSubScopesProcessor4.Parallel.Value = true;
|
---|
295 |
|
---|
296 | evaluator2.Name = "Evaluator (placeholder)";
|
---|
297 | evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;
|
---|
298 |
|
---|
299 | subScopesCounter2.Name = "Increment EvaluatedSolutions";
|
---|
300 | subScopesCounter2.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
|
---|
301 |
|
---|
302 | parentsComparator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
|
---|
303 | parentsComparator.LeftSideParameter.ActualName = QualityParameter.Name;
|
---|
304 | parentsComparator.RightSideParameter.ActualName = QualityParameter.Name;
|
---|
305 | parentsComparator.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
306 | parentsComparator.ResultParameter.ActualName = "SuccessfulOffspring";
|
---|
307 |
|
---|
308 | subScopesRemover_afterCompare.RemoveAllSubScopes = true;
|
---|
309 |
|
---|
310 | offspringSelector.CurrentSuccessRatioParameter.ActualName = CurrentSuccessRatioParameter.Name;
|
---|
311 | offspringSelector.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
|
---|
312 | offspringSelector.SelectionPressureParameter.ActualName = SelectionPressureParameter.Name;
|
---|
313 | offspringSelector.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
|
---|
314 | offspringSelector.OffspringPopulationParameter.ActualName = "OffspringPopulation";
|
---|
315 | offspringSelector.OffspringPopulationWinnersParameter.ActualName = "OffspringPopulationWinners";
|
---|
316 | offspringSelector.SuccessfulOffspringParameter.ActualName = "SuccessfulOffspring";
|
---|
317 | offspringSelector.QualityParameter.ActualName = QualityParameter.Name;
|
---|
318 |
|
---|
319 | maxSelectionPressureComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
320 | maxSelectionPressureComparator.LeftSideParameter.ActualName = "SelectionPressure";
|
---|
321 | maxSelectionPressureComparator.ResultParameter.ActualName = "TerminateSelectionPressure";
|
---|
322 | maxSelectionPressureComparator.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
|
---|
323 |
|
---|
324 | conditionalBranchTerminateSelPressure.ConditionParameter.ActualName = "TerminateSelectionPressure";
|
---|
325 |
|
---|
326 | maxEvaluatedSolutionsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
327 | maxEvaluatedSolutionsComparator.LeftSideParameter.ActualName = "EvaluatedSolutions";
|
---|
328 | maxEvaluatedSolutionsComparator.ResultParameter.ActualName = "TerminateEvaluatedSolutions";
|
---|
329 | maxEvaluatedSolutionsComparator.RightSideParameter.ActualName = MaximumEvaluatedSolutionsParameter.Name;
|
---|
330 |
|
---|
331 | conditionalBranchTerminateEvalSolutions.ConditionParameter.ActualName = "TerminateEvaluatedSolutions";
|
---|
332 |
|
---|
333 | #endregion
|
---|
334 |
|
---|
335 | #region Create operator graph
|
---|
336 | OperatorGraph.InitialOperator = variableCreator;
|
---|
337 | variableCreator.Successor = resultsCollector1;
|
---|
338 | resultsCollector1.Successor = analyzer1;
|
---|
339 | analyzer1.Successor = selector;
|
---|
340 | selector.Successor = subScopesProcessor1;
|
---|
341 | subScopesProcessor1.Operators.Add(new EmptyOperator());
|
---|
342 | subScopesProcessor1.Operators.Add(useRecombinationComparator);
|
---|
343 |
|
---|
344 | subScopesProcessor1.Successor = offspringSelector;
|
---|
345 | offspringSelector.OffspringCreator = selector;
|
---|
346 | offspringSelector.Successor = plusOrCommaReplacementBranch;
|
---|
347 |
|
---|
348 | useRecombinationComparator.Successor = useRecombinationBranch;
|
---|
349 | useRecombinationBranch.TrueBranch = childrenCreator;
|
---|
350 |
|
---|
351 | useRecombinationBranch.FalseBranch = childrenCopyCreator;
|
---|
352 | childrenCopyCreator.Successor = uniformSubScopesProcessor2;
|
---|
353 |
|
---|
354 | useRecombinationBranch.Successor = uniformSubScopesProcessor3;
|
---|
355 | childrenCreator.Successor = uniformSubScopesProcessor1;
|
---|
356 | uniformSubScopesProcessor1.Operator = recombinator;
|
---|
357 | uniformSubScopesProcessor1.Successor = null;
|
---|
358 | recombinator.Successor = strategyRecombinator;
|
---|
359 | strategyRecombinator.Successor = strategyMutator1;
|
---|
360 | strategyMutator1.Successor = mutator1;
|
---|
361 |
|
---|
362 | mutator1.Successor = null;
|
---|
363 |
|
---|
364 | uniformSubScopesProcessor2.Operator = strategyMutator2;
|
---|
365 | uniformSubScopesProcessor2.Successor = null;
|
---|
366 | strategyMutator2.Successor = mutator2;
|
---|
367 | mutator2.Successor = null;
|
---|
368 | uniformSubScopesProcessor3.Operator = evaluator;
|
---|
369 | uniformSubScopesProcessor3.Successor = subScopesCounter;
|
---|
370 |
|
---|
371 | evaluator.Successor = parentsComparator;
|
---|
372 | parentsComparator.Successor = subScopesRemover_afterCompare;
|
---|
373 | subScopesRemover_afterCompare.Successor = null;
|
---|
374 | subScopesCounter.Successor = null;
|
---|
375 |
|
---|
376 | plusOrCommaReplacementBranch.TrueBranch = reevaluateElitesBranch;
|
---|
377 | reevaluateElitesBranch.TrueBranch = subScopesProcessor2;
|
---|
378 | reevaluateElitesBranch.FalseBranch = null;
|
---|
379 | subScopesProcessor2.Operators.Add(uniformSubScopesProcessor4);
|
---|
380 | subScopesProcessor2.Operators.Add(new EmptyOperator());
|
---|
381 | uniformSubScopesProcessor4.Operator = evaluator2;
|
---|
382 | uniformSubScopesProcessor4.Successor = subScopesCounter2;
|
---|
383 | subScopesCounter2.Successor = null;
|
---|
384 | reevaluateElitesBranch.Successor = plusReplacement;
|
---|
385 |
|
---|
386 | plusReplacement.Successor = bestSelector;
|
---|
387 | bestSelector.Successor = rightReducer;
|
---|
388 |
|
---|
389 | plusOrCommaReplacementBranch.FalseBranch = commaReplacement;
|
---|
390 | plusOrCommaReplacementBranch.Successor = intCounter;
|
---|
391 |
|
---|
392 |
|
---|
393 | intCounter.Successor = maxGenerationsComparator;
|
---|
394 | maxGenerationsComparator.Successor = maxSelectionPressureComparator;
|
---|
395 | maxSelectionPressureComparator.Successor = maxEvaluatedSolutionsComparator;
|
---|
396 | maxEvaluatedSolutionsComparator.Successor = analyzer2;
|
---|
397 | analyzer2.Successor = conditionalBranchTerminate;
|
---|
398 | conditionalBranchTerminate.FalseBranch = conditionalBranchTerminateSelPressure;
|
---|
399 | conditionalBranchTerminate.TrueBranch = null;
|
---|
400 | conditionalBranchTerminate.Successor = null;
|
---|
401 | conditionalBranchTerminateSelPressure.FalseBranch = conditionalBranchTerminateEvalSolutions;
|
---|
402 | conditionalBranchTerminateSelPressure.TrueBranch = null;
|
---|
403 | conditionalBranchTerminateSelPressure.Successor = null;
|
---|
404 | conditionalBranchTerminateEvalSolutions.FalseBranch = selector;
|
---|
405 | conditionalBranchTerminateEvalSolutions.TrueBranch = null;
|
---|
406 | conditionalBranchTerminateEvalSolutions.Successor = null;
|
---|
407 |
|
---|
408 | #endregion
|
---|
409 | }
|
---|
410 |
|
---|
411 | public override IOperation Apply() {
|
---|
412 | if (MutatorParameter.ActualValue == null)
|
---|
413 | return null;
|
---|
414 | return base.Apply();
|
---|
415 | }
|
---|
416 | }
|
---|
417 | }
|
---|