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