1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2012 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.Analysis;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Data;
|
---|
26 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
27 | using HeuristicLab.Optimization;
|
---|
28 | using HeuristicLab.Parameters;
|
---|
29 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
30 | using HeuristicLab.PluginInfrastructure;
|
---|
31 | using System;
|
---|
32 | using System.Collections.Generic;
|
---|
33 | using System.Linq;
|
---|
34 |
|
---|
35 | namespace HeuristicLab.Problems.TestFunctions {
|
---|
36 | [Item("Single Objective Test Function", "Test function with real valued inputs and a single objective.")]
|
---|
37 | [StorableClass]
|
---|
38 | [Creatable("Problems")]
|
---|
39 | public sealed class SingleObjectiveTestFunctionProblem : SingleObjectiveHeuristicOptimizationProblem<ISingleObjectiveTestFunctionProblemEvaluator, IRealVectorCreator>, IStorableContent {
|
---|
40 | public string Filename { get; set; }
|
---|
41 |
|
---|
42 | [Storable]
|
---|
43 | private StdDevStrategyVectorCreator strategyVectorCreator;
|
---|
44 | [Storable]
|
---|
45 | private StdDevStrategyVectorCrossover strategyVectorCrossover;
|
---|
46 | [Storable]
|
---|
47 | private StdDevStrategyVectorManipulator strategyVectorManipulator;
|
---|
48 |
|
---|
49 | #region Parameter Properties
|
---|
50 | public ValueParameter<DoubleMatrix> BoundsParameter {
|
---|
51 | get { return (ValueParameter<DoubleMatrix>)Parameters["Bounds"]; }
|
---|
52 | }
|
---|
53 | public ValueParameter<IntValue> ProblemSizeParameter {
|
---|
54 | get { return (ValueParameter<IntValue>)Parameters["ProblemSize"]; }
|
---|
55 | }
|
---|
56 | public OptionalValueParameter<RealVector> BestKnownSolutionParameter {
|
---|
57 | get { return (OptionalValueParameter<RealVector>)Parameters["BestKnownSolution"]; }
|
---|
58 | }
|
---|
59 | #endregion
|
---|
60 |
|
---|
61 | #region Properties
|
---|
62 | public DoubleMatrix Bounds {
|
---|
63 | get { return BoundsParameter.Value; }
|
---|
64 | set { BoundsParameter.Value = value; }
|
---|
65 | }
|
---|
66 | public IntValue ProblemSize {
|
---|
67 | get { return ProblemSizeParameter.Value; }
|
---|
68 | set { ProblemSizeParameter.Value = value; }
|
---|
69 | }
|
---|
70 | private BestSingleObjectiveTestFunctionSolutionAnalyzer BestSingleObjectiveTestFunctionSolutionAnalyzer {
|
---|
71 | get { return Operators.OfType<BestSingleObjectiveTestFunctionSolutionAnalyzer>().FirstOrDefault(); }
|
---|
72 | }
|
---|
73 | private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {
|
---|
74 | get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }
|
---|
75 | }
|
---|
76 | #endregion
|
---|
77 |
|
---|
78 | // BackwardsCompatibility3.3
|
---|
79 | #region Backwards compatible code, remove with 3.4
|
---|
80 | [Obsolete]
|
---|
81 | [Storable(Name = "operators")]
|
---|
82 | private IEnumerable<IOperator> oldOperators {
|
---|
83 | get { return null; }
|
---|
84 | set {
|
---|
85 | if (value != null && value.Any())
|
---|
86 | Operators.AddRange(value);
|
---|
87 | }
|
---|
88 | }
|
---|
89 | #endregion
|
---|
90 |
|
---|
91 | [StorableConstructor]
|
---|
92 | private SingleObjectiveTestFunctionProblem(bool deserializing) : base(deserializing) { }
|
---|
93 | private SingleObjectiveTestFunctionProblem(SingleObjectiveTestFunctionProblem original, Cloner cloner)
|
---|
94 | : base(original, cloner) {
|
---|
95 | strategyVectorCreator = cloner.Clone(original.strategyVectorCreator);
|
---|
96 | strategyVectorCrossover = cloner.Clone(original.strategyVectorCrossover);
|
---|
97 | strategyVectorManipulator = cloner.Clone(original.strategyVectorManipulator);
|
---|
98 | RegisterEventHandlers();
|
---|
99 | }
|
---|
100 | public SingleObjectiveTestFunctionProblem()
|
---|
101 | : base(new AckleyEvaluator(), new UniformRandomRealVectorCreator()) {
|
---|
102 | Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension.", Evaluator.Bounds));
|
---|
103 | Parameters.Add(new ValueParameter<IntValue>("ProblemSize", "The dimension of the problem.", new IntValue(2)));
|
---|
104 | Parameters.Add(new OptionalValueParameter<RealVector>("BestKnownSolution", "The best known solution for this test function instance."));
|
---|
105 |
|
---|
106 | Maximization.Value = Evaluator.Maximization;
|
---|
107 | BestKnownQuality = new DoubleValue(Evaluator.BestKnownQuality);
|
---|
108 |
|
---|
109 | strategyVectorCreator = new StdDevStrategyVectorCreator();
|
---|
110 | strategyVectorCreator.LengthParameter.ActualName = ProblemSizeParameter.Name;
|
---|
111 | strategyVectorCrossover = new StdDevStrategyVectorCrossover();
|
---|
112 | strategyVectorManipulator = new StdDevStrategyVectorManipulator();
|
---|
113 | strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(0.5);
|
---|
114 | strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(0.5);
|
---|
115 |
|
---|
116 | SolutionCreator.RealVectorParameter.ActualName = "Point";
|
---|
117 | ParameterizeSolutionCreator();
|
---|
118 | ParameterizeEvaluator();
|
---|
119 |
|
---|
120 | InitializeOperators();
|
---|
121 | RegisterEventHandlers();
|
---|
122 | UpdateStrategyVectorBounds();
|
---|
123 | }
|
---|
124 |
|
---|
125 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
126 | return new SingleObjectiveTestFunctionProblem(this, cloner);
|
---|
127 | }
|
---|
128 |
|
---|
129 | #region Events
|
---|
130 | protected override void OnSolutionCreatorChanged() {
|
---|
131 | base.OnSolutionCreatorChanged();
|
---|
132 | ParameterizeSolutionCreator();
|
---|
133 | ParameterizeAnalyzers();
|
---|
134 | SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
|
---|
135 | SolutionCreator_RealVectorParameter_ActualNameChanged(null, EventArgs.Empty);
|
---|
136 | }
|
---|
137 | protected override void OnEvaluatorChanged() {
|
---|
138 | base.OnEvaluatorChanged();
|
---|
139 | bool problemSizeChange = ProblemSize.Value < Evaluator.MinimumProblemSize
|
---|
140 | || ProblemSize.Value > Evaluator.MaximumProblemSize;
|
---|
141 | if (problemSizeChange) {
|
---|
142 | ProblemSize.Value = Math.Max(Evaluator.MinimumProblemSize, Math.Min(ProblemSize.Value, Evaluator.MaximumProblemSize));
|
---|
143 | } else {
|
---|
144 | ParameterizeEvaluator();
|
---|
145 | }
|
---|
146 | UpdateMoveEvaluators();
|
---|
147 | ParameterizeAnalyzers();
|
---|
148 | Maximization.Value = Evaluator.Maximization;
|
---|
149 | BoundsParameter.Value = Evaluator.Bounds;
|
---|
150 | BestKnownQuality = new DoubleValue(Evaluator.BestKnownQuality);
|
---|
151 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
152 | Evaluator_QualityParameter_ActualNameChanged(null, EventArgs.Empty);
|
---|
153 | OnReset();
|
---|
154 | }
|
---|
155 | private void ProblemSizeParameter_ValueChanged(object sender, EventArgs e) {
|
---|
156 | ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
|
---|
157 | ProblemSize_ValueChanged(null, EventArgs.Empty);
|
---|
158 | }
|
---|
159 | private void ProblemSize_ValueChanged(object sender, EventArgs e) {
|
---|
160 | if (ProblemSize.Value < 1) ProblemSize.Value = 1;
|
---|
161 | ParameterizeSolutionCreator();
|
---|
162 | ParameterizeEvaluator();
|
---|
163 | strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * ProblemSize.Value));
|
---|
164 | strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * Math.Sqrt(ProblemSize.Value)));
|
---|
165 | OnReset();
|
---|
166 | }
|
---|
167 | private void SolutionCreator_RealVectorParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
168 | ParameterizeEvaluator();
|
---|
169 | ParameterizeOperators();
|
---|
170 | ParameterizeAnalyzers();
|
---|
171 | }
|
---|
172 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
173 | ParameterizeOperators();
|
---|
174 | }
|
---|
175 | private void BoundsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
176 | Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged);
|
---|
177 | Bounds_ToStringChanged(null, EventArgs.Empty);
|
---|
178 | }
|
---|
179 | private void Bounds_ToStringChanged(object sender, EventArgs e) {
|
---|
180 | if (Bounds.Columns != 2 || Bounds.Rows < 1)
|
---|
181 | Bounds = new DoubleMatrix(1, 2);
|
---|
182 | ParameterizeOperators();
|
---|
183 | UpdateStrategyVectorBounds();
|
---|
184 | }
|
---|
185 | private void Bounds_ItemChanged(object sender, EventArgs<int, int> e) {
|
---|
186 | if (e.Value2 == 0 && Bounds[e.Value, 1] <= Bounds[e.Value, 0])
|
---|
187 | Bounds[e.Value, 1] = Bounds[e.Value, 0] + 0.1;
|
---|
188 | if (e.Value2 == 1 && Bounds[e.Value, 0] >= Bounds[e.Value, 1])
|
---|
189 | Bounds[e.Value, 0] = Bounds[e.Value, 1] - 0.1;
|
---|
190 | ParameterizeOperators();
|
---|
191 | UpdateStrategyVectorBounds();
|
---|
192 | }
|
---|
193 | private void MoveGenerator_AdditiveMoveParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
194 | string name = ((ILookupParameter<AdditiveMove>)sender).ActualName;
|
---|
195 | foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) {
|
---|
196 | op.AdditiveMoveParameter.ActualName = name;
|
---|
197 | }
|
---|
198 | }
|
---|
199 | private void SphereEvaluator_Parameter_ValueChanged(object sender, EventArgs e) {
|
---|
200 | SphereEvaluator eval = (Evaluator as SphereEvaluator);
|
---|
201 | if (eval != null) {
|
---|
202 | foreach (ISphereMoveEvaluator op in Operators.OfType<ISphereMoveEvaluator>()) {
|
---|
203 | op.C = eval.C;
|
---|
204 | op.Alpha = eval.Alpha;
|
---|
205 | }
|
---|
206 | }
|
---|
207 | }
|
---|
208 | private void RastriginEvaluator_Parameter_ValueChanged(object sender, EventArgs e) {
|
---|
209 | RastriginEvaluator eval = (Evaluator as RastriginEvaluator);
|
---|
210 | if (eval != null) {
|
---|
211 | foreach (IRastriginMoveEvaluator op in Operators.OfType<IRastriginMoveEvaluator>()) {
|
---|
212 | op.A = eval.A;
|
---|
213 | }
|
---|
214 | }
|
---|
215 | }
|
---|
216 | private void strategyVectorCreator_BoundsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
217 | strategyVectorManipulator.BoundsParameter.Value = (DoubleMatrix)strategyVectorCreator.BoundsParameter.Value.Clone();
|
---|
218 | }
|
---|
219 | private void strategyVectorCreator_StrategyParameterParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
220 | string name = strategyVectorCreator.StrategyParameterParameter.ActualName;
|
---|
221 | strategyVectorCrossover.ParentsParameter.ActualName = name;
|
---|
222 | strategyVectorCrossover.StrategyParameterParameter.ActualName = name;
|
---|
223 | strategyVectorManipulator.StrategyParameterParameter.ActualName = name;
|
---|
224 | }
|
---|
225 | #endregion
|
---|
226 |
|
---|
227 | #region Helpers
|
---|
228 | [StorableHook(HookType.AfterDeserialization)]
|
---|
229 | private void AfterDeserialization() {
|
---|
230 | // BackwardsCompatibility3.3
|
---|
231 | #region Backwards compatible code (remove with 3.4)
|
---|
232 | if (Operators.Count == 0) InitializeOperators();
|
---|
233 | #endregion
|
---|
234 | RegisterEventHandlers();
|
---|
235 | }
|
---|
236 |
|
---|
237 | private void RegisterEventHandlers() {
|
---|
238 | ProblemSizeParameter.ValueChanged += new EventHandler(ProblemSizeParameter_ValueChanged);
|
---|
239 | ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
|
---|
240 | BoundsParameter.ValueChanged += new EventHandler(BoundsParameter_ValueChanged);
|
---|
241 | Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged);
|
---|
242 | Bounds.ItemChanged += new EventHandler<EventArgs<int, int>>(Bounds_ItemChanged);
|
---|
243 | SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
|
---|
244 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
245 | strategyVectorCreator.BoundsParameter.ValueChanged += new EventHandler(strategyVectorCreator_BoundsParameter_ValueChanged);
|
---|
246 | strategyVectorCreator.StrategyParameterParameter.ActualNameChanged += new EventHandler(strategyVectorCreator_StrategyParameterParameter_ActualNameChanged);
|
---|
247 | }
|
---|
248 | private void ParameterizeAnalyzers() {
|
---|
249 | if (BestSingleObjectiveTestFunctionSolutionAnalyzer != null) {
|
---|
250 | BestSingleObjectiveTestFunctionSolutionAnalyzer.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
251 | BestSingleObjectiveTestFunctionSolutionAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
252 | BestSingleObjectiveTestFunctionSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
|
---|
253 | BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
|
---|
254 | BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
|
---|
255 | BestSingleObjectiveTestFunctionSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
256 | BestSingleObjectiveTestFunctionSolutionAnalyzer.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
|
---|
257 | BestSingleObjectiveTestFunctionSolutionAnalyzer.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
258 | }
|
---|
259 |
|
---|
260 | if (SingleObjectivePopulationDiversityAnalyzer != null) {
|
---|
261 | SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
262 | SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
|
---|
263 | SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
264 | SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<SingleObjectiveTestFunctionSimilarityCalculator>().SingleOrDefault();
|
---|
265 | }
|
---|
266 | }
|
---|
267 | private void InitializeOperators() {
|
---|
268 | Operators.Add(new SingleObjectiveTestFunctionImprovementOperator());
|
---|
269 | Operators.Add(new SingleObjectiveTestFunctionPathRelinker());
|
---|
270 | Operators.Add(new SingleObjectiveTestFunctionSimilarityCalculator());
|
---|
271 |
|
---|
272 | Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer());
|
---|
273 | Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());
|
---|
274 | ParameterizeAnalyzers();
|
---|
275 | Operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());
|
---|
276 | Operators.Add(strategyVectorCreator);
|
---|
277 | Operators.Add(strategyVectorCrossover);
|
---|
278 | Operators.Add(strategyVectorManipulator);
|
---|
279 | UpdateMoveEvaluators();
|
---|
280 | ParameterizeOperators();
|
---|
281 | InitializeMoveGenerators();
|
---|
282 | }
|
---|
283 | private void InitializeMoveGenerators() {
|
---|
284 | foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) {
|
---|
285 | if (op is IMoveGenerator) {
|
---|
286 | op.AdditiveMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_AdditiveMoveParameter_ActualNameChanged);
|
---|
287 | }
|
---|
288 | }
|
---|
289 | }
|
---|
290 | private void UpdateMoveEvaluators() {
|
---|
291 | foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList())
|
---|
292 | Operators.Remove(op);
|
---|
293 | foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>())
|
---|
294 | if (op.EvaluatorType == Evaluator.GetType()) {
|
---|
295 | Operators.Add(op);
|
---|
296 | #region Synchronize evaluator specific parameters with the parameters of the corresponding move evaluators
|
---|
297 | if (op is ISphereMoveEvaluator) {
|
---|
298 | SphereEvaluator e = (Evaluator as SphereEvaluator);
|
---|
299 | e.AlphaParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged);
|
---|
300 | e.CParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged);
|
---|
301 | ISphereMoveEvaluator em = (op as ISphereMoveEvaluator);
|
---|
302 | em.C = e.C;
|
---|
303 | em.Alpha = e.Alpha;
|
---|
304 | } else if (op is IRastriginMoveEvaluator) {
|
---|
305 | RastriginEvaluator e = (Evaluator as RastriginEvaluator);
|
---|
306 | e.AParameter.ValueChanged += new EventHandler(RastriginEvaluator_Parameter_ValueChanged);
|
---|
307 | IRastriginMoveEvaluator em = (op as IRastriginMoveEvaluator);
|
---|
308 | em.A = e.A;
|
---|
309 | }
|
---|
310 | #endregion
|
---|
311 | }
|
---|
312 | ParameterizeOperators();
|
---|
313 | OnOperatorsChanged();
|
---|
314 | }
|
---|
315 | private void ParameterizeSolutionCreator() {
|
---|
316 | SolutionCreator.LengthParameter.Value = new IntValue(ProblemSize.Value);
|
---|
317 | SolutionCreator.LengthParameter.Hidden = true;
|
---|
318 | SolutionCreator.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
319 | SolutionCreator.BoundsParameter.Hidden = true;
|
---|
320 | }
|
---|
321 | private void ParameterizeEvaluator() {
|
---|
322 | Evaluator.PointParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
323 | Evaluator.PointParameter.Hidden = true;
|
---|
324 | try {
|
---|
325 | BestKnownSolutionParameter.Value = Evaluator.GetBestKnownSolution(ProblemSize.Value);
|
---|
326 | } catch (ArgumentException e) {
|
---|
327 | ErrorHandling.ShowErrorDialog(e);
|
---|
328 | ProblemSize.Value = Evaluator.MinimumProblemSize;
|
---|
329 | }
|
---|
330 | }
|
---|
331 | private void ParameterizeOperators() {
|
---|
332 | foreach (var op in Operators.OfType<IRealVectorCrossover>()) {
|
---|
333 | op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
334 | op.ParentsParameter.Hidden = true;
|
---|
335 | op.ChildParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
336 | op.ChildParameter.Hidden = true;
|
---|
337 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
338 | op.BoundsParameter.Hidden = true;
|
---|
339 | }
|
---|
340 | foreach (var op in Operators.OfType<IRealVectorManipulator>()) {
|
---|
341 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
342 | op.RealVectorParameter.Hidden = true;
|
---|
343 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
344 | op.BoundsParameter.Hidden = true;
|
---|
345 | }
|
---|
346 | foreach (var op in Operators.OfType<IRealVectorMoveOperator>()) {
|
---|
347 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
348 | op.RealVectorParameter.Hidden = true;
|
---|
349 | }
|
---|
350 | foreach (var op in Operators.OfType<IRealVectorMoveGenerator>()) {
|
---|
351 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
352 | op.BoundsParameter.Hidden = true;
|
---|
353 | }
|
---|
354 | foreach (var op in Operators.OfType<ISingleObjectiveTestFunctionAdditiveMoveEvaluator>()) {
|
---|
355 | op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
|
---|
356 | op.QualityParameter.Hidden = true;
|
---|
357 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
358 | op.RealVectorParameter.Hidden = true;
|
---|
359 | }
|
---|
360 | foreach (var op in Operators.OfType<IRealVectorParticleCreator>()) {
|
---|
361 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
362 | op.RealVectorParameter.Hidden = true;
|
---|
363 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
364 | op.BoundsParameter.Hidden = true;
|
---|
365 | op.ProblemSizeParameter.ActualName = ProblemSizeParameter.Name;
|
---|
366 | op.ProblemSizeParameter.Hidden = true;
|
---|
367 | }
|
---|
368 | foreach (var op in Operators.OfType<IRealVectorParticleUpdater>()) {
|
---|
369 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
370 | op.RealVectorParameter.Hidden = true;
|
---|
371 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
372 | op.BoundsParameter.Hidden = true;
|
---|
373 | }
|
---|
374 | foreach (var op in Operators.OfType<IRealVectorSwarmUpdater>()) {
|
---|
375 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
376 | op.RealVectorParameter.Hidden = true;
|
---|
377 | op.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
378 | op.MaximizationParameter.Hidden = true;
|
---|
379 | }
|
---|
380 | foreach (var op in Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()) {
|
---|
381 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
382 | op.RealVectorParameter.Hidden = true;
|
---|
383 | }
|
---|
384 | foreach (var op in Operators.OfType<ISingleObjectiveImprovementOperator>()) {
|
---|
385 | op.SolutionParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
386 | op.SolutionParameter.Hidden = true;
|
---|
387 | }
|
---|
388 | foreach (var op in Operators.OfType<ISingleObjectivePathRelinker>()) {
|
---|
389 | op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
390 | op.ParentsParameter.Hidden = true;
|
---|
391 | }
|
---|
392 | foreach (var op in Operators.OfType<SingleObjectiveTestFunctionSimilarityCalculator>()) {
|
---|
393 | op.SolutionVariableName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
394 | op.QualityVariableName = Evaluator.QualityParameter.ActualName;
|
---|
395 | op.Bounds = Bounds;
|
---|
396 | }
|
---|
397 | }
|
---|
398 | private void UpdateStrategyVectorBounds() {
|
---|
399 | var strategyBounds = (DoubleMatrix)Bounds.Clone();
|
---|
400 | for (int i = 0; i < strategyBounds.Rows; i++) {
|
---|
401 | if (strategyBounds[i, 0] < 0) strategyBounds[i, 0] = 0;
|
---|
402 | strategyBounds[i, 1] = 0.1 * (Bounds[i, 1] - Bounds[i, 0]);
|
---|
403 | }
|
---|
404 | strategyVectorCreator.BoundsParameter.Value = strategyBounds;
|
---|
405 | }
|
---|
406 | #endregion
|
---|
407 | }
|
---|
408 | }
|
---|