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