[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]
|
---|
[4419] | 43 | public sealed class ArtificialAntProblem : ParameterizedNamedItem, ISingleObjectiveProblem, IStorableContent {
|
---|
| 44 | public string Filename { get; set; }
|
---|
[4098] | 45 |
|
---|
[3223] | 46 | public override Image ItemImage {
|
---|
| 47 | get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
|
---|
| 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 | }
|
---|
| 91 | IParameter ISingleObjectiveProblem.MaximizationParameter {
|
---|
| 92 | get { return MaximizationParameter; }
|
---|
| 93 | }
|
---|
| 94 | public ValueParameter<SymbolicExpressionTreeCreator> SolutionCreatorParameter {
|
---|
| 95 | get { return (ValueParameter<SymbolicExpressionTreeCreator>)Parameters["SolutionCreator"]; }
|
---|
| 96 | }
|
---|
| 97 | IParameter IProblem.SolutionCreatorParameter {
|
---|
| 98 | get { return SolutionCreatorParameter; }
|
---|
| 99 | }
|
---|
| 100 | public ValueParameter<Evaluator> EvaluatorParameter {
|
---|
| 101 | get { return (ValueParameter<Evaluator>)Parameters["Evaluator"]; }
|
---|
| 102 | }
|
---|
| 103 | IParameter IProblem.EvaluatorParameter {
|
---|
| 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 | }
|
---|
| 131 | IParameter ISingleObjectiveProblem.BestKnownQualityParameter {
|
---|
| 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 | }
|
---|
| 165 | ISolutionCreator IProblem.SolutionCreator {
|
---|
| 166 | get { return SolutionCreatorParameter.Value; }
|
---|
| 167 | }
|
---|
| 168 | public Evaluator Evaluator {
|
---|
| 169 | get { return EvaluatorParameter.Value; }
|
---|
| 170 | set { EvaluatorParameter.Value = value; }
|
---|
| 171 | }
|
---|
| 172 | ISingleObjectiveEvaluator ISingleObjectiveProblem.Evaluator {
|
---|
| 173 | get { return EvaluatorParameter.Value; }
|
---|
| 174 | }
|
---|
| 175 | IEvaluator IProblem.Evaluator {
|
---|
| 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) { }
|
---|
[3223] | 198 | public ArtificialAntProblem()
|
---|
| 199 | : base() {
|
---|
| 200 | SymbolicExpressionTreeCreator creator = new ProbabilisticTreeCreator();
|
---|
| 201 | Evaluator evaluator = new Evaluator();
|
---|
[3239] | 202 | BoolMatrix world = new BoolMatrix(santaFeAntTrail);
|
---|
[3338] | 203 | ISymbolicExpressionGrammar grammar = new GlobalSymbolicExpressionGrammar(new ArtificialAntExpressionGrammar());
|
---|
[3223] | 204 | Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the Artificial Ant Problem is a maximization problem.", new BoolValue(true)));
|
---|
| 205 | Parameters.Add(new ValueParameter<SymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new artificial ant solutions.", creator));
|
---|
| 206 | Parameters.Add(new ValueParameter<Evaluator>("Evaluator", "The operator which should be used to evaluate artificial ant solutions.", evaluator));
|
---|
[3251] | 207 | Parameters.Add(new ValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this artificial ant instance.", new DoubleValue(89)));
|
---|
[3223] | 208 | Parameters.Add(new ValueParameter<IntValue>("MaxExpressionLength", "Maximal length of the expression to control the artificial ant.", new IntValue(100)));
|
---|
| 209 | Parameters.Add(new ValueParameter<IntValue>("MaxExpressionDepth", "Maximal depth of the expression to control the artificial ant.", new IntValue(10)));
|
---|
[3294] | 210 | Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefinitions", "Maximal number of automatically defined functions in the expression to control the artificial ant.", new IntValue(3)));
|
---|
| 211 | 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] | 212 | Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("ArtificialAntExpressionGrammar", "The grammar that should be used for artificial ant expressions.", grammar));
|
---|
[3239] | 213 | Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world));
|
---|
| 214 | 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] | 215 |
|
---|
| 216 | creator.SymbolicExpressionTreeParameter.ActualName = "AntTrailSolution";
|
---|
| 217 | evaluator.QualityParameter.ActualName = "FoodEaten";
|
---|
| 218 | ParameterizeSolutionCreator();
|
---|
| 219 | ParameterizeEvaluator();
|
---|
[4098] | 220 | InitializeOperators();
|
---|
| 221 | AttachEventHandlers();
|
---|
[3223] | 222 | }
|
---|
| 223 |
|
---|
| 224 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 225 | ArtificialAntProblem clone = (ArtificialAntProblem)base.Clone(cloner);
|
---|
[4098] | 226 | clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
|
---|
| 227 | clone.AttachEventHandlers();
|
---|
[3223] | 228 | return clone;
|
---|
| 229 | }
|
---|
| 230 |
|
---|
| 231 | #region Events
|
---|
| 232 | public event EventHandler SolutionCreatorChanged;
|
---|
| 233 | private void OnSolutionCreatorChanged() {
|
---|
[3739] | 234 | EventHandler handler = SolutionCreatorChanged;
|
---|
| 235 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
[3223] | 236 | }
|
---|
| 237 | public event EventHandler EvaluatorChanged;
|
---|
| 238 | private void OnEvaluatorChanged() {
|
---|
[3739] | 239 | EventHandler handler = EvaluatorChanged;
|
---|
| 240 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
[3223] | 241 | }
|
---|
| 242 | public event EventHandler OperatorsChanged;
|
---|
| 243 | private void OnOperatorsChanged() {
|
---|
[3739] | 244 | EventHandler handler = OperatorsChanged;
|
---|
| 245 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
[3223] | 246 | }
|
---|
[3739] | 247 | public event EventHandler Reset;
|
---|
| 248 | private void OnReset() {
|
---|
| 249 | EventHandler handler = Reset;
|
---|
| 250 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
| 251 | }
|
---|
[3223] | 252 |
|
---|
| 253 | private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 254 | SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
| 255 | ParameterizeSolutionCreator();
|
---|
| 256 | ParameterizeEvaluator();
|
---|
[3631] | 257 | ParameterizeAnalyzers();
|
---|
[3223] | 258 | ParameterizeOperators();
|
---|
| 259 | OnSolutionCreatorChanged();
|
---|
| 260 | }
|
---|
| 261 | private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
| 262 | ParameterizeEvaluator();
|
---|
[3631] | 263 | ParameterizeAnalyzers();
|
---|
[3223] | 264 | ParameterizeOperators();
|
---|
| 265 | }
|
---|
| 266 | private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
[3239] | 267 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
[3223] | 268 | ParameterizeEvaluator();
|
---|
[3631] | 269 | ParameterizeAnalyzers();
|
---|
[3223] | 270 | OnEvaluatorChanged();
|
---|
| 271 | }
|
---|
[3239] | 272 |
|
---|
| 273 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
[3631] | 274 | ParameterizeAnalyzers();
|
---|
[3239] | 275 | }
|
---|
| 276 |
|
---|
[3223] | 277 | #endregion
|
---|
| 278 |
|
---|
| 279 | #region Helpers
|
---|
| 280 | [StorableHook(HookType.AfterDeserialization)]
|
---|
[4118] | 281 | private void AfterDeserializationHook() {
|
---|
| 282 | // BackwardsCompatibility3.3
|
---|
| 283 | #region Backwards compatible code (remove with 3.4)
|
---|
| 284 | if (operators == null) InitializeOperators();
|
---|
| 285 | #endregion
|
---|
| 286 | AttachEventHandlers();
|
---|
| 287 | }
|
---|
| 288 |
|
---|
[4098] | 289 | private void AttachEventHandlers() {
|
---|
[3223] | 290 | SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
|
---|
| 291 | SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
| 292 | EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
|
---|
[3239] | 293 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
[3338] | 294 | MaxFunctionArgumentsParameter.ValueChanged += new EventHandler(MaxFunctionArgumentsParameter_ValueChanged);
|
---|
| 295 | MaxFunctionArguments.ValueChanged += new EventHandler(MaxFunctionArgumentsParameter_ValueChanged);
|
---|
| 296 | MaxFunctionDefinitionsParameter.ValueChanged += new EventHandler(MaxFunctionDefinitionsParameter_ValueChanged);
|
---|
| 297 | MaxFunctionDefinitions.ValueChanged += new EventHandler(MaxFunctionDefinitionsParameter_ValueChanged);
|
---|
[3223] | 298 | }
|
---|
[3239] | 299 |
|
---|
[3338] | 300 | void MaxFunctionDefinitionsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 301 | ArtificialAntExpressionGrammar.MaxFunctionDefinitions = MaxFunctionDefinitions.Value;
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | void MaxFunctionArgumentsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 305 | ArtificialAntExpressionGrammar.MaxFunctionArguments = MaxFunctionArguments.Value;
|
---|
| 306 | }
|
---|
| 307 |
|
---|
[3239] | 308 | private void InitializeOperators() {
|
---|
[3631] | 309 | operators = new List<IOperator>();
|
---|
| 310 | operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>().OfType<IOperator>());
|
---|
[3681] | 311 | operators.Add(new BestAntTrailAnalyzer());
|
---|
[3817] | 312 | operators.Add(new MinAverageMaxSymbolicExpressionTreeSizeAnalyzer());
|
---|
[3631] | 313 | ParameterizeAnalyzers();
|
---|
[3239] | 314 | ParameterizeOperators();
|
---|
| 315 | }
|
---|
| 316 |
|
---|
[3223] | 317 | private void ParameterizeSolutionCreator() {
|
---|
| 318 | SolutionCreator.SymbolicExpressionGrammarParameter.ActualName = ArtificialAntExpressionGrammarParameter.Name;
|
---|
[3239] | 319 | SolutionCreator.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
|
---|
| 320 | SolutionCreator.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
|
---|
[3223] | 321 | }
|
---|
| 322 | private void ParameterizeEvaluator() {
|
---|
| 323 | Evaluator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
[3239] | 324 | Evaluator.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
|
---|
| 325 | Evaluator.WorldParameter.ActualName = WorldParameter.Name;
|
---|
[3223] | 326 | }
|
---|
[3631] | 327 | private void ParameterizeAnalyzers() {
|
---|
[3681] | 328 | foreach (IAntTrailAnalyzer analyzer in AntTrailAnalyzers) {
|
---|
[3631] | 329 | analyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
|
---|
| 330 | analyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
| 331 | analyzer.WorldParameter.ActualName = WorldParameter.Name;
|
---|
| 332 | analyzer.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
|
---|
| 333 | }
|
---|
[3681] | 334 | foreach (ISymbolicExpressionTreeAnalyzer analyzer in Operators.OfType<ISymbolicExpressionTreeAnalyzer>()) {
|
---|
[3651] | 335 | analyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
| 336 | }
|
---|
[3223] | 337 | }
|
---|
| 338 |
|
---|
| 339 | private void ParameterizeOperators() {
|
---|
[3239] | 340 | foreach (ISymbolicExpressionTreeOperator op in Operators.OfType<ISymbolicExpressionTreeOperator>()) {
|
---|
[3223] | 341 | op.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
|
---|
| 342 | op.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
|
---|
| 343 | op.SymbolicExpressionGrammarParameter.ActualName = ArtificialAntExpressionGrammarParameter.Name;
|
---|
| 344 | }
|
---|
| 345 | foreach (Evaluator op in Operators.OfType<Evaluator>()) {
|
---|
| 346 | op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
[3239] | 347 | op.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
|
---|
| 348 | op.WorldParameter.ActualName = WorldParameter.Name;
|
---|
[3223] | 349 | }
|
---|
[3539] | 350 | foreach (ISymbolicExpressionTreeCrossover op in Operators.OfType<ISymbolicExpressionTreeCrossover>()) {
|
---|
[3238] | 351 | op.ParentsParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
| 352 | op.ChildParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
| 353 | }
|
---|
[3539] | 354 | foreach (ISymbolicExpressionTreeManipulator op in Operators.OfType<ISymbolicExpressionTreeManipulator>()) {
|
---|
[3294] | 355 | op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
| 356 | }
|
---|
[3534] | 357 | foreach (ISymbolicExpressionTreeArchitectureManipulator op in Operators.OfType<ISymbolicExpressionTreeArchitectureManipulator>()) {
|
---|
| 358 | op.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name;
|
---|
[3294] | 359 | op.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
|
---|
| 360 | }
|
---|
[3338] | 361 | foreach (SymbolicExpressionTreeCreator op in Operators.OfType<SymbolicExpressionTreeCreator>()) {
|
---|
| 362 | op.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
|
---|
| 363 | op.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name;
|
---|
| 364 | }
|
---|
[3223] | 365 | }
|
---|
[3238] | 366 |
|
---|
[3239] | 367 |
|
---|
[3223] | 368 | #endregion
|
---|
| 369 | }
|
---|
| 370 | }
|
---|