[3150] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[17209] | 3 | * Copyright (C) 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;
|
---|
[16565] | 33 | using HEAL.Attic;
|
---|
[3150] | 34 | using HeuristicLab.PluginInfrastructure;
|
---|
[9980] | 35 | using HeuristicLab.Problems.Instances;
|
---|
[3150] | 36 |
|
---|
[3170] | 37 | namespace HeuristicLab.Problems.TestFunctions {
|
---|
[12504] | 38 | [Item("Test Function (single-objective)", "Test function with real valued inputs and a single objective.")]
|
---|
[16565] | 39 | [StorableType("F0AB7236-2C9B-49DC-9D4F-A3558FD9E992")]
|
---|
[12504] | 40 | [Creatable(CreatableAttribute.Categories.Problems, Priority = 90)]
|
---|
[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]
|
---|
[16565] | 91 | private SingleObjectiveTestFunctionProblem(StorableConstructorFlag _) : base(_) { }
|
---|
[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());
|
---|
[15069] | 263 | Operators.Add(new HammingSimilarityCalculator());
|
---|
| 264 | Operators.Add(new EuclideanSimilarityCalculator());
|
---|
[12126] | 265 | Operators.Add(new QualitySimilarityCalculator());
|
---|
[8334] | 266 |
|
---|
[6938] | 267 | Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer());
|
---|
[12069] | 268 | Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
|
---|
[3647] | 269 | ParameterizeAnalyzers();
|
---|
[6938] | 270 | Operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());
|
---|
| 271 | Operators.Add(strategyVectorCreator);
|
---|
| 272 | Operators.Add(strategyVectorCrossover);
|
---|
| 273 | Operators.Add(strategyVectorManipulator);
|
---|
[3209] | 274 | UpdateMoveEvaluators();
|
---|
| 275 | ParameterizeOperators();
|
---|
[3187] | 276 | InitializeMoveGenerators();
|
---|
[3150] | 277 | }
|
---|
[3187] | 278 | private void InitializeMoveGenerators() {
|
---|
| 279 | foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) {
|
---|
[3150] | 280 | if (op is IMoveGenerator) {
|
---|
[3187] | 281 | op.AdditiveMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_AdditiveMoveParameter_ActualNameChanged);
|
---|
[3150] | 282 | }
|
---|
| 283 | }
|
---|
[3187] | 284 | }
|
---|
| 285 | private void UpdateMoveEvaluators() {
|
---|
[3303] | 286 | foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList())
|
---|
[6938] | 287 | Operators.Remove(op);
|
---|
[3303] | 288 | foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>())
|
---|
| 289 | if (op.EvaluatorType == Evaluator.GetType()) {
|
---|
[6938] | 290 | Operators.Add(op);
|
---|
[3318] | 291 | #region Synchronize evaluator specific parameters with the parameters of the corresponding move evaluators
|
---|
| 292 | if (op is ISphereMoveEvaluator) {
|
---|
| 293 | SphereEvaluator e = (Evaluator as SphereEvaluator);
|
---|
| 294 | e.AlphaParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged);
|
---|
| 295 | e.CParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged);
|
---|
| 296 | ISphereMoveEvaluator em = (op as ISphereMoveEvaluator);
|
---|
| 297 | em.C = e.C;
|
---|
| 298 | em.Alpha = e.Alpha;
|
---|
| 299 | } else if (op is IRastriginMoveEvaluator) {
|
---|
| 300 | RastriginEvaluator e = (Evaluator as RastriginEvaluator);
|
---|
| 301 | e.AParameter.ValueChanged += new EventHandler(RastriginEvaluator_Parameter_ValueChanged);
|
---|
| 302 | IRastriginMoveEvaluator em = (op as IRastriginMoveEvaluator);
|
---|
| 303 | em.A = e.A;
|
---|
| 304 | }
|
---|
| 305 | #endregion
|
---|
[3303] | 306 | }
|
---|
| 307 | ParameterizeOperators();
|
---|
| 308 | OnOperatorsChanged();
|
---|
[3187] | 309 | }
|
---|
[3150] | 310 | private void ParameterizeSolutionCreator() {
|
---|
| 311 | SolutionCreator.LengthParameter.Value = new IntValue(ProblemSize.Value);
|
---|
[6051] | 312 | SolutionCreator.LengthParameter.Hidden = true;
|
---|
| 313 | SolutionCreator.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
| 314 | SolutionCreator.BoundsParameter.Hidden = true;
|
---|
[3150] | 315 | }
|
---|
| 316 | private void ParameterizeEvaluator() {
|
---|
| 317 | Evaluator.PointParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 318 | Evaluator.PointParameter.Hidden = true;
|
---|
[8493] | 319 | try {
|
---|
| 320 | BestKnownSolutionParameter.Value = Evaluator.GetBestKnownSolution(ProblemSize.Value);
|
---|
[12102] | 321 | }
|
---|
| 322 | catch (ArgumentException e) {
|
---|
[8493] | 323 | ErrorHandling.ShowErrorDialog(e);
|
---|
| 324 | ProblemSize.Value = Evaluator.MinimumProblemSize;
|
---|
| 325 | }
|
---|
[3150] | 326 | }
|
---|
| 327 | private void ParameterizeOperators() {
|
---|
[9258] | 328 | foreach (var op in Operators.OfType<IRealVectorCrossover>()) {
|
---|
[3150] | 329 | op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 330 | op.ParentsParameter.Hidden = true;
|
---|
[3150] | 331 | op.ChildParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 332 | op.ChildParameter.Hidden = true;
|
---|
[3182] | 333 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[6051] | 334 | op.BoundsParameter.Hidden = true;
|
---|
[3150] | 335 | }
|
---|
[9258] | 336 | foreach (var op in Operators.OfType<IRealVectorManipulator>()) {
|
---|
[3150] | 337 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 338 | op.RealVectorParameter.Hidden = true;
|
---|
[3182] | 339 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[6051] | 340 | op.BoundsParameter.Hidden = true;
|
---|
[3150] | 341 | }
|
---|
[9258] | 342 | foreach (var op in Operators.OfType<IRealVectorMoveOperator>()) {
|
---|
[3187] | 343 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 344 | op.RealVectorParameter.Hidden = true;
|
---|
[3150] | 345 | }
|
---|
[9258] | 346 | foreach (var op in Operators.OfType<IRealVectorMoveGenerator>()) {
|
---|
[3187] | 347 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[6051] | 348 | op.BoundsParameter.Hidden = true;
|
---|
[3187] | 349 | }
|
---|
[9258] | 350 | foreach (var op in Operators.OfType<ISingleObjectiveTestFunctionAdditiveMoveEvaluator>()) {
|
---|
[3187] | 351 | op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
|
---|
[6051] | 352 | op.QualityParameter.Hidden = true;
|
---|
[3187] | 353 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 354 | op.RealVectorParameter.Hidden = true;
|
---|
[3187] | 355 | }
|
---|
[9258] | 356 | foreach (var op in Operators.OfType<IRealVectorParticleCreator>()) {
|
---|
[5560] | 357 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 358 | op.RealVectorParameter.Hidden = true;
|
---|
[5560] | 359 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[6051] | 360 | op.BoundsParameter.Hidden = true;
|
---|
[5560] | 361 | }
|
---|
[9258] | 362 | foreach (var op in Operators.OfType<IRealVectorParticleUpdater>()) {
|
---|
[5560] | 363 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 364 | op.RealVectorParameter.Hidden = true;
|
---|
[5951] | 365 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
[6051] | 366 | op.BoundsParameter.Hidden = true;
|
---|
[5560] | 367 | }
|
---|
[9258] | 368 | foreach (var op in Operators.OfType<IRealVectorSwarmUpdater>()) {
|
---|
[5561] | 369 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 370 | op.RealVectorParameter.Hidden = true;
|
---|
[5951] | 371 | op.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
[6051] | 372 | op.MaximizationParameter.Hidden = true;
|
---|
[5561] | 373 | }
|
---|
[9258] | 374 | foreach (var op in Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()) {
|
---|
[6042] | 375 | op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
[6051] | 376 | op.RealVectorParameter.Hidden = true;
|
---|
| 377 | }
|
---|
[9258] | 378 | foreach (var op in Operators.OfType<ISingleObjectiveImprovementOperator>()) {
|
---|
[8334] | 379 | op.SolutionParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 380 | op.SolutionParameter.Hidden = true;
|
---|
| 381 | }
|
---|
[9258] | 382 | foreach (var op in Operators.OfType<ISingleObjectivePathRelinker>()) {
|
---|
[8334] | 383 | op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 384 | op.ParentsParameter.Hidden = true;
|
---|
| 385 | }
|
---|
[12126] | 386 | foreach (var op in Operators.OfType<ISolutionSimilarityCalculator>()) {
|
---|
[8334] | 387 | op.SolutionVariableName = SolutionCreator.RealVectorParameter.ActualName;
|
---|
| 388 | op.QualityVariableName = Evaluator.QualityParameter.ActualName;
|
---|
[12126] | 389 | var calc = op as SingleObjectiveTestFunctionSimilarityCalculator;
|
---|
| 390 | if (calc != null) calc.Bounds = Bounds;
|
---|
[8334] | 391 | }
|
---|
[3150] | 392 | }
|
---|
[3781] | 393 | private void UpdateStrategyVectorBounds() {
|
---|
[9258] | 394 | var strategyBounds = (DoubleMatrix)Bounds.Clone();
|
---|
[5381] | 395 | for (int i = 0; i < strategyBounds.Rows; i++) {
|
---|
[3781] | 396 | if (strategyBounds[i, 0] < 0) strategyBounds[i, 0] = 0;
|
---|
[5381] | 397 | strategyBounds[i, 1] = 0.1 * (Bounds[i, 1] - Bounds[i, 0]);
|
---|
| 398 | }
|
---|
[3781] | 399 | strategyVectorCreator.BoundsParameter.Value = strategyBounds;
|
---|
| 400 | }
|
---|
[3150] | 401 | #endregion
|
---|
[9980] | 402 |
|
---|
| 403 | public void Load(SOTFData data) {
|
---|
| 404 | Name = data.Name;
|
---|
| 405 | Description = data.Description;
|
---|
[9982] | 406 | Evaluator = data.Evaluator;
|
---|
[9980] | 407 | }
|
---|
[3150] | 408 | }
|
---|
| 409 | }
|
---|