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