[3150] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Collections.ObjectModel;
|
---|
| 25 | using System.Drawing;
|
---|
| 26 | using System.Linq;
|
---|
| 27 | using HeuristicLab.Common;
|
---|
| 28 | using HeuristicLab.Core;
|
---|
| 29 | using HeuristicLab.Data;
|
---|
| 30 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
| 31 | using HeuristicLab.Optimization;
|
---|
| 32 | using HeuristicLab.Parameters;
|
---|
| 33 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 34 | using HeuristicLab.PluginInfrastructure;
|
---|
[3682] | 35 | using HeuristicLab.Operators;
|
---|
[3647] | 36 | using HeuristicLab.Problems.TestFunctions.Analyzers;
|
---|
[3150] | 37 |
|
---|
[3170] | 38 | namespace HeuristicLab.Problems.TestFunctions {
|
---|
[3221] | 39 | [Item("Single Objective Test Function", "Test function with real valued inputs and a single objective.")]
|
---|
[3150] | 40 | [StorableClass]
|
---|
| 41 | [Creatable("Problems")]
|
---|
[3170] | 42 | public sealed class SingleObjectiveTestFunctionProblem : ParameterizedNamedItem, ISingleObjectiveProblem {
|
---|
[3336] | 43 | [Storable]
|
---|
[3450] | 44 | private StdDevStrategyVectorCreator strategyVectorCreator;
|
---|
[3336] | 45 | [Storable]
|
---|
[3450] | 46 | private StdDevStrategyVectorCrossover strategyVectorCrossover;
|
---|
[3336] | 47 | [Storable]
|
---|
[3450] | 48 | private StdDevStrategyVectorManipulator strategyVectorManipulator;
|
---|
[3336] | 49 |
|
---|
[3150] | 50 | public override Image ItemImage {
|
---|
| 51 | get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | #region Parameter Properties
|
---|
| 55 | public ValueParameter<BoolValue> MaximizationParameter {
|
---|
| 56 | get { return (ValueParameter<BoolValue>)Parameters["Maximization"]; }
|
---|
| 57 | }
|
---|
| 58 | IParameter ISingleObjectiveProblem.MaximizationParameter {
|
---|
| 59 | get { return MaximizationParameter; }
|
---|
| 60 | }
|
---|
| 61 | public ValueParameter<DoubleMatrix> BoundsParameter {
|
---|
| 62 | get { return (ValueParameter<DoubleMatrix>)Parameters["Bounds"]; }
|
---|
| 63 | }
|
---|
| 64 | public ValueParameter<IntValue> ProblemSizeParameter {
|
---|
| 65 | get { return (ValueParameter<IntValue>)Parameters["ProblemSize"]; }
|
---|
| 66 | }
|
---|
| 67 | public ValueParameter<IRealVectorCreator> SolutionCreatorParameter {
|
---|
| 68 | get { return (ValueParameter<IRealVectorCreator>)Parameters["SolutionCreator"]; }
|
---|
| 69 | }
|
---|
| 70 | IParameter IProblem.SolutionCreatorParameter {
|
---|
| 71 | get { return SolutionCreatorParameter; }
|
---|
| 72 | }
|
---|
[3170] | 73 | public ValueParameter<ISingleObjectiveTestFunctionProblemEvaluator> EvaluatorParameter {
|
---|
| 74 | get { return (ValueParameter<ISingleObjectiveTestFunctionProblemEvaluator>)Parameters["Evaluator"]; }
|
---|
[3150] | 75 | }
|
---|
| 76 | IParameter IProblem.EvaluatorParameter {
|
---|
| 77 | get { return EvaluatorParameter; }
|
---|
| 78 | }
|
---|
| 79 | public OptionalValueParameter<DoubleValue> BestKnownQualityParameter {
|
---|
| 80 | get { return (OptionalValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
|
---|
| 81 | }
|
---|
| 82 | IParameter ISingleObjectiveProblem.BestKnownQualityParameter {
|
---|
| 83 | get { return BestKnownQualityParameter; }
|
---|
| 84 | }
|
---|
| 85 | #endregion
|
---|
| 86 |
|
---|
| 87 | #region Properties
|
---|
[3154] | 88 | public BoolValue Maximization {
|
---|
| 89 | get { return MaximizationParameter.Value; }
|
---|
| 90 | set { MaximizationParameter.Value = value; }
|
---|
| 91 | }
|
---|
[3150] | 92 | public DoubleMatrix Bounds {
|
---|
| 93 | get { return BoundsParameter.Value; }
|
---|
| 94 | set { BoundsParameter.Value = value; }
|
---|
| 95 | }
|
---|
| 96 | public IntValue ProblemSize {
|
---|
| 97 | get { return ProblemSizeParameter.Value; }
|
---|
| 98 | set { ProblemSizeParameter.Value = value; }
|
---|
| 99 | }
|
---|
| 100 | public IRealVectorCreator SolutionCreator {
|
---|
| 101 | get { return SolutionCreatorParameter.Value; }
|
---|
| 102 | set { SolutionCreatorParameter.Value = value; }
|
---|
| 103 | }
|
---|
| 104 | ISolutionCreator IProblem.SolutionCreator {
|
---|
| 105 | get { return SolutionCreatorParameter.Value; }
|
---|
| 106 | }
|
---|
[3170] | 107 | public ISingleObjectiveTestFunctionProblemEvaluator Evaluator {
|
---|
[3150] | 108 | get { return EvaluatorParameter.Value; }
|
---|
| 109 | set { EvaluatorParameter.Value = value; }
|
---|
| 110 | }
|
---|
| 111 | ISingleObjectiveEvaluator ISingleObjectiveProblem.Evaluator {
|
---|
| 112 | get { return EvaluatorParameter.Value; }
|
---|
| 113 | }
|
---|
| 114 | IEvaluator IProblem.Evaluator {
|
---|
| 115 | get { return EvaluatorParameter.Value; }
|
---|
| 116 | }
|
---|
| 117 | public DoubleValue BestKnownQuality {
|
---|
| 118 | get { return BestKnownQualityParameter.Value; }
|
---|
| 119 | set { BestKnownQualityParameter.Value = value; }
|
---|
| 120 | }
|
---|
[3187] | 121 | private List<IOperator> operators;
|
---|
[3150] | 122 | public IEnumerable<IOperator> Operators {
|
---|
[3187] | 123 | get { return operators; }
|
---|
[3150] | 124 | }
|
---|
[3647] | 125 | private IEnumerable<IBestSingleObjectiveTestFunctionSolutionAnalyzer> BestSingleObjectiveTestFunctionSolutionAnalyzers {
|
---|
| 126 | get { return operators.OfType<IBestSingleObjectiveTestFunctionSolutionAnalyzer>(); }
|
---|
| 127 | }
|
---|
[3150] | 128 | #endregion
|
---|
| 129 |
|
---|
| 130 | [StorableConstructor]
|
---|
[3170] | 131 | private SingleObjectiveTestFunctionProblem(bool deserializing) : base() { }
|
---|
| 132 | public SingleObjectiveTestFunctionProblem()
|
---|
[3150] | 133 | : base() {
|
---|
| 134 | UniformRandomRealVectorCreator creator = new UniformRandomRealVectorCreator();
|
---|
| 135 | AckleyEvaluator evaluator = new AckleyEvaluator();
|
---|
| 136 |
|
---|
| 137 | Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as most test functions are minimization problems.", new BoolValue(evaluator.Maximization)));
|
---|
| 138 | Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension.", evaluator.Bounds));
|
---|
| 139 | Parameters.Add(new ValueParameter<IntValue>("ProblemSize", "The dimension of the problem.", new IntValue(2)));
|
---|
[3685] | 140 | Parameters.Add(new ValueParameter<IRealVectorCreator>("SolutionCreator", "The operator which should be used to create new test function solutions.", creator));
|
---|
| 141 | Parameters.Add(new ValueParameter<ISingleObjectiveTestFunctionProblemEvaluator>("Evaluator", "The operator which should be used to evaluate test function solutions.", evaluator));
|
---|
| 142 | Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this test function.", new DoubleValue(evaluator.BestKnownQuality)));
|
---|
[3150] | 143 |
|
---|
[3450] | 144 | strategyVectorCreator = new StdDevStrategyVectorCreator();
|
---|
[3336] | 145 | strategyVectorCreator.LengthParameter.ActualName = ProblemSizeParameter.Name;
|
---|
[3450] | 146 | strategyVectorCrossover = new StdDevStrategyVectorCrossover();
|
---|
| 147 | strategyVectorManipulator = new StdDevStrategyVectorManipulator();
|
---|
| 148 | strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(0.5);
|
---|
| 149 | strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(0.5);
|
---|
[3336] | 150 |
|
---|
[3150] | 151 | creator.RealVectorParameter.ActualName = "Point";
|
---|
| 152 | ParameterizeSolutionCreator();
|
---|
| 153 | ParameterizeEvaluator();
|
---|
| 154 |
|
---|
| 155 | Initialize();
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[3170] | 159 | SingleObjectiveTestFunctionProblem clone = (SingleObjectiveTestFunctionProblem)base.Clone(cloner);
|
---|
[3150] | 160 | clone.Initialize();
|
---|
| 161 | return clone;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | #region Events
|
---|
| 165 | public event EventHandler SolutionCreatorChanged;
|
---|
| 166 | private void OnSolutionCreatorChanged() {
|
---|
[3739] | 167 | EventHandler handler = SolutionCreatorChanged;
|
---|
| 168 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
[3150] | 169 | }
|
---|
| 170 | public event EventHandler EvaluatorChanged;
|
---|
| 171 | private void OnEvaluatorChanged() {
|
---|
[3739] | 172 | EventHandler handler = EvaluatorChanged;
|
---|
| 173 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
[3150] | 174 | }
|
---|
| 175 | public event EventHandler OperatorsChanged;
|
---|
| 176 | private void OnOperatorsChanged() {
|
---|
[3739] | 177 | EventHandler handler = OperatorsChanged;
|
---|
| 178 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
[3150] | 179 | }
|
---|
[3739] | 180 | public event EventHandler Reset;
|
---|
| 181 | private void OnReset() {
|
---|
| 182 | EventHandler handler = Reset;
|
---|
| 183 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
| 184 | }
|
---|
| 185 |
|
---|
[3150] | 186 | private void ProblemSizeParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 187 | ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
|
---|
| 188 | ProblemSize_ValueChanged(null, EventArgs.Empty);
|
---|
| 189 | }
|
---|
| 190 | private void ProblemSize_ValueChanged(object sender, EventArgs e) {
|
---|
[3336] | 191 | if (ProblemSize.Value < 1) ProblemSize.Value = 1;
|
---|
[3150] | 192 | ParameterizeSolutionCreator();
|
---|
[3336] | 193 | strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * ProblemSize.Value));
|
---|
| 194 | strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * Math.Sqrt(ProblemSize.Value)));
|
---|
[3150] | 195 | }
|
---|
| 196 | private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 197 | ParameterizeSolutionCreator();
|
---|
[3647] | 198 | ParameterizeAnalyzers();
|
---|
[3150] | 199 | SolutionCreator_RealVectorParameter_ActualNameChanged(null, EventArgs.Empty);
|
---|
| 200 | }
|
---|
| 201 | private void SolutionCreator_RealVectorParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
| 202 | ParameterizeEvaluator();
|
---|
| 203 | ParameterizeOperators();
|
---|
[3647] | 204 | ParameterizeAnalyzers();
|
---|
[3150] | 205 | }
|
---|
| 206 | private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 207 | ParameterizeEvaluator();
|
---|
[3187] | 208 | UpdateMoveEvaluators();
|
---|
[3647] | 209 | ParameterizeAnalyzers();
|
---|
[3154] | 210 | Maximization.Value = Evaluator.Maximization;
|
---|
| 211 | BoundsParameter.Value = Evaluator.Bounds;
|
---|
| 212 | if (ProblemSize.Value < Evaluator.MinimumProblemSize)
|
---|
| 213 | ProblemSize.Value = Evaluator.MinimumProblemSize;
|
---|
| 214 | else if (ProblemSize.Value > Evaluator.MaximumProblemSize)
|
---|
| 215 | ProblemSize.Value = Evaluator.MaximumProblemSize;
|
---|
| 216 | BestKnownQuality = new DoubleValue(Evaluator.BestKnownQuality);
|
---|
[3150] | 217 | Evaluator_QualityParameter_ActualNameChanged(null, EventArgs.Empty);
|
---|
| 218 | }
|
---|
| 219 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
| 220 | ParameterizeOperators();
|
---|
| 221 | }
|
---|
[3154] | 222 | private void BoundsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 223 | Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged);
|
---|
| 224 | Bounds_ToStringChanged(null, EventArgs.Empty);
|
---|
| 225 | }
|
---|
| 226 | private void Bounds_ToStringChanged(object sender, EventArgs e) {
|
---|
| 227 | if (Bounds.Columns != 2 || Bounds.Rows < 1)
|
---|
| 228 | Bounds = new DoubleMatrix(1, 2);
|
---|
[3719] | 229 | ParameterizeOperators();
|
---|
[3154] | 230 | }
|
---|
| 231 | private void Bounds_ItemChanged(object sender, EventArgs<int, int> e) {
|
---|
| 232 | if (e.Value2 == 0 && Bounds[e.Value, 1] <= Bounds[e.Value, 0])
|
---|
| 233 | Bounds[e.Value, 1] = Bounds[e.Value, 0] + 0.1;
|
---|
| 234 | if (e.Value2 == 1 && Bounds[e.Value, 0] >= Bounds[e.Value, 1])
|
---|
| 235 | Bounds[e.Value, 0] = Bounds[e.Value, 1] - 0.1;
|
---|
[3719] | 236 | ParameterizeOperators();
|
---|
[3154] | 237 | }
|
---|
[3187] | 238 | private void MoveGenerator_AdditiveMoveParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
| 239 | string name = ((ILookupParameter<AdditiveMove>)sender).ActualName;
|
---|
| 240 | foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) {
|
---|
| 241 | op.AdditiveMoveParameter.ActualName = name;
|
---|
| 242 | }
|
---|
[3182] | 243 | }
|
---|
[3318] | 244 | private void SphereEvaluator_Parameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 245 | SphereEvaluator eval = (Evaluator as SphereEvaluator);
|
---|
| 246 | if (eval != null) {
|
---|
| 247 | foreach (ISphereMoveEvaluator op in Operators.OfType<ISphereMoveEvaluator>()) {
|
---|
| 248 | op.C = eval.C;
|
---|
| 249 | op.Alpha = eval.Alpha;
|
---|
| 250 | }
|
---|
| 251 | }
|
---|
| 252 | }
|
---|
| 253 | private void RastriginEvaluator_Parameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 254 | RastriginEvaluator eval = (Evaluator as RastriginEvaluator);
|
---|
| 255 | if (eval != null) {
|
---|
| 256 | foreach (IRastriginMoveEvaluator op in Operators.OfType<IRastriginMoveEvaluator>()) {
|
---|
| 257 | op.A = eval.A;
|
---|
| 258 | }
|
---|
| 259 | }
|
---|
| 260 | }
|
---|
[3336] | 261 | private void strategyVectorCreator_BoundsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 262 | strategyVectorManipulator.BoundsParameter.Value = strategyVectorCreator.BoundsParameter.Value;
|
---|
| 263 | }
|
---|
| 264 | private void strategyVectorCreator_StrategyParameterParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
| 265 | string name = strategyVectorCreator.StrategyParameterParameter.ActualName;
|
---|
| 266 | strategyVectorCrossover.ParentsParameter.ActualName = name;
|
---|
| 267 | strategyVectorCrossover.StrategyParameterParameter.ActualName = name;
|
---|
| 268 | strategyVectorManipulator.StrategyParameterParameter.ActualName = name;
|
---|
| 269 | }
|
---|
[3150] | 270 | #endregion
|
---|
| 271 |
|
---|
| 272 | #region Helpers
|
---|
| 273 | [StorableHook(HookType.AfterDeserialization)]
|
---|
| 274 | private void Initialize() {
|
---|
| 275 | InitializeOperators();
|
---|
| 276 | ProblemSizeParameter.ValueChanged += new EventHandler(ProblemSizeParameter_ValueChanged);
|
---|
| 277 | ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
|
---|
[3154] | 278 | BoundsParameter.ValueChanged += new EventHandler(BoundsParameter_ValueChanged);
|
---|
| 279 | Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged);
|
---|
| 280 | Bounds.ItemChanged += new EventHandler<EventArgs<int, int>>(Bounds_ItemChanged);
|
---|
[3150] | 281 | SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
|
---|
| 282 | SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
|
---|
| 283 | EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
|
---|
| 284 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
[3336] | 285 | strategyVectorCreator.BoundsParameter.ValueChanged += new EventHandler(strategyVectorCreator_BoundsParameter_ValueChanged);
|
---|
| 286 | strategyVectorCreator.StrategyParameterParameter.ActualNameChanged += new EventHandler(strategyVectorCreator_StrategyParameterParameter_ActualNameChanged);
|
---|
[3150] | 287 | }
|
---|
[3647] | 288 | private void ParameterizeAnalyzers() {
|
---|
| 289 | foreach (IBestSingleObjectiveTestFunctionSolutionAnalyzer analyzer in BestSingleObjectiveTestFunctionSolutionAnalyzers) {
|
---|
| 290 | analyzer.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 291 | analyzer.ResultsParameter.ActualName = "Results";
|
---|
| 292 | }
|
---|
| 293 | }
|
---|
[3150] | 294 | private void InitializeOperators() {
|
---|
[3187] | 295 | operators = new List<IOperator>();
|
---|
[3647] | 296 | operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer());
|
---|
| 297 | ParameterizeAnalyzers();
|
---|
[3303] | 298 | operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());
|
---|
[3336] | 299 | operators.Add(strategyVectorCreator);
|
---|
| 300 | operators.Add(strategyVectorCrossover);
|
---|
| 301 | operators.Add(strategyVectorManipulator);
|
---|
[3209] | 302 | UpdateMoveEvaluators();
|
---|
| 303 | ParameterizeOperators();
|
---|
[3187] | 304 | InitializeMoveGenerators();
|
---|
[3150] | 305 | }
|
---|
[3187] | 306 | private void InitializeMoveGenerators() {
|
---|
| 307 | foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) {
|
---|
[3150] | 308 | if (op is IMoveGenerator) {
|
---|
[3187] | 309 | op.AdditiveMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_AdditiveMoveParameter_ActualNameChanged);
|
---|
[3150] | 310 | }
|
---|
| 311 | }
|
---|
[3187] | 312 | }
|
---|
| 313 | private void UpdateMoveEvaluators() {
|
---|
[3303] | 314 | foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList())
|
---|
| 315 | operators.Remove(op);
|
---|
| 316 | foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>())
|
---|
| 317 | if (op.EvaluatorType == Evaluator.GetType()) {
|
---|
| 318 | operators.Add(op);
|
---|
[3318] | 319 | #region Synchronize evaluator specific parameters with the parameters of the corresponding move evaluators
|
---|
| 320 | if (op is ISphereMoveEvaluator) {
|
---|
| 321 | SphereEvaluator e = (Evaluator as SphereEvaluator);
|
---|
| 322 | e.AlphaParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged);
|
---|
| 323 | e.CParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged);
|
---|
| 324 | ISphereMoveEvaluator em = (op as ISphereMoveEvaluator);
|
---|
| 325 | em.C = e.C;
|
---|
| 326 | em.Alpha = e.Alpha;
|
---|
| 327 | } else if (op is IRastriginMoveEvaluator) {
|
---|
| 328 | RastriginEvaluator e = (Evaluator as RastriginEvaluator);
|
---|
| 329 | e.AParameter.ValueChanged += new EventHandler(RastriginEvaluator_Parameter_ValueChanged);
|
---|
| 330 | IRastriginMoveEvaluator em = (op as IRastriginMoveEvaluator);
|
---|
| 331 | em.A = e.A;
|
---|
| 332 | }
|
---|
| 333 | #endregion
|
---|
[3303] | 334 | }
|
---|
| 335 | ParameterizeOperators();
|
---|
| 336 | OnOperatorsChanged();
|
---|
[3187] | 337 | }
|
---|
[3150] | 338 | private void ParameterizeSolutionCreator() {
|
---|
| 339 | SolutionCreator.LengthParameter.Value = new IntValue(ProblemSize.Value);
|
---|
| 340 | }
|
---|
| 341 | private void ParameterizeEvaluator() {
|
---|
| 342 | Evaluator.PointParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 343 | }
|
---|
| 344 | private void ParameterizeOperators() {
|
---|
| 345 | foreach (IRealVectorCrossover op in Operators.OfType<IRealVectorCrossover>()) {
|
---|
| 346 | op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 347 | op.ChildParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[3182] | 348 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[3150] | 349 | }
|
---|
| 350 | foreach (IRealVectorManipulator op in Operators.OfType<IRealVectorManipulator>()) {
|
---|
| 351 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[3182] | 352 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[3150] | 353 | }
|
---|
[3187] | 354 | foreach (IRealVectorMoveOperator op in Operators.OfType<IRealVectorMoveOperator>()) {
|
---|
| 355 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[3150] | 356 | }
|
---|
[3187] | 357 | foreach (IRealVectorMoveGenerator op in Operators.OfType<IRealVectorMoveGenerator>()) {
|
---|
| 358 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
| 359 | }
|
---|
| 360 | foreach (ISingleObjectiveTestFunctionAdditiveMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionAdditiveMoveEvaluator>()) {
|
---|
| 361 | op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
|
---|
| 362 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 363 | }
|
---|
[3682] | 364 | foreach (IRealVectorPSOEncoder op in Operators.OfType<IRealVectorPSOEncoder>()) {
|
---|
[3719] | 365 | ((ILookupParameter)op.OriginalRealVectorParameter).ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 366 | op.BoundsParameter.Value = (DoubleMatrix)BoundsParameter.Value.Clone();
|
---|
| 367 | op.BoundsParameter.ActualName = "ParticleBounds";
|
---|
[3682] | 368 | }
|
---|
[3150] | 369 | }
|
---|
| 370 | #endregion
|
---|
| 371 | }
|
---|
| 372 | }
|
---|