source: branches/2989_MovingPeaksBenchmark/HeuristicLab.Problems.MovingPeaksBenchmark/3.3/MovingPeaksBenchmarkProblem.cs @ 16608

Last change on this file since 16608 was 16608, checked in by swagner, 3 years ago

#2989: Worked on Moving Peaks Benchmark

File size: 23.1 KB
Line 
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
22using System;
23using System.Collections.Generic;
24using System.Linq;
25//using HeuristicLab.Analysis;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Data;
29using HeuristicLab.Encodings.RealVectorEncoding;
30using HeuristicLab.Optimization;
31//using HeuristicLab.Optimization.Operators;
32using HeuristicLab.Parameters;
33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
34using HeuristicLab.PluginInfrastructure;
35//using HeuristicLab.Problems.Instances;
36
37namespace HeuristicLab.Problems.MovingPeaksBenchmark {
38  [Item("Moving Peaks Benchmark", "Moving peaks benchmark problem for dynamic optimization.")]
39  [StorableClass]
40  [Creatable(CreatableAttribute.Categories.Problems, Priority = 97)]
41  public sealed class MovingPeaksBenchmarkProblem : SingleObjectiveHeuristicOptimizationProblem<IMovingPeaksBenchmarkProblemEvaluator, IRealVectorCreator>, IStorableContent {
42    public string Filename { get; set; }
43
44    //[Storable]
45    //private StdDevStrategyVectorCreator strategyVectorCreator;
46    //[Storable]
47    //private StdDevStrategyVectorCrossover strategyVectorCrossover;
48    //[Storable]
49    //private StdDevStrategyVectorManipulator strategyVectorManipulator;
50
51    #region Parameter Properties
52    public ValueParameter<DoubleMatrix> BoundsParameter {
53      get { return (ValueParameter<DoubleMatrix>)Parameters["Bounds"]; }
54    }
55    public ValueParameter<IntValue> ProblemSizeParameter {
56      get { return (ValueParameter<IntValue>)Parameters["ProblemSize"]; }
57    }
58    public ValueParameter<IntValue> PeaksParameter {
59      get { return (ValueParameter<IntValue>)Parameters["Peaks"]; }
60    }
61    public ValueParameter<DoubleMatrix> InitialPeakLocationsParameter {
62      get { return (ValueParameter<DoubleMatrix>)Parameters["InitialPeakLocations"]; }
63    }
64    public ValueParameter<DoubleMatrix> PeakLocationsParameter {
65      get { return (ValueParameter<DoubleMatrix>)Parameters["PeakLocations"]; }
66    }
67    public ValueParameter<DoubleArray> InitialPeakWidthsParameter {
68      get { return (ValueParameter<DoubleArray>)Parameters["InitialPeakWidths"]; }
69    }
70    public ValueParameter<DoubleArray> PeakWidthsParameter {
71      get { return (ValueParameter<DoubleArray>)Parameters["PeakWidths"]; }
72    }
73    public ValueParameter<DoubleArray> InitialPeakHeightsParameter {
74      get { return (ValueParameter<DoubleArray>)Parameters["InitialPeakHeights"]; }
75    }
76    public ValueParameter<DoubleArray> PeakHeightsParameter {
77      get { return (ValueParameter<DoubleArray>)Parameters["PeakHeights"]; }
78    }
79    public OptionalValueParameter<RealVector> BestKnownSolutionParameter {
80      get { return (OptionalValueParameter<RealVector>)Parameters["BestKnownSolution"]; }
81    }
82    #endregion
83
84    #region Properties
85    public DoubleMatrix Bounds {
86      get { return BoundsParameter.Value; }
87      set { BoundsParameter.Value = value; }
88    }
89    public IntValue ProblemSize {
90      get { return ProblemSizeParameter.Value; }
91      set { ProblemSizeParameter.Value = value; }
92    }
93    public IntValue Peaks {
94      get { return PeaksParameter.Value; }
95      set { PeaksParameter.Value = value; }
96    }
97    public DoubleMatrix InitialPeakLocations {
98      get { return InitialPeakLocationsParameter.Value; }
99      set { InitialPeakLocationsParameter.Value = value; }
100    }
101    public DoubleMatrix PeakLocations {
102      get { return PeakLocationsParameter.Value; }
103      set { PeakLocationsParameter.Value = value; }
104    }
105    public DoubleArray InitialPeakWidths {
106      get { return InitialPeakWidthsParameter.Value; }
107      set { InitialPeakWidthsParameter.Value = value; }
108    }
109    public DoubleArray PeakWidths {
110      get { return PeakWidthsParameter.Value; }
111      set { PeakWidthsParameter.Value = value; }
112    }
113    public DoubleArray InitialPeakHeights {
114      get { return InitialPeakHeightsParameter.Value; }
115      set { InitialPeakHeightsParameter.Value = value; }
116    }
117    public DoubleArray PeakHeights {
118      get { return PeakHeightsParameter.Value; }
119      set { PeakHeightsParameter.Value = value; }
120    }
121    //    private BestSingleObjectiveTestFunctionSolutionAnalyzer BestSingleObjectiveTestFunctionSolutionAnalyzer {
122    //      get { return Operators.OfType<BestSingleObjectiveTestFunctionSolutionAnalyzer>().FirstOrDefault(); }
123    //    }
124    #endregion
125
126    [StorableConstructor]
127    private MovingPeaksBenchmarkProblem(bool deserializing) : base(deserializing) { }
128    private MovingPeaksBenchmarkProblem(MovingPeaksBenchmarkProblem original, Cloner cloner)
129      : base(original, cloner) {
130      //strategyVectorCreator = cloner.Clone(original.strategyVectorCreator);
131      //strategyVectorCrossover = cloner.Clone(original.strategyVectorCrossover);
132      //strategyVectorManipulator = cloner.Clone(original.strategyVectorManipulator);
133      RegisterEventHandlers();
134    }
135    public MovingPeaksBenchmarkProblem()
136      : base(new MovingPeaksBenchmarkProblemEvaluator(), new UniformRandomRealVectorCreator()) {
137      var defaultBounds = new double[,] {
138        { 0.0, 100.0 }
139      };
140      var defaultPeaks = new double[,] {
141        { 08.0, 64.0, 67.0, 55.0, 04.0 },
142        { 50.0, 13.0, 76.0, 15.0, 07.0 },
143        { 09.0, 19.0, 27.0, 67.0, 24.0 },
144        { 66.0, 87.0, 65.0, 19.0, 43.0 },
145        { 76.0, 32.0, 43.0, 54.0, 65.0 }
146      };
147      var defaultWidths = new double[] { 0.1, 0.1, 0.1, 0.1, 0.1 };
148      var defaultHeights = new double[] { 50.0, 50.0, 50.0, 50.0, 50.0 };
149
150      Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension.", new DoubleMatrix(defaultBounds)));
151      Parameters.Add(new ValueParameter<IntValue>("ProblemSize", "The dimension of the problem.", new IntValue(5)));
152      Parameters.Add(new ValueParameter<IntValue>("Peaks", "The number of peaks.", new IntValue(5)));
153      Parameters.Add(new ValueParameter<DoubleMatrix>("InitialPeakLocations", "Initial coordinates of each peaks.", new DoubleMatrix(defaultPeaks)));
154      Parameters.Add(new ValueParameter<DoubleMatrix>("PeakLocations", "Current coordinates of each peaks.", new DoubleMatrix(defaultPeaks)));
155      Parameters.Add(new ValueParameter<DoubleArray>("InitialPeakWidths", "Initial width of each peak.", new DoubleArray(defaultWidths)));
156      Parameters.Add(new ValueParameter<DoubleArray>("PeakWidths", "Current width of each peak.", new DoubleArray(defaultWidths)));
157      Parameters.Add(new ValueParameter<DoubleArray>("InitialPeakHeights", "Initial height of each peak.", new DoubleArray(defaultHeights)));
158      Parameters.Add(new ValueParameter<DoubleArray>("PeakHeights", "Current height of each peak.", new DoubleArray(defaultHeights)));
159
160      //Parameters.Add(new OptionalValueParameter<RealVector>("BestKnownSolution", "The best known solution for this test function instance."));
161
162      Maximization.Value = true;
163      //BestKnownQuality = new DoubleValue(Evaluator.BestKnownQuality);
164
165      //strategyVectorCreator = new StdDevStrategyVectorCreator();
166      //strategyVectorCreator.LengthParameter.ActualName = ProblemSizeParameter.Name;
167      //strategyVectorCrossover = new StdDevStrategyVectorCrossover();
168      //strategyVectorManipulator = new StdDevStrategyVectorManipulator();
169      //strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(0.5);
170      //strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(0.5);
171
172      SolutionCreator.RealVectorParameter.ActualName = "Point";
173      ParameterizeSolutionCreator();
174      ParameterizeEvaluator();
175
176      InitializeOperators();
177      RegisterEventHandlers();
178      UpdateStrategyVectorBounds();
179    }
180
181    public override IDeepCloneable Clone(Cloner cloner) {
182      return new MovingPeaksBenchmarkProblem(this, cloner);
183    }
184
185    protected override void OnReset() {
186      base.OnReset();
187      PeakLocations = InitialPeakLocations.Clone() as DoubleMatrix;
188      PeakWidths = InitialPeakWidths.Clone() as DoubleArray;
189      PeakHeights = InitialPeakHeights.Clone() as DoubleArray;
190    }
191
192    #region Events
193    protected override void OnSolutionCreatorChanged() {
194      base.OnSolutionCreatorChanged();
195      ParameterizeSolutionCreator();
196      ParameterizeAnalyzers();
197      SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
198      SolutionCreator_RealVectorParameter_ActualNameChanged(null, EventArgs.Empty);
199    }
200    protected override void OnEvaluatorChanged() {
201      base.OnEvaluatorChanged();
202      ParameterizeEvaluator();
203      UpdateMoveEvaluators();
204      ParameterizeAnalyzers();
205      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
206      Evaluator_QualityParameter_ActualNameChanged(null, EventArgs.Empty);
207      OnReset();
208    }
209    private void ProblemSizeParameter_ValueChanged(object sender, EventArgs e) {
210      ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
211      ProblemSize_ValueChanged(null, EventArgs.Empty);
212    }
213    private void ProblemSize_ValueChanged(object sender, EventArgs e) {
214      if (ProblemSize.Value < 1) ProblemSize.Value = 1;
215      ParameterizeSolutionCreator();
216      ParameterizeEvaluator();
217      //strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * ProblemSize.Value));
218      //strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * Math.Sqrt(ProblemSize.Value)));
219      OnReset();
220    }
221    private void SolutionCreator_RealVectorParameter_ActualNameChanged(object sender, EventArgs e) {
222      ParameterizeEvaluator();
223      ParameterizeOperators();
224      ParameterizeAnalyzers();
225    }
226    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
227      ParameterizeOperators();
228    }
229    private void BoundsParameter_ValueChanged(object sender, EventArgs e) {
230      Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged);
231      Bounds_ToStringChanged(null, EventArgs.Empty);
232    }
233    private void Bounds_ToStringChanged(object sender, EventArgs e) {
234      if (Bounds.Columns != 2 || Bounds.Rows < 1)
235        Bounds = new DoubleMatrix(1, 2);
236      ParameterizeOperators();
237      UpdateStrategyVectorBounds();
238    }
239    private void Bounds_ItemChanged(object sender, EventArgs<int, int> e) {
240      if (e.Value2 == 0 && Bounds[e.Value, 1] <= Bounds[e.Value, 0])
241        Bounds[e.Value, 1] = Bounds[e.Value, 0] + 0.1;
242      if (e.Value2 == 1 && Bounds[e.Value, 0] >= Bounds[e.Value, 1])
243        Bounds[e.Value, 0] = Bounds[e.Value, 1] - 0.1;
244      ParameterizeOperators();
245      UpdateStrategyVectorBounds();
246    }
247    private void MoveGenerator_AdditiveMoveParameter_ActualNameChanged(object sender, EventArgs e) {
248      string name = ((ILookupParameter<AdditiveMove>)sender).ActualName;
249      foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) {
250        op.AdditiveMoveParameter.ActualName = name;
251      }
252    }
253    //private void SphereEvaluator_Parameter_ValueChanged(object sender, EventArgs e) {
254    //  SphereEvaluator eval = (Evaluator as SphereEvaluator);
255    //  if (eval != null) {
256    //    foreach (ISphereMoveEvaluator op in Operators.OfType<ISphereMoveEvaluator>()) {
257    //      op.C = eval.C;
258    //      op.Alpha = eval.Alpha;
259    //    }
260    //  }
261    //}
262    //private void RastriginEvaluator_Parameter_ValueChanged(object sender, EventArgs e) {
263    //  RastriginEvaluator eval = (Evaluator as RastriginEvaluator);
264    //  if (eval != null) {
265    //    foreach (IRastriginMoveEvaluator op in Operators.OfType<IRastriginMoveEvaluator>()) {
266    //      op.A = eval.A;
267    //    }
268    //  }
269    //}
270    //private void strategyVectorCreator_BoundsParameter_ValueChanged(object sender, EventArgs e) {
271    //  strategyVectorManipulator.BoundsParameter.Value = (DoubleMatrix)strategyVectorCreator.BoundsParameter.Value.Clone();
272    //}
273    //private void strategyVectorCreator_StrategyParameterParameter_ActualNameChanged(object sender, EventArgs e) {
274    //  string name = strategyVectorCreator.StrategyParameterParameter.ActualName;
275    //  strategyVectorCrossover.ParentsParameter.ActualName = name;
276    //  strategyVectorCrossover.StrategyParameterParameter.ActualName = name;
277    //  strategyVectorManipulator.StrategyParameterParameter.ActualName = name;
278    //}
279    #endregion
280
281    #region Helpers
282    [StorableHook(HookType.AfterDeserialization)]
283    private void AfterDeserialization() {
284      RegisterEventHandlers();
285    }
286
287    private void RegisterEventHandlers() {
288      ProblemSizeParameter.ValueChanged += new EventHandler(ProblemSizeParameter_ValueChanged);
289      ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
290      BoundsParameter.ValueChanged += new EventHandler(BoundsParameter_ValueChanged);
291      Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged);
292      Bounds.ItemChanged += new EventHandler<EventArgs<int, int>>(Bounds_ItemChanged);
293      SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
294      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
295      //strategyVectorCreator.BoundsParameter.ValueChanged += new EventHandler(strategyVectorCreator_BoundsParameter_ValueChanged);
296      //strategyVectorCreator.StrategyParameterParameter.ActualNameChanged += new EventHandler(strategyVectorCreator_StrategyParameterParameter_ActualNameChanged);
297    }
298    private void ParameterizeAnalyzers() {
299      //if (BestSingleObjectiveTestFunctionSolutionAnalyzer != null) {
300      //  BestSingleObjectiveTestFunctionSolutionAnalyzer.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
301      //  BestSingleObjectiveTestFunctionSolutionAnalyzer.ResultsParameter.ActualName = "Results";
302      //  BestSingleObjectiveTestFunctionSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
303      //  BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
304      //  BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
305      //  BestSingleObjectiveTestFunctionSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
306      //  BestSingleObjectiveTestFunctionSolutionAnalyzer.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
307      //  BestSingleObjectiveTestFunctionSolutionAnalyzer.BoundsParameter.ActualName = BoundsParameter.Name;
308      //}
309    }
310    private void InitializeOperators() {
311      //Operators.Add(new SingleObjectiveTestFunctionImprovementOperator());
312      //Operators.Add(new SingleObjectiveTestFunctionPathRelinker());
313      //Operators.Add(new SingleObjectiveTestFunctionSimilarityCalculator());
314      //Operators.Add(new HammingSimilarityCalculator());
315      //Operators.Add(new EuclideanSimilarityCalculator());
316      //Operators.Add(new QualitySimilarityCalculator());
317
318      //Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer());
319      //Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
320      ParameterizeAnalyzers();
321      Operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());
322      //Operators.Add(strategyVectorCreator);
323      //Operators.Add(strategyVectorCrossover);
324      //Operators.Add(strategyVectorManipulator);
325      UpdateMoveEvaluators();
326      ParameterizeOperators();
327      InitializeMoveGenerators();
328    }
329    private void InitializeMoveGenerators() {
330      foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) {
331        if (op is IMoveGenerator) {
332          op.AdditiveMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_AdditiveMoveParameter_ActualNameChanged);
333        }
334      }
335    }
336    private void UpdateMoveEvaluators() {
337      //foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList())
338      //  Operators.Remove(op);
339      //foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>())
340      //  if (op.EvaluatorType == Evaluator.GetType()) {
341      //    Operators.Add(op);
342      //    #region Synchronize evaluator specific parameters with the parameters of the corresponding move evaluators
343      //    if (op is ISphereMoveEvaluator) {
344      //      SphereEvaluator e = (Evaluator as SphereEvaluator);
345      //      e.AlphaParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged);
346      //      e.CParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged);
347      //      ISphereMoveEvaluator em = (op as ISphereMoveEvaluator);
348      //      em.C = e.C;
349      //      em.Alpha = e.Alpha;
350      //    } else if (op is IRastriginMoveEvaluator) {
351      //      RastriginEvaluator e = (Evaluator as RastriginEvaluator);
352      //      e.AParameter.ValueChanged += new EventHandler(RastriginEvaluator_Parameter_ValueChanged);
353      //      IRastriginMoveEvaluator em = (op as IRastriginMoveEvaluator);
354      //      em.A = e.A;
355      //    }
356      //    #endregion
357      //  }
358      ParameterizeOperators();
359      OnOperatorsChanged();
360    }
361    private void ParameterizeSolutionCreator() {
362      SolutionCreator.LengthParameter.Value = new IntValue(ProblemSize.Value);
363      SolutionCreator.LengthParameter.Hidden = true;
364      SolutionCreator.BoundsParameter.ActualName = BoundsParameter.Name;
365      SolutionCreator.BoundsParameter.Hidden = true;
366    }
367    private void ParameterizeEvaluator() {
368      Evaluator.PointParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
369      Evaluator.PointParameter.Hidden = true;
370      //try {
371      //  BestKnownSolutionParameter.Value = Evaluator.GetBestKnownSolution(ProblemSize.Value);
372      //}
373      //catch (ArgumentException e) {
374      //  ErrorHandling.ShowErrorDialog(e);
375      //  ProblemSize.Value = Evaluator.MinimumProblemSize;
376      //}
377    }
378    private void ParameterizeOperators() {
379      foreach (var op in Operators.OfType<IRealVectorCrossover>()) {
380        op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
381        op.ParentsParameter.Hidden = true;
382        op.ChildParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
383        op.ChildParameter.Hidden = true;
384        op.BoundsParameter.ActualName = BoundsParameter.Name;
385        op.BoundsParameter.Hidden = true;
386      }
387      foreach (var op in Operators.OfType<IRealVectorManipulator>()) {
388        op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
389        op.RealVectorParameter.Hidden = true;
390        op.BoundsParameter.ActualName = BoundsParameter.Name;
391        op.BoundsParameter.Hidden = true;
392      }
393      foreach (var op in Operators.OfType<IRealVectorMoveOperator>()) {
394        op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
395        op.RealVectorParameter.Hidden = true;
396      }
397      foreach (var op in Operators.OfType<IRealVectorMoveGenerator>()) {
398        op.BoundsParameter.ActualName = BoundsParameter.Name;
399        op.BoundsParameter.Hidden = true;
400      }
401      //foreach (var op in Operators.OfType<ISingleObjectiveTestFunctionAdditiveMoveEvaluator>()) {
402      //  op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
403      //  op.QualityParameter.Hidden = true;
404      //  op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
405      //  op.RealVectorParameter.Hidden = true;
406      //}
407      foreach (var op in Operators.OfType<IRealVectorParticleCreator>()) {
408        op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
409        op.RealVectorParameter.Hidden = true;
410        op.BoundsParameter.ActualName = BoundsParameter.Name;
411        op.BoundsParameter.Hidden = true;
412      }
413      foreach (var op in Operators.OfType<IRealVectorParticleUpdater>()) {
414        op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
415        op.RealVectorParameter.Hidden = true;
416        op.BoundsParameter.ActualName = BoundsParameter.Name;
417        op.BoundsParameter.Hidden = true;
418      }
419      foreach (var op in Operators.OfType<IRealVectorSwarmUpdater>()) {
420        op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
421        op.RealVectorParameter.Hidden = true;
422        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
423        op.MaximizationParameter.Hidden = true;
424      }
425      foreach (var op in Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()) {
426        op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
427        op.RealVectorParameter.Hidden = true;
428      }
429      foreach (var op in Operators.OfType<ISingleObjectiveImprovementOperator>()) {
430        op.SolutionParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
431        op.SolutionParameter.Hidden = true;
432      }
433      foreach (var op in Operators.OfType<ISingleObjectivePathRelinker>()) {
434        op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
435        op.ParentsParameter.Hidden = true;
436      }
437      foreach (var op in Operators.OfType<ISolutionSimilarityCalculator>()) {
438        op.SolutionVariableName = SolutionCreator.RealVectorParameter.ActualName;
439        op.QualityVariableName = Evaluator.QualityParameter.ActualName;
440        //var calc = op as SingleObjectiveTestFunctionSimilarityCalculator;
441        //if (calc != null) calc.Bounds = Bounds;
442      }
443    }
444    private void UpdateStrategyVectorBounds() {
445      //var strategyBounds = (DoubleMatrix)Bounds.Clone();
446      //for (int i = 0; i < strategyBounds.Rows; i++) {
447      //  if (strategyBounds[i, 0] < 0) strategyBounds[i, 0] = 0;
448      //  strategyBounds[i, 1] = 0.1 * (Bounds[i, 1] - Bounds[i, 0]);
449      //}
450      //strategyVectorCreator.BoundsParameter.Value = strategyBounds;
451    }
452    #endregion
453  }
454}
Note: See TracBrowser for help on using the repository browser.