[3150] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[9456] | 3 | * Copyright (C) 2002-2013 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 |
|
---|
[8720] | 22 | using HeuristicLab.Analysis;
|
---|
[3150] | 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;
|
---|
[9258] | 31 | using System;
|
---|
| 32 | using System.Collections.Generic;
|
---|
| 33 | using System.Linq;
|
---|
[3150] | 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 |
|
---|
| 129 | #region Events
|
---|
[6938] | 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);
|
---|
[3150] | 136 | }
|
---|
[6938] | 137 | protected override void OnEvaluatorChanged() {
|
---|
| 138 | base.OnEvaluatorChanged();
|
---|
[8493] | 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 | }
|
---|
[6938] | 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();
|
---|
[3150] | 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) {
|
---|
[3336] | 160 | if (ProblemSize.Value < 1) ProblemSize.Value = 1;
|
---|
[3150] | 161 | ParameterizeSolutionCreator();
|
---|
[3781] | 162 | ParameterizeEvaluator();
|
---|
[3336] | 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)));
|
---|
[3781] | 165 | OnReset();
|
---|
[3150] | 166 | }
|
---|
| 167 | private void SolutionCreator_RealVectorParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
| 168 | ParameterizeEvaluator();
|
---|
| 169 | ParameterizeOperators();
|
---|
[3647] | 170 | ParameterizeAnalyzers();
|
---|
[3150] | 171 | }
|
---|
| 172 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
| 173 | ParameterizeOperators();
|
---|
| 174 | }
|
---|
[3154] | 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);
|
---|
[3781] | 182 | ParameterizeOperators();
|
---|
| 183 | UpdateStrategyVectorBounds();
|
---|
[3154] | 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;
|
---|
[3781] | 190 | ParameterizeOperators();
|
---|
| 191 | UpdateStrategyVectorBounds();
|
---|
[3154] | 192 | }
|
---|
[3187] | 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 | }
|
---|
[3182] | 198 | }
|
---|
[3318] | 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 | }
|
---|
[3336] | 216 | private void strategyVectorCreator_BoundsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
[3781] | 217 | strategyVectorManipulator.BoundsParameter.Value = (DoubleMatrix)strategyVectorCreator.BoundsParameter.Value.Clone();
|
---|
[3336] | 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 | }
|
---|
[3150] | 225 | #endregion
|
---|
| 226 |
|
---|
| 227 | #region Helpers
|
---|
| 228 | [StorableHook(HookType.AfterDeserialization)]
|
---|
[4722] | 229 | private void AfterDeserialization() {
|
---|
[4118] | 230 | // BackwardsCompatibility3.3
|
---|
| 231 | #region Backwards compatible code (remove with 3.4)
|
---|
[6938] | 232 | if (Operators.Count == 0) InitializeOperators();
|
---|
[4118] | 233 | #endregion
|
---|
[7351] | 234 | RegisterEventHandlers();
|
---|
[4118] | 235 | }
|
---|
| 236 |
|
---|
[7351] | 237 | private void RegisterEventHandlers() {
|
---|
[3150] | 238 | ProblemSizeParameter.ValueChanged += new EventHandler(ProblemSizeParameter_ValueChanged);
|
---|
| 239 | ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
|
---|
[3154] | 240 | BoundsParameter.ValueChanged += new EventHandler(BoundsParameter_ValueChanged);
|
---|
| 241 | Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged);
|
---|
| 242 | Bounds.ItemChanged += new EventHandler<EventArgs<int, int>>(Bounds_ItemChanged);
|
---|
[3150] | 243 | SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
|
---|
| 244 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
[3336] | 245 | strategyVectorCreator.BoundsParameter.ValueChanged += new EventHandler(strategyVectorCreator_BoundsParameter_ValueChanged);
|
---|
| 246 | strategyVectorCreator.StrategyParameterParameter.ActualNameChanged += new EventHandler(strategyVectorCreator_StrategyParameterParameter_ActualNameChanged);
|
---|
[3150] | 247 | }
|
---|
[3647] | 248 | private void ParameterizeAnalyzers() {
|
---|
[8720] | 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 | }
|
---|
[3647] | 266 | }
|
---|
[3150] | 267 | private void InitializeOperators() {
|
---|
[8334] | 268 | Operators.Add(new SingleObjectiveTestFunctionImprovementOperator());
|
---|
| 269 | Operators.Add(new SingleObjectiveTestFunctionPathRelinker());
|
---|
| 270 | Operators.Add(new SingleObjectiveTestFunctionSimilarityCalculator());
|
---|
| 271 |
|
---|
[6938] | 272 | Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer());
|
---|
[8720] | 273 | Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());
|
---|
[3647] | 274 | ParameterizeAnalyzers();
|
---|
[6938] | 275 | Operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());
|
---|
| 276 | Operators.Add(strategyVectorCreator);
|
---|
| 277 | Operators.Add(strategyVectorCrossover);
|
---|
| 278 | Operators.Add(strategyVectorManipulator);
|
---|
[3209] | 279 | UpdateMoveEvaluators();
|
---|
| 280 | ParameterizeOperators();
|
---|
[3187] | 281 | InitializeMoveGenerators();
|
---|
[3150] | 282 | }
|
---|
[3187] | 283 | private void InitializeMoveGenerators() {
|
---|
| 284 | foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) {
|
---|
[3150] | 285 | if (op is IMoveGenerator) {
|
---|
[3187] | 286 | op.AdditiveMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_AdditiveMoveParameter_ActualNameChanged);
|
---|
[3150] | 287 | }
|
---|
| 288 | }
|
---|
[3187] | 289 | }
|
---|
| 290 | private void UpdateMoveEvaluators() {
|
---|
[3303] | 291 | foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList())
|
---|
[6938] | 292 | Operators.Remove(op);
|
---|
[3303] | 293 | foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>())
|
---|
| 294 | if (op.EvaluatorType == Evaluator.GetType()) {
|
---|
[6938] | 295 | Operators.Add(op);
|
---|
[3318] | 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
|
---|
[3303] | 311 | }
|
---|
| 312 | ParameterizeOperators();
|
---|
| 313 | OnOperatorsChanged();
|
---|
[3187] | 314 | }
|
---|
[3150] | 315 | private void ParameterizeSolutionCreator() {
|
---|
| 316 | SolutionCreator.LengthParameter.Value = new IntValue(ProblemSize.Value);
|
---|
[6051] | 317 | SolutionCreator.LengthParameter.Hidden = true;
|
---|
| 318 | SolutionCreator.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
| 319 | SolutionCreator.BoundsParameter.Hidden = true;
|
---|
[3150] | 320 | }
|
---|
| 321 | private void ParameterizeEvaluator() {
|
---|
| 322 | Evaluator.PointParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 323 | Evaluator.PointParameter.Hidden = true;
|
---|
[8493] | 324 | try {
|
---|
| 325 | BestKnownSolutionParameter.Value = Evaluator.GetBestKnownSolution(ProblemSize.Value);
|
---|
[8720] | 326 | }
|
---|
| 327 | catch (ArgumentException e) {
|
---|
[8493] | 328 | ErrorHandling.ShowErrorDialog(e);
|
---|
| 329 | ProblemSize.Value = Evaluator.MinimumProblemSize;
|
---|
| 330 | }
|
---|
[3150] | 331 | }
|
---|
| 332 | private void ParameterizeOperators() {
|
---|
[9258] | 333 | foreach (var op in Operators.OfType<IRealVectorCrossover>()) {
|
---|
[3150] | 334 | op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 335 | op.ParentsParameter.Hidden = true;
|
---|
[3150] | 336 | op.ChildParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 337 | op.ChildParameter.Hidden = true;
|
---|
[3182] | 338 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[6051] | 339 | op.BoundsParameter.Hidden = true;
|
---|
[3150] | 340 | }
|
---|
[9258] | 341 | foreach (var op in Operators.OfType<IRealVectorManipulator>()) {
|
---|
[3150] | 342 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 343 | op.RealVectorParameter.Hidden = true;
|
---|
[3182] | 344 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[6051] | 345 | op.BoundsParameter.Hidden = true;
|
---|
[3150] | 346 | }
|
---|
[9258] | 347 | foreach (var op in Operators.OfType<IRealVectorMoveOperator>()) {
|
---|
[3187] | 348 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 349 | op.RealVectorParameter.Hidden = true;
|
---|
[3150] | 350 | }
|
---|
[9258] | 351 | foreach (var op in Operators.OfType<IRealVectorMoveGenerator>()) {
|
---|
[3187] | 352 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[6051] | 353 | op.BoundsParameter.Hidden = true;
|
---|
[3187] | 354 | }
|
---|
[9258] | 355 | foreach (var op in Operators.OfType<ISingleObjectiveTestFunctionAdditiveMoveEvaluator>()) {
|
---|
[3187] | 356 | op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
|
---|
[6051] | 357 | op.QualityParameter.Hidden = true;
|
---|
[3187] | 358 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 359 | op.RealVectorParameter.Hidden = true;
|
---|
[3187] | 360 | }
|
---|
[9258] | 361 | foreach (var op in Operators.OfType<IRealVectorParticleCreator>()) {
|
---|
[5560] | 362 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 363 | op.RealVectorParameter.Hidden = true;
|
---|
[5560] | 364 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[6051] | 365 | op.BoundsParameter.Hidden = true;
|
---|
[5951] | 366 | op.ProblemSizeParameter.ActualName = ProblemSizeParameter.Name;
|
---|
[6051] | 367 | op.ProblemSizeParameter.Hidden = true;
|
---|
[5560] | 368 | }
|
---|
[9258] | 369 | foreach (var op in Operators.OfType<IRealVectorParticleUpdater>()) {
|
---|
[5560] | 370 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 371 | op.RealVectorParameter.Hidden = true;
|
---|
[5951] | 372 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[6051] | 373 | op.BoundsParameter.Hidden = true;
|
---|
[5560] | 374 | }
|
---|
[9258] | 375 | foreach (var op in Operators.OfType<IRealVectorSwarmUpdater>()) {
|
---|
[5561] | 376 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 377 | op.RealVectorParameter.Hidden = true;
|
---|
[5951] | 378 | op.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
[6051] | 379 | op.MaximizationParameter.Hidden = true;
|
---|
[5561] | 380 | }
|
---|
[9258] | 381 | foreach (var op in Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()) {
|
---|
[6042] | 382 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 383 | op.RealVectorParameter.Hidden = true;
|
---|
| 384 | }
|
---|
[9258] | 385 | foreach (var op in Operators.OfType<ISingleObjectiveImprovementOperator>()) {
|
---|
[8334] | 386 | op.SolutionParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 387 | op.SolutionParameter.Hidden = true;
|
---|
| 388 | }
|
---|
[9258] | 389 | foreach (var op in Operators.OfType<ISingleObjectivePathRelinker>()) {
|
---|
[8334] | 390 | op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 391 | op.ParentsParameter.Hidden = true;
|
---|
| 392 | }
|
---|
[9258] | 393 | foreach (var op in Operators.OfType<SingleObjectiveTestFunctionSimilarityCalculator>()) {
|
---|
[8334] | 394 | op.SolutionVariableName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 395 | op.QualityVariableName = Evaluator.QualityParameter.ActualName;
|
---|
| 396 | op.Bounds = Bounds;
|
---|
| 397 | }
|
---|
[3150] | 398 | }
|
---|
[3781] | 399 | private void UpdateStrategyVectorBounds() {
|
---|
[9258] | 400 | var strategyBounds = (DoubleMatrix)Bounds.Clone();
|
---|
[5381] | 401 | for (int i = 0; i < strategyBounds.Rows; i++) {
|
---|
[3781] | 402 | if (strategyBounds[i, 0] < 0) strategyBounds[i, 0] = 0;
|
---|
[5381] | 403 | strategyBounds[i, 1] = 0.1 * (Bounds[i, 1] - Bounds[i, 0]);
|
---|
| 404 | }
|
---|
[3781] | 405 | strategyVectorCreator.BoundsParameter.Value = strategyBounds;
|
---|
| 406 | }
|
---|
[3150] | 407 | #endregion
|
---|
| 408 | }
|
---|
| 409 | }
|
---|