[3223] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[5445] | 3 | * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[3223] | 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;
|
---|
[4068] | 24 | using System.Drawing;
|
---|
[3223] | 25 | using System.Linq;
|
---|
| 26 | using HeuristicLab.Common;
|
---|
| 27 | using HeuristicLab.Core;
|
---|
| 28 | using HeuristicLab.Data;
|
---|
[4068] | 29 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
| 30 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Analyzers;
|
---|
| 31 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
|
---|
| 32 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
|
---|
[3223] | 33 | using HeuristicLab.Optimization;
|
---|
| 34 | using HeuristicLab.Parameters;
|
---|
| 35 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 36 | using HeuristicLab.PluginInfrastructure;
|
---|
[3631] | 37 | using HeuristicLab.Problems.ArtificialAnt.Analyzers;
|
---|
[3223] | 38 |
|
---|
| 39 | namespace HeuristicLab.Problems.ArtificialAnt {
|
---|
[3528] | 40 | [Item("Artificial Ant Problem", "Represents the Artificial Ant problem.")]
|
---|
[3223] | 41 | [StorableClass]
|
---|
[5809] | 42 | [NonDiscoverableType]
|
---|
| 43 | public sealed class ArtificialAntProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {
|
---|
[4419] | 44 | public string Filename { get; set; }
|
---|
[4098] | 45 |
|
---|
[3223] | 46 | public override Image ItemImage {
|
---|
[5287] | 47 | get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
|
---|
[3223] | 48 | }
|
---|
| 49 |
|
---|
[3239] | 50 | #region constant for default world (Santa Fe)
|
---|
| 51 | private readonly bool[,] santaFeAntTrail = new bool[,] {
|
---|
| 52 | {false, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 53 | {false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 54 | {false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, false, false, false, false},
|
---|
| 55 | {false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, true, false, false},
|
---|
| 56 | {false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, true, false, false},
|
---|
| 57 | {false, false, false, true, true, true, true, false, true, true, true, true, true, false, false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false},
|
---|
| 58 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false},
|
---|
| 59 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 60 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 61 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, true, false, false},
|
---|
| 62 | {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 63 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 64 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false},
|
---|
| 65 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 66 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, true, true, true, false, false, false},
|
---|
| 67 | {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, false},
|
---|
| 68 | {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 69 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 70 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false},
|
---|
| 71 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false},
|
---|
| 72 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 73 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 74 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false},
|
---|
| 75 | {false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false},
|
---|
| 76 | {false, false, false, true, true, false, false, true, true, true, true, true, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 77 | {false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 78 | {false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 79 | {false, true, false, false, false, false, false, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 80 | {false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 81 | {false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false},
|
---|
| 82 | {false, false, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false },
|
---|
| 83 | {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false }
|
---|
| 84 | };
|
---|
| 85 | #endregion
|
---|
| 86 |
|
---|
[3223] | 87 | #region Parameter Properties
|
---|
| 88 | public ValueParameter<BoolValue> MaximizationParameter {
|
---|
| 89 | get { return (ValueParameter<BoolValue>)Parameters["Maximization"]; }
|
---|
| 90 | }
|
---|
[5809] | 91 | IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter {
|
---|
[3223] | 92 | get { return MaximizationParameter; }
|
---|
| 93 | }
|
---|
| 94 | public ValueParameter<SymbolicExpressionTreeCreator> SolutionCreatorParameter {
|
---|
| 95 | get { return (ValueParameter<SymbolicExpressionTreeCreator>)Parameters["SolutionCreator"]; }
|
---|
| 96 | }
|
---|
[5809] | 97 | IParameter IHeuristicOptimizationProblem.SolutionCreatorParameter {
|
---|
[3223] | 98 | get { return SolutionCreatorParameter; }
|
---|
| 99 | }
|
---|
| 100 | public ValueParameter<Evaluator> EvaluatorParameter {
|
---|
| 101 | get { return (ValueParameter<Evaluator>)Parameters["Evaluator"]; }
|
---|
| 102 | }
|
---|
[5809] | 103 | IParameter IHeuristicOptimizationProblem.EvaluatorParameter {
|
---|
[3223] | 104 | get { return EvaluatorParameter; }
|
---|
| 105 | }
|
---|
| 106 | public ValueParameter<ISymbolicExpressionGrammar> ArtificialAntExpressionGrammarParameter {
|
---|
| 107 | get { return (ValueParameter<ISymbolicExpressionGrammar>)Parameters["ArtificialAntExpressionGrammar"]; }
|
---|
| 108 | }
|
---|
| 109 | public ValueParameter<IntValue> MaxExpressionLengthParameter {
|
---|
| 110 | get { return (ValueParameter<IntValue>)Parameters["MaxExpressionLength"]; }
|
---|
| 111 | }
|
---|
| 112 | public ValueParameter<IntValue> MaxExpressionDepthParameter {
|
---|
| 113 | get { return (ValueParameter<IntValue>)Parameters["MaxExpressionDepth"]; }
|
---|
| 114 | }
|
---|
[3294] | 115 | public ValueParameter<IntValue> MaxFunctionDefinitionsParameter {
|
---|
| 116 | get { return (ValueParameter<IntValue>)Parameters["MaxFunctionDefinitions"]; }
|
---|
| 117 | }
|
---|
| 118 | public ValueParameter<IntValue> MaxFunctionArgumentsParameter {
|
---|
| 119 | get { return (ValueParameter<IntValue>)Parameters["MaxFunctionArguments"]; }
|
---|
| 120 | }
|
---|
[3239] | 121 | public ValueParameter<BoolMatrix> WorldParameter {
|
---|
| 122 | get { return (ValueParameter<BoolMatrix>)Parameters["World"]; }
|
---|
| 123 | }
|
---|
| 124 | public ValueParameter<IntValue> MaxTimeStepsParameter {
|
---|
| 125 | get { return (ValueParameter<IntValue>)Parameters["MaxTimeSteps"]; }
|
---|
| 126 | }
|
---|
[3223] | 127 |
|
---|
| 128 | public ValueParameter<DoubleValue> BestKnownQualityParameter {
|
---|
| 129 | get { return (ValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
|
---|
| 130 | }
|
---|
[5809] | 131 | IParameter ISingleObjectiveHeuristicOptimizationProblem.BestKnownQualityParameter {
|
---|
[3223] | 132 | get { return BestKnownQualityParameter; }
|
---|
| 133 | }
|
---|
| 134 | #endregion
|
---|
| 135 |
|
---|
| 136 | #region Properties
|
---|
[3239] | 137 | public BoolMatrix World {
|
---|
| 138 | get { return WorldParameter.Value; }
|
---|
| 139 | set { WorldParameter.Value = value; }
|
---|
| 140 | }
|
---|
| 141 | public IntValue MaxTimeSteps {
|
---|
| 142 | get { return MaxTimeStepsParameter.Value; }
|
---|
| 143 | set { MaxTimeStepsParameter.Value = value; }
|
---|
| 144 | }
|
---|
| 145 | public IntValue MaxExpressionLength {
|
---|
| 146 | get { return MaxExpressionLengthParameter.Value; }
|
---|
| 147 | set { MaxExpressionLengthParameter.Value = value; }
|
---|
| 148 | }
|
---|
| 149 | public IntValue MaxExpressionDepth {
|
---|
| 150 | get { return MaxExpressionDepthParameter.Value; }
|
---|
| 151 | set { MaxExpressionDepthParameter.Value = value; }
|
---|
| 152 | }
|
---|
[3338] | 153 | public IntValue MaxFunctionDefinitions {
|
---|
| 154 | get { return MaxFunctionDefinitionsParameter.Value; }
|
---|
| 155 | set { MaxFunctionDefinitionsParameter.Value = value; }
|
---|
| 156 | }
|
---|
| 157 | public IntValue MaxFunctionArguments {
|
---|
| 158 | get { return MaxFunctionArgumentsParameter.Value; }
|
---|
| 159 | set { MaxFunctionArgumentsParameter.Value = value; }
|
---|
| 160 | }
|
---|
[3223] | 161 | public SymbolicExpressionTreeCreator SolutionCreator {
|
---|
| 162 | get { return SolutionCreatorParameter.Value; }
|
---|
| 163 | set { SolutionCreatorParameter.Value = value; }
|
---|
| 164 | }
|
---|
[5809] | 165 | ISolutionCreator IHeuristicOptimizationProblem.SolutionCreator {
|
---|
[3223] | 166 | get { return SolutionCreatorParameter.Value; }
|
---|
| 167 | }
|
---|
| 168 | public Evaluator Evaluator {
|
---|
| 169 | get { return EvaluatorParameter.Value; }
|
---|
| 170 | set { EvaluatorParameter.Value = value; }
|
---|
| 171 | }
|
---|
[5809] | 172 | ISingleObjectiveEvaluator ISingleObjectiveHeuristicOptimizationProblem.Evaluator {
|
---|
[3223] | 173 | get { return EvaluatorParameter.Value; }
|
---|
| 174 | }
|
---|
[5809] | 175 | IEvaluator IHeuristicOptimizationProblem.Evaluator {
|
---|
[3223] | 176 | get { return EvaluatorParameter.Value; }
|
---|
| 177 | }
|
---|
[3338] | 178 | public GlobalSymbolicExpressionGrammar ArtificialAntExpressionGrammar {
|
---|
| 179 | get { return (GlobalSymbolicExpressionGrammar)ArtificialAntExpressionGrammarParameter.Value; }
|
---|
[3223] | 180 | }
|
---|
| 181 | public DoubleValue BestKnownQuality {
|
---|
| 182 | get { return BestKnownQualityParameter.Value; }
|
---|
| 183 | }
|
---|
| 184 | public IEnumerable<IOperator> Operators {
|
---|
[3631] | 185 | get { return operators; }
|
---|
[3223] | 186 | }
|
---|
[3631] | 187 |
|
---|
[3681] | 188 | public IEnumerable<IAntTrailAnalyzer> AntTrailAnalyzers {
|
---|
| 189 | get { return operators.OfType<IAntTrailAnalyzer>(); }
|
---|
[3631] | 190 | }
|
---|
[3223] | 191 | #endregion
|
---|
| 192 |
|
---|
[4098] | 193 | [Storable]
|
---|
| 194 | private List<IOperator> operators;
|
---|
| 195 |
|
---|
| 196 | [StorableConstructor]
|
---|
[4106] | 197 | private ArtificialAntProblem(bool deserializing) : base(deserializing) { }
|
---|
[4722] | 198 | [StorableHook(HookType.AfterDeserialization)]
|
---|
| 199 | private void AfterDeserialization() {
|
---|
| 200 | // BackwardsCompatibility3.3
|
---|
| 201 | #region Backwards compatible code (remove with 3.4)
|
---|
| 202 | if (operators == null) InitializeOperators();
|
---|
| 203 | #endregion
|
---|
| 204 | AttachEventHandlers();
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | private ArtificialAntProblem(ArtificialAntProblem original, Cloner cloner)
|
---|
| 208 | : base(original, cloner) {
|
---|
| 209 | operators = original.operators.Select(x => cloner.Clone(x)).ToList();
|
---|
| 210 | AttachEventHandlers();
|
---|
| 211 | }
|
---|
| 212 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 213 | return new ArtificialAntProblem(this, cloner);
|
---|
| 214 | }
|
---|
[3223] | 215 | public ArtificialAntProblem()
|
---|
| 216 | : base() {
|
---|
| 217 | SymbolicExpressionTreeCreator creator = new ProbabilisticTreeCreator();
|
---|
| 218 | Evaluator evaluator = new Evaluator();
|
---|
[3239] | 219 | BoolMatrix world = new BoolMatrix(santaFeAntTrail);
|
---|
[3338] | 220 | ISymbolicExpressionGrammar grammar = new GlobalSymbolicExpressionGrammar(new ArtificialAntExpressionGrammar());
|
---|
[3223] | 221 | Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the Artificial Ant Problem is a maximization problem.", new BoolValue(true)));
|
---|
| 222 | Parameters.Add(new ValueParameter<SymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new artificial ant solutions.", creator));
|
---|
| 223 | Parameters.Add(new ValueParameter<Evaluator>("Evaluator", "The operator which should be used to evaluate artificial ant solutions.", evaluator));
|
---|
[3251] | 224 | Parameters.Add(new ValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this artificial ant instance.", new DoubleValue(89)));
|
---|
[3223] | 225 | Parameters.Add(new ValueParameter<IntValue>("MaxExpressionLength", "Maximal length of the expression to control the artificial ant.", new IntValue(100)));
|
---|
| 226 | Parameters.Add(new ValueParameter<IntValue>("MaxExpressionDepth", "Maximal depth of the expression to control the artificial ant.", new IntValue(10)));
|
---|
[3294] | 227 | Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefinitions", "Maximal number of automatically defined functions in the expression to control the artificial ant.", new IntValue(3)));
|
---|
| 228 | Parameters.Add(new ValueParameter<IntValue>("MaxFunctionArguments", "Maximal number of arguments of automatically defined functions in the expression to control the artificial ant.", new IntValue(3)));
|
---|
[3338] | 229 | Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("ArtificialAntExpressionGrammar", "The grammar that should be used for artificial ant expressions.", grammar));
|
---|
[3239] | 230 | Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world));
|
---|
| 231 | Parameters.Add(new ValueParameter<IntValue>("MaxTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600)));
|
---|
[3223] | 232 |
|
---|
| 233 | creator.SymbolicExpressionTreeParameter.ActualName = "AntTrailSolution";
|
---|
| 234 | evaluator.QualityParameter.ActualName = "FoodEaten";
|
---|
| 235 | ParameterizeSolutionCreator();
|
---|
| 236 | ParameterizeEvaluator();
|
---|
[4098] | 237 | InitializeOperators();
|
---|
| 238 | AttachEventHandlers();
|
---|
[3223] | 239 | }
|
---|
| 240 |
|
---|
| 241 | #region Events
|
---|
| 242 | public event EventHandler SolutionCreatorChanged;
|
---|
| 243 | private void OnSolutionCreatorChanged() {
|
---|
[3739] | 244 | EventHandler handler = SolutionCreatorChanged;
|
---|
| 245 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
[3223] | 246 | }
|
---|
| 247 | public event EventHandler EvaluatorChanged;
|
---|
| 248 | private void OnEvaluatorChanged() {
|
---|
[3739] | 249 | EventHandler handler = EvaluatorChanged;
|
---|
| 250 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
[3223] | 251 | }
|
---|
| 252 | public event EventHandler OperatorsChanged;
|
---|
| 253 | private void OnOperatorsChanged() {
|
---|
[3739] | 254 | EventHandler handler = OperatorsChanged;
|
---|
| 255 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
[3223] | 256 | }
|
---|
[3739] | 257 | public event EventHandler Reset;
|
---|
| 258 | private void OnReset() {
|
---|
| 259 | EventHandler handler = Reset;
|
---|
| 260 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
| 261 | }
|
---|
[3223] | 262 |
|
---|
| 263 | private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 264 | SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
| 265 | ParameterizeSolutionCreator();
|
---|
| 266 | ParameterizeEvaluator();
|
---|
[3631] | 267 | ParameterizeAnalyzers();
|
---|
[3223] | 268 | ParameterizeOperators();
|
---|
| 269 | OnSolutionCreatorChanged();
|
---|
| 270 | }
|
---|
| 271 | private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
| 272 | ParameterizeEvaluator();
|
---|
[3631] | 273 | ParameterizeAnalyzers();
|
---|
[3223] | 274 | ParameterizeOperators();
|
---|
| 275 | }
|
---|
| 276 | private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
[3239] | 277 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
[3223] | 278 | ParameterizeEvaluator();
|
---|
[3631] | 279 | ParameterizeAnalyzers();
|
---|
[3223] | 280 | OnEvaluatorChanged();
|
---|
| 281 | }
|
---|
[3239] | 282 |
|
---|
| 283 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
[3631] | 284 | ParameterizeAnalyzers();
|
---|
[3239] | 285 | }
|
---|
| 286 |
|
---|
[3223] | 287 | #endregion
|
---|
| 288 |
|
---|
| 289 | #region Helpers
|
---|
[4098] | 290 | private void AttachEventHandlers() {
|
---|
[3223] | 291 | SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
|
---|
| 292 | SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
| 293 | EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
|
---|
[3239] | 294 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
[3338] | 295 | MaxFunctionArgumentsParameter.ValueChanged += new EventHandler(MaxFunctionArgumentsParameter_ValueChanged);
|
---|
| 296 | MaxFunctionArguments.ValueChanged += new EventHandler(MaxFunctionArgumentsParameter_ValueChanged);
|
---|
| 297 | MaxFunctionDefinitionsParameter.ValueChanged += new EventHandler(MaxFunctionDefinitionsParameter_ValueChanged);
|
---|
| 298 | MaxFunctionDefinitions.ValueChanged += new EventHandler(MaxFunctionDefinitionsParameter_ValueChanged);
|
---|
[3223] | 299 | }
|
---|
[3239] | 300 |
|
---|
[3338] | 301 | void MaxFunctionDefinitionsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 302 | ArtificialAntExpressionGrammar.MaxFunctionDefinitions = MaxFunctionDefinitions.Value;
|
---|
| 303 | }
|
---|
| 304 |
|
---|
| 305 | void MaxFunctionArgumentsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 306 | ArtificialAntExpressionGrammar.MaxFunctionArguments = MaxFunctionArguments.Value;
|
---|
| 307 | }
|
---|
| 308 |
|
---|
[3239] | 309 | private void InitializeOperators() {
|
---|
[3631] | 310 | operators = new List<IOperator>();
|
---|
| 311 | operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>().OfType<IOperator>());
|
---|
[3681] | 312 | operators.Add(new BestAntTrailAnalyzer());
|
---|
[3817] | 313 | operators.Add(new MinAverageMaxSymbolicExpressionTreeSizeAnalyzer());
|
---|
[5395] | 314 | operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());
|
---|
[3631] | 315 | ParameterizeAnalyzers();
|
---|
[3239] | 316 | ParameterizeOperators();
|
---|
| 317 | }
|
---|
| 318 |
|
---|
[3223] | 319 | private void ParameterizeSolutionCreator() {
|
---|
| 320 | SolutionCreator.SymbolicExpressionGrammarParameter.ActualName = ArtificialAntExpressionGrammarParameter.Name;
|
---|
[3239] | 321 | SolutionCreator.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
|
---|
| 322 | SolutionCreator.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
|
---|
[3223] | 323 | }
|
---|
| 324 | private void ParameterizeEvaluator() {
|
---|
| 325 | Evaluator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
[3239] | 326 | Evaluator.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
|
---|
| 327 | Evaluator.WorldParameter.ActualName = WorldParameter.Name;
|
---|
[3223] | 328 | }
|
---|
[3631] | 329 | private void ParameterizeAnalyzers() {
|
---|
[3681] | 330 | foreach (IAntTrailAnalyzer analyzer in AntTrailAnalyzers) {
|
---|
[3631] | 331 | analyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
|
---|
| 332 | analyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
| 333 | analyzer.WorldParameter.ActualName = WorldParameter.Name;
|
---|
| 334 | analyzer.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
|
---|
| 335 | }
|
---|
[3681] | 336 | foreach (ISymbolicExpressionTreeAnalyzer analyzer in Operators.OfType<ISymbolicExpressionTreeAnalyzer>()) {
|
---|
[3651] | 337 | analyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
| 338 | }
|
---|
[3223] | 339 | }
|
---|
| 340 |
|
---|
| 341 | private void ParameterizeOperators() {
|
---|
[3239] | 342 | foreach (ISymbolicExpressionTreeOperator op in Operators.OfType<ISymbolicExpressionTreeOperator>()) {
|
---|
[3223] | 343 | op.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
|
---|
| 344 | op.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
|
---|
| 345 | op.SymbolicExpressionGrammarParameter.ActualName = ArtificialAntExpressionGrammarParameter.Name;
|
---|
| 346 | }
|
---|
| 347 | foreach (Evaluator op in Operators.OfType<Evaluator>()) {
|
---|
| 348 | op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
[3239] | 349 | op.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
|
---|
| 350 | op.WorldParameter.ActualName = WorldParameter.Name;
|
---|
[3223] | 351 | }
|
---|
[3539] | 352 | foreach (ISymbolicExpressionTreeCrossover op in Operators.OfType<ISymbolicExpressionTreeCrossover>()) {
|
---|
[3238] | 353 | op.ParentsParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
| 354 | op.ChildParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
| 355 | }
|
---|
[3539] | 356 | foreach (ISymbolicExpressionTreeManipulator op in Operators.OfType<ISymbolicExpressionTreeManipulator>()) {
|
---|
[3294] | 357 | op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
| 358 | }
|
---|
[3534] | 359 | foreach (ISymbolicExpressionTreeArchitectureManipulator op in Operators.OfType<ISymbolicExpressionTreeArchitectureManipulator>()) {
|
---|
| 360 | op.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name;
|
---|
[3294] | 361 | op.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
|
---|
| 362 | }
|
---|
[3338] | 363 | foreach (SymbolicExpressionTreeCreator op in Operators.OfType<SymbolicExpressionTreeCreator>()) {
|
---|
| 364 | op.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
|
---|
| 365 | op.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name;
|
---|
| 366 | }
|
---|
[3223] | 367 | }
|
---|
[3238] | 368 |
|
---|
[3239] | 369 |
|
---|
[3223] | 370 | #endregion
|
---|
| 371 | }
|
---|
| 372 | }
|
---|