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