1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2013 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.Linq;
|
---|
24 | using HeuristicLab.Algorithms.CMAEvolutionStrategy;
|
---|
25 | using HeuristicLab.Analysis;
|
---|
26 | using HeuristicLab.Common;
|
---|
27 | using HeuristicLab.Core;
|
---|
28 | using HeuristicLab.Data;
|
---|
29 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
30 | using HeuristicLab.Operators;
|
---|
31 | using HeuristicLab.Optimization;
|
---|
32 | using HeuristicLab.Optimization.Operators;
|
---|
33 | using HeuristicLab.Parameters;
|
---|
34 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
35 | using HeuristicLab.PluginInfrastructure;
|
---|
36 | using HeuristicLab.Random;
|
---|
37 | using HeuristicLab.Selection;
|
---|
38 |
|
---|
39 | namespace HeuristicLab.Algorithms.OffspringSelectionCMAEvolutionStrategy {
|
---|
40 | [Item("Offspring Selection CMA Evolution Strategy", "An evolution strategy with offspring selection based on covariance matrix adaptation.")]
|
---|
41 | [Creatable("Algorithms")]
|
---|
42 | [StorableClass]
|
---|
43 | public sealed class OffspringSelectionCMAEvolutionStrategy : HeuristicOptimizationEngineAlgorithm, IStorableContent {
|
---|
44 | public string Filename { get; set; }
|
---|
45 | #region Strings
|
---|
46 | private const string SeedName = "Seed";
|
---|
47 | private const string SetSeedRandomlyName = "SetSeedRandomly";
|
---|
48 | private const string PopulationSizeName = "PopulationSize";
|
---|
49 | private const string InitialIterationsName = "InitialIterations";
|
---|
50 | private const string InitialSigmaName = "InitialSigma";
|
---|
51 | private const string MuName = "Mu";
|
---|
52 | private const string CMAInitializerName = "CMAInitializer";
|
---|
53 | private const string CMAMutatorName = "CMAMutator";
|
---|
54 | private const string CMARecombinatorName = "CMARecombinator";
|
---|
55 | private const string CMAUpdaterName = "CMAUpdater";
|
---|
56 | private const string AnalyzerName = "Analyzer";
|
---|
57 | private const string MaximumGenerationsName = "MaximumGenerations";
|
---|
58 | private const string MaximumEvaluatedSolutionsName = "MaximumEvaluatedSolutions";
|
---|
59 | private const string TargetQualityName = "TargetQuality";
|
---|
60 | private const string MinimumQualityChangeName = "MinimumQualityChange";
|
---|
61 | private const string MinimumQualityHistoryChangeName = "MinimumQualityHistoryChange";
|
---|
62 | private const string MinimumStandardDeviationName = "MinimumStandardDeviation";
|
---|
63 | private const string MaximumStandardDeviationChangeName = "MaximumStandardDeviationChange";
|
---|
64 | #endregion
|
---|
65 |
|
---|
66 | #region Problem Properties
|
---|
67 | public override Type ProblemType {
|
---|
68 | get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
|
---|
69 | }
|
---|
70 | public new ISingleObjectiveHeuristicOptimizationProblem Problem {
|
---|
71 | get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; }
|
---|
72 | set { base.Problem = value; }
|
---|
73 | }
|
---|
74 | #endregion
|
---|
75 |
|
---|
76 | #region Parameter Properties
|
---|
77 | public IValueParameter<MultiAnalyzer> AnalyzerParameter {
|
---|
78 | get { return (IValueParameter<MultiAnalyzer>)Parameters[AnalyzerName]; }
|
---|
79 | }
|
---|
80 | private IFixedValueParameter<IntValue> SeedParameter {
|
---|
81 | get { return (IFixedValueParameter<IntValue>)Parameters[SeedName]; }
|
---|
82 | }
|
---|
83 | private IFixedValueParameter<BoolValue> SetSeedRandomlyParameter {
|
---|
84 | get { return (IFixedValueParameter<BoolValue>)Parameters[SetSeedRandomlyName]; }
|
---|
85 | }
|
---|
86 | private IFixedValueParameter<IntValue> PopulationSizeParameter {
|
---|
87 | get { return (IFixedValueParameter<IntValue>)Parameters[PopulationSizeName]; }
|
---|
88 | }
|
---|
89 | private IFixedValueParameter<IntValue> InitialIterationsParameter {
|
---|
90 | get { return (IFixedValueParameter<IntValue>)Parameters[InitialIterationsName]; }
|
---|
91 | }
|
---|
92 | public IValueParameter<DoubleArray> InitialSigmaParameter {
|
---|
93 | get { return (IValueParameter<DoubleArray>)Parameters[InitialSigmaName]; }
|
---|
94 | }
|
---|
95 | private OptionalValueParameter<IntValue> MuParameter {
|
---|
96 | get { return (OptionalValueParameter<IntValue>)Parameters[MuName]; }
|
---|
97 | }
|
---|
98 | public IConstrainedValueParameter<ICMAInitializer> CMAInitializerParameter {
|
---|
99 | get { return (IConstrainedValueParameter<ICMAInitializer>)Parameters[CMAInitializerName]; }
|
---|
100 | }
|
---|
101 | public IConstrainedValueParameter<ICMAManipulator> CMAMutatorParameter {
|
---|
102 | get { return (IConstrainedValueParameter<ICMAManipulator>)Parameters[CMAMutatorName]; }
|
---|
103 | }
|
---|
104 | public IConstrainedValueParameter<ICMARecombinator> CMARecombinatorParameter {
|
---|
105 | get { return (IConstrainedValueParameter<ICMARecombinator>)Parameters[CMARecombinatorName]; }
|
---|
106 | }
|
---|
107 | public IConstrainedValueParameter<ICMAUpdater> CMAUpdaterParameter {
|
---|
108 | get { return (IConstrainedValueParameter<ICMAUpdater>)Parameters[CMAUpdaterName]; }
|
---|
109 | }
|
---|
110 | private IFixedValueParameter<IntValue> MaximumGenerationsParameter {
|
---|
111 | get { return (IFixedValueParameter<IntValue>)Parameters[MaximumGenerationsName]; }
|
---|
112 | }
|
---|
113 | private IFixedValueParameter<IntValue> MaximumEvaluatedSolutionsParameter {
|
---|
114 | get { return (IFixedValueParameter<IntValue>)Parameters[MaximumEvaluatedSolutionsName]; }
|
---|
115 | }
|
---|
116 | private IFixedValueParameter<DoubleValue> TargetQualityParameter {
|
---|
117 | get { return (IFixedValueParameter<DoubleValue>)Parameters[TargetQualityName]; }
|
---|
118 | }
|
---|
119 | private IFixedValueParameter<DoubleValue> MinimumQualityChangeParameter {
|
---|
120 | get { return (IFixedValueParameter<DoubleValue>)Parameters[MinimumQualityChangeName]; }
|
---|
121 | }
|
---|
122 | private IFixedValueParameter<DoubleValue> MinimumQualityHistoryChangeParameter {
|
---|
123 | get { return (IFixedValueParameter<DoubleValue>)Parameters[MinimumQualityHistoryChangeName]; }
|
---|
124 | }
|
---|
125 | private IFixedValueParameter<DoubleValue> MinimumStandardDeviationParameter {
|
---|
126 | get { return (IFixedValueParameter<DoubleValue>)Parameters[MinimumStandardDeviationName]; }
|
---|
127 | }
|
---|
128 | private IFixedValueParameter<DoubleValue> MaximumStandardDeviationChangeParameter {
|
---|
129 | get { return (IFixedValueParameter<DoubleValue>)Parameters[MaximumStandardDeviationChangeName]; }
|
---|
130 | }
|
---|
131 |
|
---|
132 | private LookupParameter<DoubleValue> xMeanQualityParameter {
|
---|
133 | get { return (LookupParameter<DoubleValue>)Parameters["xMeanQuality"]; }
|
---|
134 | }
|
---|
135 | private LookupParameter<DoubleValue> CurrentSuccessRatioParameter {
|
---|
136 | get { return (LookupParameter<DoubleValue>)Parameters["CurrentSuccessRatio"]; }
|
---|
137 | }
|
---|
138 | private LookupParameter<DoubleValue> SelectionPressureParameter {
|
---|
139 | get { return (LookupParameter<DoubleValue>)Parameters["SelectionPressure"]; }
|
---|
140 | }
|
---|
141 | private ValueLookupParameter<DoubleValue> SuccessRatioParameter {
|
---|
142 | get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
|
---|
143 | }
|
---|
144 | private ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
|
---|
145 | get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
|
---|
146 | }
|
---|
147 |
|
---|
148 | #endregion
|
---|
149 |
|
---|
150 | #region Properties
|
---|
151 | public int Seed {
|
---|
152 | get { return SeedParameter.Value.Value; }
|
---|
153 | set { SeedParameter.Value.Value = value; }
|
---|
154 | }
|
---|
155 | public bool SetSeedRandomly {
|
---|
156 | get { return SetSeedRandomlyParameter.Value.Value; }
|
---|
157 | set { SetSeedRandomlyParameter.Value.Value = value; }
|
---|
158 | }
|
---|
159 | public int PopulationSize {
|
---|
160 | get { return PopulationSizeParameter.Value.Value; }
|
---|
161 | set { PopulationSizeParameter.Value.Value = value; }
|
---|
162 | }
|
---|
163 | public int InitialIterations {
|
---|
164 | get { return InitialIterationsParameter.Value.Value; }
|
---|
165 | set { InitialIterationsParameter.Value.Value = value; }
|
---|
166 | }
|
---|
167 | public int MaximumGenerations {
|
---|
168 | get { return MaximumGenerationsParameter.Value.Value; }
|
---|
169 | set { MaximumGenerationsParameter.Value.Value = value; }
|
---|
170 | }
|
---|
171 | public int MaximumEvaluatedSolutions {
|
---|
172 | get { return MaximumEvaluatedSolutionsParameter.Value.Value; }
|
---|
173 | set { MaximumEvaluatedSolutionsParameter.Value.Value = value; }
|
---|
174 | }
|
---|
175 | public double TargetQuality {
|
---|
176 | get { return TargetQualityParameter.Value.Value; }
|
---|
177 | set { TargetQualityParameter.Value.Value = value; }
|
---|
178 | }
|
---|
179 | public double MinimumQualityChange {
|
---|
180 | get { return MinimumQualityChangeParameter.Value.Value; }
|
---|
181 | set { MinimumQualityChangeParameter.Value.Value = value; }
|
---|
182 | }
|
---|
183 | public double MinimumQualityHistoryChange {
|
---|
184 | get { return MinimumQualityHistoryChangeParameter.Value.Value; }
|
---|
185 | set { MinimumQualityHistoryChangeParameter.Value.Value = value; }
|
---|
186 | }
|
---|
187 | public double MinimumStandardDeviation {
|
---|
188 | get { return MinimumStandardDeviationParameter.Value.Value; }
|
---|
189 | set { MinimumStandardDeviationParameter.Value.Value = value; }
|
---|
190 | }
|
---|
191 | public double MaximumStandardDeviationChange {
|
---|
192 | get { return MaximumStandardDeviationChangeParameter.Value.Value; }
|
---|
193 | set { MaximumStandardDeviationChangeParameter.Value.Value = value; }
|
---|
194 | }
|
---|
195 | public DoubleArray InitialSigma {
|
---|
196 | get { return InitialSigmaParameter.Value; }
|
---|
197 | set { InitialSigmaParameter.Value = value; }
|
---|
198 | }
|
---|
199 | public IntValue Mu {
|
---|
200 | get { return MuParameter.Value; }
|
---|
201 | set { MuParameter.Value = value; }
|
---|
202 | }
|
---|
203 | public ICMAInitializer CMAInitializer {
|
---|
204 | get { return CMAInitializerParameter.Value; }
|
---|
205 | set { CMAInitializerParameter.Value = value; }
|
---|
206 | }
|
---|
207 | public ICMAManipulator CMAMutator {
|
---|
208 | get { return CMAMutatorParameter.Value; }
|
---|
209 | set { CMAMutatorParameter.Value = value; }
|
---|
210 | }
|
---|
211 | public ICMARecombinator CMARecombinator {
|
---|
212 | get { return CMARecombinatorParameter.Value; }
|
---|
213 | set { CMARecombinatorParameter.Value = value; }
|
---|
214 | }
|
---|
215 | public MultiAnalyzer Analyzer {
|
---|
216 | get { return AnalyzerParameter.Value; }
|
---|
217 | set { AnalyzerParameter.Value = value; }
|
---|
218 | }
|
---|
219 | public ICMAUpdater CMAUpdater {
|
---|
220 | get { return CMAUpdaterParameter.Value; }
|
---|
221 | set { CMAUpdaterParameter.Value = value; }
|
---|
222 | }
|
---|
223 |
|
---|
224 | public DoubleValue SuccessRatio {
|
---|
225 | get { return SuccessRatioParameter.Value; }
|
---|
226 | set { SuccessRatioParameter.Value = value; }
|
---|
227 | }
|
---|
228 | public DoubleValue MaximumSelectionPressure {
|
---|
229 | get { return MaximumSelectionPressureParameter.Value; }
|
---|
230 | set { MaximumSelectionPressureParameter.Value = value; }
|
---|
231 | }
|
---|
232 |
|
---|
233 | private RandomCreator RandomCreator {
|
---|
234 | get { return (RandomCreator)OperatorGraph.InitialOperator; }
|
---|
235 | }
|
---|
236 |
|
---|
237 | [Storable]
|
---|
238 | private BestAverageWorstQualityAnalyzer qualityAnalyzer;
|
---|
239 | [Storable]
|
---|
240 | private CMAAnalyzer cmaAnalyzer;
|
---|
241 | [Storable]
|
---|
242 | private Placeholder solutionCreator;
|
---|
243 | [Storable]
|
---|
244 | private Placeholder evaluator;
|
---|
245 | [Storable]
|
---|
246 | private SubScopesSorter sorter;
|
---|
247 | [Storable]
|
---|
248 | private OffspringSelectionCMATerminator terminator;
|
---|
249 | [Storable]
|
---|
250 | private Placeholder xMeanEvaluator;
|
---|
251 | [Storable]
|
---|
252 | private QualityComparator parentsComparator;
|
---|
253 | [Storable]
|
---|
254 | private Assigner xMeanQualityAssigner;
|
---|
255 | [Storable]
|
---|
256 | private Remover qualityRemover;
|
---|
257 | [Storable]
|
---|
258 | private CMAEvolutionStrategyOffspringSelector offspringSelector;
|
---|
259 | [Storable]
|
---|
260 | private ValueAnalyzer selectionPressureAnalyzer;
|
---|
261 | #endregion
|
---|
262 |
|
---|
263 | [StorableConstructor]
|
---|
264 | private OffspringSelectionCMAEvolutionStrategy(bool deserializing) : base(deserializing) { }
|
---|
265 | private OffspringSelectionCMAEvolutionStrategy(OffspringSelectionCMAEvolutionStrategy original, Cloner cloner)
|
---|
266 | : base(original, cloner) {
|
---|
267 | qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
|
---|
268 | cmaAnalyzer = cloner.Clone(original.cmaAnalyzer);
|
---|
269 | solutionCreator = cloner.Clone(original.solutionCreator);
|
---|
270 | evaluator = cloner.Clone(original.evaluator);
|
---|
271 | sorter = cloner.Clone(original.sorter);
|
---|
272 | terminator = cloner.Clone(original.terminator);
|
---|
273 |
|
---|
274 | xMeanEvaluator = cloner.Clone(original.xMeanEvaluator);
|
---|
275 | parentsComparator = cloner.Clone(original.parentsComparator);
|
---|
276 | xMeanQualityAssigner = cloner.Clone(original.xMeanQualityAssigner);
|
---|
277 | qualityRemover = cloner.Clone(original.qualityRemover);
|
---|
278 | offspringSelector = cloner.Clone(original.offspringSelector);
|
---|
279 | selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
|
---|
280 |
|
---|
281 | RegisterEventHandlers();
|
---|
282 | }
|
---|
283 | public OffspringSelectionCMAEvolutionStrategy()
|
---|
284 | : base() {
|
---|
285 | Parameters.Add(new FixedValueParameter<IntValue>(SeedName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
|
---|
286 | Parameters.Add(new FixedValueParameter<BoolValue>(SetSeedRandomlyName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
|
---|
287 | Parameters.Add(new FixedValueParameter<IntValue>(PopulationSizeName, "λ (lambda) - the size of the offspring population.", new IntValue(20)));
|
---|
288 | Parameters.Add(new FixedValueParameter<IntValue>(InitialIterationsName, "The number of iterations that should be performed with only axis parallel mutation.", new IntValue(0)));
|
---|
289 | Parameters.Add(new FixedValueParameter<DoubleArray>(InitialSigmaName, "The initial sigma can be a single value or a value for each dimension. All values need to be > 0.", new DoubleArray(new[] { 0.5 })));
|
---|
290 | Parameters.Add(new OptionalValueParameter<IntValue>(MuName, "Optional, the mu best offspring that should be considered for update of the new mean and strategy parameters. If not given it will be automatically calculated."));
|
---|
291 | Parameters.Add(new ConstrainedValueParameter<ICMARecombinator>(CMARecombinatorName, "The operator used to calculate the new mean."));
|
---|
292 | Parameters.Add(new ConstrainedValueParameter<ICMAManipulator>(CMAMutatorName, "The operator used to manipulate a point."));
|
---|
293 | Parameters.Add(new ConstrainedValueParameter<ICMAInitializer>(CMAInitializerName, "The operator that initializes the covariance matrix and strategy parameters."));
|
---|
294 | Parameters.Add(new ConstrainedValueParameter<ICMAUpdater>(CMAUpdaterName, "The operator that updates the covariance matrix and strategy parameters."));
|
---|
295 | Parameters.Add(new ValueParameter<MultiAnalyzer>(AnalyzerName, "The operator used to analyze each generation.", new MultiAnalyzer()));
|
---|
296 | Parameters.Add(new FixedValueParameter<IntValue>(MaximumGenerationsName, "The maximum number of generations which should be processed.", new IntValue(1000)));
|
---|
297 | Parameters.Add(new FixedValueParameter<IntValue>(MaximumEvaluatedSolutionsName, "The maximum number of evaluated solutions that should be computed.", new IntValue(int.MaxValue)));
|
---|
298 | Parameters.Add(new FixedValueParameter<DoubleValue>(TargetQualityName, "(stopFitness) Surpassing this quality value terminates the algorithm.", new DoubleValue(double.NaN)));
|
---|
299 | Parameters.Add(new FixedValueParameter<DoubleValue>(MinimumQualityChangeName, "(stopTolFun) If the range of fitness values is less than a certain value the algorithm terminates (set to 0 or positive value to enable).", new DoubleValue(double.NaN)));
|
---|
300 | Parameters.Add(new FixedValueParameter<DoubleValue>(MinimumQualityHistoryChangeName, "(stopTolFunHist) If the range of fitness values is less than a certain value for a certain time the algorithm terminates (set to 0 or positive to enable).", new DoubleValue(double.NaN)));
|
---|
301 | Parameters.Add(new FixedValueParameter<DoubleValue>(MinimumStandardDeviationName, "(stopTolXFactor) If the standard deviation falls below a certain value the algorithm terminates (set to 0 or positive to enable).", new DoubleValue(double.NaN)));
|
---|
302 | Parameters.Add(new FixedValueParameter<DoubleValue>(MaximumStandardDeviationChangeName, "(stopTolUpXFactor) If the standard deviation changes by a value larger than this parameter the algorithm stops (set to a value > 0 to enable).", new DoubleValue(double.NaN)));
|
---|
303 |
|
---|
304 | Parameters.Add(new LookupParameter<DoubleValue>("xMeanQuality", "The value which represents the quality of the current xMean."));
|
---|
305 | Parameters.Add(new LookupParameter<DoubleValue>("CurrentSuccessRatio", "The current success ratio."));
|
---|
306 | Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
|
---|
307 | Parameters.Add(new LookupParameter<DoubleValue>("SelectionPressure", "The actual selection pressure."));
|
---|
308 | Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
|
---|
309 |
|
---|
310 | var randomCreator = new RandomCreator();
|
---|
311 | var variableCreator = new VariableCreator();
|
---|
312 | var resultsCollector = new ResultsCollector();
|
---|
313 | var cmaInitializer = new Placeholder();
|
---|
314 | solutionCreator = new Placeholder();
|
---|
315 | var subScopesCreator = new SubScopesCreator();
|
---|
316 | var cmaMutator = new Placeholder();
|
---|
317 | var ussp = new UniformSubScopesProcessor();
|
---|
318 | evaluator = new Placeholder();
|
---|
319 | var subScopesCounter = new SubScopesCounter();
|
---|
320 | sorter = new SubScopesSorter();
|
---|
321 | var analyzer = new Placeholder();
|
---|
322 | var cmaRecombinator = new Placeholder();
|
---|
323 | var generationsCounter = new IntCounter();
|
---|
324 | var cmaUpdater = new Placeholder();
|
---|
325 | terminator = new OffspringSelectionCMATerminator();
|
---|
326 |
|
---|
327 | parentsComparator = new QualityComparator();
|
---|
328 | xMeanEvaluator = new Placeholder();
|
---|
329 | xMeanQualityAssigner = new Assigner();
|
---|
330 | qualityRemover = new Remover();
|
---|
331 | offspringSelector = new CMAEvolutionStrategyOffspringSelector();
|
---|
332 | IntCounter evalSolutionsIncrement = new IntCounter();
|
---|
333 | SubScopesRemover populationRemover = new SubScopesRemover();
|
---|
334 |
|
---|
335 | OperatorGraph.InitialOperator = randomCreator;
|
---|
336 |
|
---|
337 | randomCreator.RandomParameter.ActualName = "Random";
|
---|
338 | randomCreator.SeedParameter.ActualName = SeedParameter.Name;
|
---|
339 | randomCreator.SeedParameter.Value = null;
|
---|
340 | randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
|
---|
341 | randomCreator.SetSeedRandomlyParameter.Value = null;
|
---|
342 | randomCreator.Successor = variableCreator;
|
---|
343 |
|
---|
344 | variableCreator.Name = "Initialize Variables";
|
---|
345 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
|
---|
346 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
|
---|
347 | variableCreator.Successor = resultsCollector;
|
---|
348 |
|
---|
349 | resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions"));
|
---|
350 | resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
|
---|
351 | resultsCollector.ResultsParameter.ActualName = "Results";
|
---|
352 | resultsCollector.Successor = cmaInitializer;
|
---|
353 |
|
---|
354 | cmaInitializer.Name = "Initialize Strategy Parameters";
|
---|
355 | cmaInitializer.OperatorParameter.ActualName = CMAInitializerParameter.Name;
|
---|
356 | cmaInitializer.Successor = solutionCreator;
|
---|
357 |
|
---|
358 | solutionCreator.Name = "Initialize xmean";
|
---|
359 | // solutionCreator.OperatorParameter will be wired
|
---|
360 |
|
---|
361 | xMeanEvaluator.Name = "Evaluate xmean";
|
---|
362 | // xMeanEvaluator.OperatorParameter will be wired
|
---|
363 | xMeanQualityAssigner.Name = "Memorize xmean quality";
|
---|
364 | xMeanQualityAssigner.LeftSideParameter.ActualName = xMeanQualityParameter.Name;
|
---|
365 | //xMeanQualityAssigner.RightSideParameter.ActualName will be wired
|
---|
366 | qualityRemover.Name = "Remove quality";
|
---|
367 | //xMeanQualityRemover.TargetParameter.ActualName will be wired
|
---|
368 |
|
---|
369 | evalSolutionsIncrement.Name = "EvaluatedSolutions++";
|
---|
370 | evalSolutionsIncrement.IncrementParameter.Value = new IntValue(1);
|
---|
371 | evalSolutionsIncrement.ValueParameter.ActualName = "EvaluatedSolutions";
|
---|
372 |
|
---|
373 | solutionCreator.Successor = xMeanEvaluator;
|
---|
374 | xMeanEvaluator.Successor = xMeanQualityAssigner;
|
---|
375 | xMeanQualityAssigner.Successor = qualityRemover;
|
---|
376 | qualityRemover.Successor = evalSolutionsIncrement;
|
---|
377 | evalSolutionsIncrement.Successor = subScopesCreator;
|
---|
378 |
|
---|
379 | subScopesCreator.Name = "create population";
|
---|
380 | subScopesCreator.NumberOfSubScopesParameter.ActualName = PopulationSizeParameter.Name;
|
---|
381 | subScopesCreator.Successor = cmaMutator;
|
---|
382 |
|
---|
383 | cmaMutator.Name = "Sample population";
|
---|
384 | cmaMutator.OperatorParameter.ActualName = CMAMutatorParameter.Name;
|
---|
385 | cmaMutator.Successor = ussp;
|
---|
386 |
|
---|
387 | ussp.Name = "Evaluate offspring";
|
---|
388 | ussp.Parallel = new BoolValue(true);
|
---|
389 | ussp.Operator = evaluator;
|
---|
390 | ussp.Successor = subScopesCounter;
|
---|
391 |
|
---|
392 | parentsComparator.Name = "Compare to parent";
|
---|
393 | //parentsComparator.MaximizationParameter.ActualName will be wired
|
---|
394 | //parentsComparator.LeftSideParameter.ActualName will be wired
|
---|
395 | parentsComparator.RightSideParameter.ActualName = xMeanQualityParameter.Name;
|
---|
396 | parentsComparator.ResultParameter.ActualName = "SuccessfulOffspring";
|
---|
397 |
|
---|
398 | evaluator.Name = "Evaluator";
|
---|
399 | // evaluator.OperatorParameter will be wired
|
---|
400 | evaluator.Successor = parentsComparator;
|
---|
401 | parentsComparator.Successor = null;
|
---|
402 |
|
---|
403 | subScopesCounter.Name = "Count EvaluatedSolutions";
|
---|
404 | subScopesCounter.AccumulateParameter.Value = new BoolValue(true);
|
---|
405 | subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
|
---|
406 |
|
---|
407 | offspringSelector.CurrentSuccessRatioParameter.ActualName = CurrentSuccessRatioParameter.Name;
|
---|
408 | offspringSelector.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
|
---|
409 | offspringSelector.SelectionPressureParameter.ActualName = SelectionPressureParameter.Name;
|
---|
410 | offspringSelector.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
|
---|
411 | offspringSelector.OffspringPopulationParameter.ActualName = "OffspringPopulation";
|
---|
412 | offspringSelector.OffspringPopulationWinnersParameter.ActualName = "OffspringPopulationWinners";
|
---|
413 | offspringSelector.SuccessfulOffspringParameter.ActualName = "SuccessfulOffspring";
|
---|
414 | //offspringSelector.QualityParameter.ActualName will be wired
|
---|
415 |
|
---|
416 | offspringSelector.OffspringCreator = subScopesCreator;
|
---|
417 | subScopesCounter.Successor = offspringSelector;
|
---|
418 | offspringSelector.Successor = sorter;
|
---|
419 |
|
---|
420 | // sorter.ValueParameter will be wired
|
---|
421 | // sorter.DescendingParameter will be wired
|
---|
422 | sorter.Successor = analyzer;
|
---|
423 |
|
---|
424 | analyzer.Name = "Analyzer";
|
---|
425 | analyzer.OperatorParameter.ActualName = AnalyzerParameter.Name;
|
---|
426 | analyzer.Successor = cmaRecombinator;
|
---|
427 |
|
---|
428 | cmaRecombinator.Name = "Create new xmean";
|
---|
429 | cmaRecombinator.OperatorParameter.ActualName = CMARecombinatorParameter.Name;
|
---|
430 | cmaRecombinator.Successor = generationsCounter;
|
---|
431 |
|
---|
432 | generationsCounter.Name = "Generations++";
|
---|
433 | generationsCounter.IncrementParameter.Value = new IntValue(1);
|
---|
434 | generationsCounter.ValueParameter.ActualName = "Generations";
|
---|
435 | generationsCounter.Successor = cmaUpdater;
|
---|
436 |
|
---|
437 | cmaUpdater.Name = "Update distributions";
|
---|
438 | cmaUpdater.OperatorParameter.ActualName = CMAUpdaterParameter.Name;
|
---|
439 | cmaUpdater.Successor = terminator;
|
---|
440 |
|
---|
441 | populationRemover.RemoveAllSubScopes = true;
|
---|
442 |
|
---|
443 | terminator.Continue = populationRemover;
|
---|
444 | populationRemover.Successor = xMeanEvaluator;
|
---|
445 |
|
---|
446 | terminator.Terminate = null;
|
---|
447 |
|
---|
448 | qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
|
---|
449 | cmaAnalyzer = new CMAAnalyzer();
|
---|
450 | selectionPressureAnalyzer = new ValueAnalyzer();
|
---|
451 |
|
---|
452 | InitializeOperators();
|
---|
453 | RegisterEventHandlers();
|
---|
454 | Parameterize();
|
---|
455 | }
|
---|
456 |
|
---|
457 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
458 | return new OffspringSelectionCMAEvolutionStrategy(this, cloner);
|
---|
459 | }
|
---|
460 |
|
---|
461 | [StorableHook(HookType.AfterDeserialization)]
|
---|
462 | private void AfterDeserialization() {
|
---|
463 | RegisterEventHandlers();
|
---|
464 | }
|
---|
465 |
|
---|
466 | public override void Prepare() {
|
---|
467 | if (Problem != null) base.Prepare();
|
---|
468 | }
|
---|
469 |
|
---|
470 | protected override void OnStarted() {
|
---|
471 | if (!(Problem.SolutionCreator is IRealVectorCreator))
|
---|
472 | throw new InvalidOperationException("Problems that do not use RealVectorEncoding cannot be solved by OS-CMA-ES.");
|
---|
473 | base.OnStarted();
|
---|
474 | }
|
---|
475 |
|
---|
476 | #region Events
|
---|
477 | protected override void OnProblemChanged() {
|
---|
478 | Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
|
---|
479 | var creator = Problem.SolutionCreator as IRealVectorCreator;
|
---|
480 | if (creator != null) {
|
---|
481 | creator.RealVectorParameter.ActualNameChanged += RealVectorCreator_Changed;
|
---|
482 | creator.LengthParameter.ActualNameChanged += RealVectorCreator_Changed;
|
---|
483 | creator.LengthParameter.ValueChanged += RealVectorCreator_Changed;
|
---|
484 | creator.BoundsParameter.ActualNameChanged += RealVectorCreator_Changed;
|
---|
485 | creator.BoundsParameter.ValueChanged += RealVectorCreator_Changed;
|
---|
486 | }
|
---|
487 | UpdateOperators();
|
---|
488 | UpdateAnalyzers();
|
---|
489 | Parameterize();
|
---|
490 | base.OnProblemChanged();
|
---|
491 | }
|
---|
492 | protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
|
---|
493 | var creator = Problem.SolutionCreator as IRealVectorCreator;
|
---|
494 | if (creator != null) {
|
---|
495 | creator.RealVectorParameter.ActualNameChanged += RealVectorCreator_Changed;
|
---|
496 | creator.LengthParameter.ActualNameChanged += RealVectorCreator_Changed;
|
---|
497 | creator.LengthParameter.ValueChanged += RealVectorCreator_Changed;
|
---|
498 | creator.BoundsParameter.ActualNameChanged += RealVectorCreator_Changed;
|
---|
499 | creator.BoundsParameter.ValueChanged += RealVectorCreator_Changed;
|
---|
500 | }
|
---|
501 | Parameterize();
|
---|
502 | base.Problem_SolutionCreatorChanged(sender, e);
|
---|
503 | }
|
---|
504 | protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
|
---|
505 | Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
|
---|
506 | Parameterize();
|
---|
507 | base.Problem_EvaluatorChanged(sender, e);
|
---|
508 | }
|
---|
509 | protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
|
---|
510 | UpdateOperators();
|
---|
511 | UpdateAnalyzers();
|
---|
512 | Parameterize();
|
---|
513 | base.Problem_OperatorsChanged(sender, e);
|
---|
514 | }
|
---|
515 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
516 | Parameterize();
|
---|
517 | }
|
---|
518 | private bool cmaesInitializerSync;
|
---|
519 | private void CMAESInitializerParameter_ValueChanged(object sender, EventArgs e) {
|
---|
520 | if (cmaesInitializerSync) return;
|
---|
521 | UpdateOperators();
|
---|
522 | Parameterize();
|
---|
523 | }
|
---|
524 | private void RealVectorCreator_Changed(object sender, EventArgs e) {
|
---|
525 | Parameterize();
|
---|
526 | }
|
---|
527 | #endregion
|
---|
528 |
|
---|
529 | #region Helpers
|
---|
530 | private void RegisterEventHandlers() {
|
---|
531 | CMAInitializerParameter.ValueChanged += CMAESInitializerParameter_ValueChanged;
|
---|
532 | if (Problem != null) {
|
---|
533 | Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
|
---|
534 | var creator = Problem.SolutionCreator as IRealVectorCreator;
|
---|
535 | if (creator != null) {
|
---|
536 | creator.RealVectorParameter.ActualNameChanged += RealVectorCreator_Changed;
|
---|
537 | creator.LengthParameter.ActualNameChanged += RealVectorCreator_Changed;
|
---|
538 | creator.LengthParameter.ValueChanged += RealVectorCreator_Changed;
|
---|
539 | creator.BoundsParameter.ActualNameChanged += RealVectorCreator_Changed;
|
---|
540 | creator.BoundsParameter.ValueChanged += RealVectorCreator_Changed;
|
---|
541 | }
|
---|
542 | }
|
---|
543 | }
|
---|
544 | private void InitializeOperators() {
|
---|
545 | foreach (var op in ApplicationManager.Manager.GetInstances<ICMAInitializer>())
|
---|
546 | CMAInitializerParameter.ValidValues.Add(op);
|
---|
547 | foreach (var op in ApplicationManager.Manager.GetInstances<ICMAManipulator>().Where(x => x.CMAType == CMAInitializer.CMAType))
|
---|
548 | CMAMutatorParameter.ValidValues.Add(op);
|
---|
549 | foreach (var op in ApplicationManager.Manager.GetInstances<ICMARecombinator>().Where(x => x.CMAType == CMAInitializer.CMAType))
|
---|
550 | CMARecombinatorParameter.ValidValues.Add(op);
|
---|
551 | foreach (var op in ApplicationManager.Manager.GetInstances<ICMAUpdater>().Where(x => x.CMAType == CMAInitializer.CMAType))
|
---|
552 | CMAUpdaterParameter.ValidValues.Add(op);
|
---|
553 | }
|
---|
554 | private void UpdateOperators() {
|
---|
555 | cmaesInitializerSync = true;
|
---|
556 | try {
|
---|
557 | var oldMutator = CMAMutator;
|
---|
558 | var oldRecombinator = CMARecombinator;
|
---|
559 | var oldUpdater = CMAUpdater;
|
---|
560 |
|
---|
561 | if (CMAInitializer != null && (oldMutator == null || oldMutator.CMAType != CMAInitializer.CMAType)) {
|
---|
562 | CMAMutatorParameter.ValidValues.Clear();
|
---|
563 | foreach (var op in ApplicationManager.Manager.GetInstances<ICMAManipulator>().Where(x => x.CMAType == CMAInitializer.CMAType))
|
---|
564 | CMAMutatorParameter.ValidValues.Add(op);
|
---|
565 | CMAMutator = CMAMutatorParameter.ValidValues.First();
|
---|
566 | }
|
---|
567 |
|
---|
568 | if (CMAInitializer != null && (oldRecombinator == null || oldRecombinator.CMAType != CMAInitializer.CMAType)) {
|
---|
569 | CMARecombinatorParameter.ValidValues.Clear();
|
---|
570 | foreach (var op in ApplicationManager.Manager.GetInstances<ICMARecombinator>().Where(x => x.CMAType == CMAInitializer.CMAType))
|
---|
571 | CMARecombinatorParameter.ValidValues.Add(op);
|
---|
572 | CMARecombinator = CMARecombinatorParameter.ValidValues.First();
|
---|
573 | }
|
---|
574 |
|
---|
575 | if (CMAInitializer != null && (oldUpdater == null || oldUpdater.CMAType != CMAInitializer.CMAType)) {
|
---|
576 | CMAUpdaterParameter.ValidValues.Clear();
|
---|
577 | foreach (var op in ApplicationManager.Manager.GetInstances<ICMAUpdater>().Where(x => x.CMAType == CMAInitializer.CMAType))
|
---|
578 | CMAUpdaterParameter.ValidValues.Add(op);
|
---|
579 | CMAUpdater = CMAUpdaterParameter.ValidValues.First();
|
---|
580 | }
|
---|
581 | } finally { cmaesInitializerSync = false; }
|
---|
582 | }
|
---|
583 | private void UpdateAnalyzers() {
|
---|
584 | Analyzer.Operators.Clear();
|
---|
585 | if (Problem != null) {
|
---|
586 | foreach (var analyzer in Problem.Operators.OfType<IAnalyzer>()) {
|
---|
587 | foreach (var param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
|
---|
588 | param.Depth = 1;
|
---|
589 | Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault);
|
---|
590 | }
|
---|
591 | }
|
---|
592 | Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault);
|
---|
593 | Analyzer.Operators.Add(cmaAnalyzer, cmaAnalyzer.EnabledByDefault);
|
---|
594 | Analyzer.Operators.Add(selectionPressureAnalyzer, selectionPressureAnalyzer.EnabledByDefault);
|
---|
595 | }
|
---|
596 | private void Parameterize() {
|
---|
597 |
|
---|
598 | foreach (var op in CMAInitializerParameter.ValidValues) {
|
---|
599 | op.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
|
---|
600 | op.PopulationSizeParameter.Hidden = true;
|
---|
601 | op.MuParameter.ActualName = MuParameter.Name;
|
---|
602 | op.MuParameter.Hidden = true;
|
---|
603 | op.InitialIterationsParameter.Value = null;
|
---|
604 | op.InitialIterationsParameter.ActualName = InitialIterationsParameter.Name;
|
---|
605 | op.InitialIterationsParameter.Hidden = true;
|
---|
606 | op.InitialSigmaParameter.Value = null;
|
---|
607 | op.InitialSigmaParameter.ActualName = InitialSigmaParameter.Name;
|
---|
608 | op.InitialSigmaParameter.Hidden = true;
|
---|
609 |
|
---|
610 | op.DimensionParameter.Hidden = false;
|
---|
611 |
|
---|
612 | ParameterizeStochasticOperator(op);
|
---|
613 | ParameterizeIterationBasedOperator(op);
|
---|
614 | }
|
---|
615 |
|
---|
616 | foreach (var op in CMAMutatorParameter.ValidValues) {
|
---|
617 | op.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
|
---|
618 | op.PopulationSizeParameter.Hidden = true;
|
---|
619 |
|
---|
620 | op.MeanParameter.Hidden = false;
|
---|
621 | op.BoundsParameter.Hidden = false;
|
---|
622 | op.RealVectorParameter.Hidden = false;
|
---|
623 |
|
---|
624 | ParameterizeStochasticOperator(op);
|
---|
625 | ParameterizeIterationBasedOperator(op);
|
---|
626 | }
|
---|
627 |
|
---|
628 | foreach (var op in CMARecombinatorParameter.ValidValues) {
|
---|
629 | op.OldMeanParameter.ActualName = "XOld";
|
---|
630 | op.OldMeanParameter.Hidden = true;
|
---|
631 |
|
---|
632 | op.OffspringParameter.Hidden = false;
|
---|
633 | op.MeanParameter.Hidden = false;
|
---|
634 |
|
---|
635 | ParameterizeStochasticOperator(op);
|
---|
636 | ParameterizeIterationBasedOperator(op);
|
---|
637 | }
|
---|
638 |
|
---|
639 | foreach (var op in CMAUpdaterParameter.ValidValues) {
|
---|
640 | op.MaximumEvaluatedSolutionsParameter.ActualName = MaximumEvaluatedSolutionsParameter.Name;
|
---|
641 | op.MaximumEvaluatedSolutionsParameter.Hidden = true;
|
---|
642 | op.OldMeanParameter.ActualName = "XOld";
|
---|
643 | op.OldMeanParameter.Hidden = true;
|
---|
644 |
|
---|
645 | op.MeanParameter.Hidden = false;
|
---|
646 | op.OffspringParameter.Hidden = false;
|
---|
647 | op.QualityParameter.Hidden = false;
|
---|
648 |
|
---|
649 | ParameterizeStochasticOperator(op);
|
---|
650 | ParameterizeIterationBasedOperator(op);
|
---|
651 | }
|
---|
652 |
|
---|
653 | terminator.IterationsParameter.ActualName = "Generations";
|
---|
654 | terminator.MaximumIterationsParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
655 | terminator.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
|
---|
656 | terminator.InitialSigmaParameter.ActualName = InitialSigmaParameter.Name;
|
---|
657 | terminator.MaximumEvaluatedSolutionsParameter.ActualName = MaximumEvaluatedSolutionsParameter.Name;
|
---|
658 | terminator.MaximumStandardDeviationChangeParameter.ActualName = MaximumStandardDeviationChangeParameter.Name;
|
---|
659 | terminator.MinimumQualityChangeParameter.ActualName = MinimumQualityChangeParameter.Name;
|
---|
660 | terminator.MinimumQualityHistoryChangeParameter.ActualName = MinimumQualityHistoryChangeParameter.Name;
|
---|
661 | terminator.MinimumStandardDeviationParameter.ActualName = MinimumStandardDeviationParameter.Name;
|
---|
662 | terminator.TargetQualityParameter.ActualName = TargetQualityParameter.Name;
|
---|
663 | //FOR OFFSPRING SELECTION
|
---|
664 | terminator.SelectionPressureParameter.ActualName = SelectionPressureParameter.Name;
|
---|
665 | terminator.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
|
---|
666 | //END FOR OS
|
---|
667 |
|
---|
668 | if (CMAUpdater != null)
|
---|
669 | terminator.DegenerateStateParameter.ActualName = CMAUpdater.DegenerateStateParameter.ActualName;
|
---|
670 |
|
---|
671 | var creator = Problem != null ? (Problem.SolutionCreator as IRealVectorCreator) : null;
|
---|
672 | if (Problem != null && creator != null) {
|
---|
673 |
|
---|
674 | solutionCreator.OperatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
|
---|
675 | evaluator.OperatorParameter.ActualName = Problem.EvaluatorParameter.Name;
|
---|
676 |
|
---|
677 | xMeanEvaluator.OperatorParameter.ActualName = Problem.EvaluatorParameter.Name;
|
---|
678 | parentsComparator.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
679 | parentsComparator.LeftSideParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
|
---|
680 | xMeanQualityAssigner.RightSideParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
|
---|
681 | qualityRemover.TargetParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
|
---|
682 | offspringSelector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
|
---|
683 |
|
---|
684 | sorter.DescendingParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
685 | sorter.ValueParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
686 | terminator.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
687 | terminator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
|
---|
688 |
|
---|
689 | foreach (var op in CMAInitializerParameter.ValidValues) {
|
---|
690 | if (creator.LengthParameter.Value == null) {
|
---|
691 | op.DimensionParameter.ActualName = creator.LengthParameter.ActualName;
|
---|
692 | op.DimensionParameter.Value = null;
|
---|
693 | } else op.DimensionParameter.Value = creator.LengthParameter.Value;
|
---|
694 | op.DimensionParameter.Hidden = true;
|
---|
695 | }
|
---|
696 |
|
---|
697 | foreach (var op in CMAMutatorParameter.ValidValues) {
|
---|
698 | op.MeanParameter.ActualName = creator.RealVectorParameter.ActualName;
|
---|
699 | op.MeanParameter.Hidden = true;
|
---|
700 | if (creator.BoundsParameter.Value == null) {
|
---|
701 | op.BoundsParameter.ActualName = creator.BoundsParameter.ActualName;
|
---|
702 | op.BoundsParameter.Value = null;
|
---|
703 | } else op.BoundsParameter.Value = creator.BoundsParameter.Value;
|
---|
704 | op.BoundsParameter.Hidden = true;
|
---|
705 | op.RealVectorParameter.ActualName = creator.RealVectorParameter.ActualName;
|
---|
706 | op.RealVectorParameter.Depth = 1;
|
---|
707 | op.RealVectorParameter.Hidden = true;
|
---|
708 | }
|
---|
709 |
|
---|
710 | foreach (var op in CMARecombinatorParameter.ValidValues) {
|
---|
711 | op.MeanParameter.ActualName = creator.RealVectorParameter.ActualName;
|
---|
712 | op.MeanParameter.Hidden = true;
|
---|
713 | op.OffspringParameter.ActualName = creator.RealVectorParameter.ActualName;
|
---|
714 | op.OffspringParameter.Depth = 1;
|
---|
715 | op.OffspringParameter.Hidden = true;
|
---|
716 | }
|
---|
717 |
|
---|
718 | foreach (var op in CMAUpdaterParameter.ValidValues) {
|
---|
719 | op.MeanParameter.ActualName = creator.RealVectorParameter.ActualName;
|
---|
720 | op.MeanParameter.Hidden = true;
|
---|
721 | op.OffspringParameter.ActualName = creator.RealVectorParameter.ActualName;
|
---|
722 | op.OffspringParameter.Depth = 1;
|
---|
723 | op.OffspringParameter.Hidden = true;
|
---|
724 | op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
725 | op.QualityParameter.Hidden = true;
|
---|
726 | }
|
---|
727 |
|
---|
728 | foreach (var op in Problem.Operators.OfType<IStochasticOperator>()) {
|
---|
729 | op.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
|
---|
730 | op.RandomParameter.Hidden = true;
|
---|
731 | }
|
---|
732 |
|
---|
733 | qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
734 | qualityAnalyzer.MaximizationParameter.Hidden = true;
|
---|
735 | qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
736 | qualityAnalyzer.QualityParameter.Depth = 1;
|
---|
737 | qualityAnalyzer.QualityParameter.Hidden = true;
|
---|
738 | qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
|
---|
739 | qualityAnalyzer.BestKnownQualityParameter.Hidden = true;
|
---|
740 |
|
---|
741 | cmaAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
742 | cmaAnalyzer.QualityParameter.Depth = 1;
|
---|
743 | cmaAnalyzer.QualityParameter.Hidden = true;
|
---|
744 | cmaAnalyzer.MeanParameter.ActualName = creator.RealVectorParameter.ActualName;
|
---|
745 | cmaAnalyzer.MeanParameter.Hidden = true;
|
---|
746 |
|
---|
747 | foreach (var op in Problem.Operators.OfType<IIterationBasedOperator>()) {
|
---|
748 | op.IterationsParameter.ActualName = "Generations";
|
---|
749 | op.IterationsParameter.Hidden = true;
|
---|
750 | op.MaximumIterationsParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
751 | op.MaximumIterationsParameter.Hidden = true;
|
---|
752 | }
|
---|
753 | } else {
|
---|
754 | qualityAnalyzer.MaximizationParameter.Hidden = false;
|
---|
755 | qualityAnalyzer.QualityParameter.Hidden = false;
|
---|
756 | qualityAnalyzer.BestKnownQualityParameter.Hidden = false;
|
---|
757 |
|
---|
758 | cmaAnalyzer.MeanParameter.Hidden = false;
|
---|
759 | }
|
---|
760 |
|
---|
761 | selectionPressureAnalyzer.Name = "SelectionPressure Analyzer";
|
---|
762 | selectionPressureAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
763 | selectionPressureAnalyzer.ValueParameter.ActualName = "SelectionPressure";
|
---|
764 | selectionPressureAnalyzer.ValueParameter.Depth = 0;
|
---|
765 | selectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History";
|
---|
766 | selectionPressureAnalyzer.ResultsParameter.Hidden = true;
|
---|
767 |
|
---|
768 | qualityAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
769 | qualityAnalyzer.ResultsParameter.Hidden = true;
|
---|
770 | cmaAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
771 | cmaAnalyzer.ResultsParameter.Hidden = true;
|
---|
772 | }
|
---|
773 |
|
---|
774 | private void ParameterizeStochasticOperator(IOperator op) {
|
---|
775 | var sOp = op as IStochasticOperator;
|
---|
776 | if (sOp != null) sOp.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
|
---|
777 | }
|
---|
778 |
|
---|
779 | private void ParameterizeIterationBasedOperator(IOperator op) {
|
---|
780 | var iOp = op as IIterationBasedOperator;
|
---|
781 | if (iOp != null) {
|
---|
782 | iOp.IterationsParameter.ActualName = "Generations";
|
---|
783 | iOp.MaximumIterationsParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
784 | }
|
---|
785 | }
|
---|
786 | #endregion
|
---|
787 | }
|
---|
788 | }
|
---|