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