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;
|
---|
34 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
|
---|
35 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Crossovers;
|
---|
36 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators;
|
---|
37 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
|
---|
38 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
|
---|
39 |
|
---|
40 | namespace HeuristicLab.Problems.ArtificialAnt {
|
---|
41 | [Item("Artificial Ant Problem", "Represents the Artificial Ant problem.")]
|
---|
42 | [Creatable("Problems")]
|
---|
43 | [StorableClass]
|
---|
44 | public sealed class ArtificialAntProblem : ParameterizedNamedItem, ISingleObjectiveProblem {
|
---|
45 | public override Image ItemImage {
|
---|
46 | get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
|
---|
47 | }
|
---|
48 |
|
---|
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 |
|
---|
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 | }
|
---|
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 | }
|
---|
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 | }
|
---|
126 |
|
---|
127 | public OptionalValueParameter<ISingleObjectiveSolutionsVisualizer> VisualizerParameter {
|
---|
128 | get { return (OptionalValueParameter<ISingleObjectiveSolutionsVisualizer>)Parameters["Visualizer"]; }
|
---|
129 | }
|
---|
130 | IParameter IProblem.VisualizerParameter {
|
---|
131 | get { return VisualizerParameter; }
|
---|
132 | }
|
---|
133 | public ValueParameter<DoubleValue> BestKnownQualityParameter {
|
---|
134 | get { return (ValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
|
---|
135 | }
|
---|
136 | IParameter ISingleObjectiveProblem.BestKnownQualityParameter {
|
---|
137 | get { return BestKnownQualityParameter; }
|
---|
138 | }
|
---|
139 | #endregion
|
---|
140 |
|
---|
141 | #region Properties
|
---|
142 | public BoolMatrix World {
|
---|
143 | get { return WorldParameter.Value; }
|
---|
144 | set { WorldParameter.Value = value; }
|
---|
145 | }
|
---|
146 | public IntValue MaxTimeSteps {
|
---|
147 | get { return MaxTimeStepsParameter.Value; }
|
---|
148 | set { MaxTimeStepsParameter.Value = value; }
|
---|
149 | }
|
---|
150 | public IntValue MaxExpressionLength {
|
---|
151 | get { return MaxExpressionLengthParameter.Value; }
|
---|
152 | set { MaxExpressionLengthParameter.Value = value; }
|
---|
153 | }
|
---|
154 | public IntValue MaxExpressionDepth {
|
---|
155 | get { return MaxExpressionDepthParameter.Value; }
|
---|
156 | set { MaxExpressionDepthParameter.Value = value; }
|
---|
157 | }
|
---|
158 | public IntValue MaxFunctionDefinitions {
|
---|
159 | get { return MaxFunctionDefinitionsParameter.Value; }
|
---|
160 | set { MaxFunctionDefinitionsParameter.Value = value; }
|
---|
161 | }
|
---|
162 | public IntValue MaxFunctionArguments {
|
---|
163 | get { return MaxFunctionArgumentsParameter.Value; }
|
---|
164 | set { MaxFunctionArgumentsParameter.Value = value; }
|
---|
165 | }
|
---|
166 | public SymbolicExpressionTreeCreator SolutionCreator {
|
---|
167 | get { return SolutionCreatorParameter.Value; }
|
---|
168 | set { SolutionCreatorParameter.Value = value; }
|
---|
169 | }
|
---|
170 | ISolutionCreator IProblem.SolutionCreator {
|
---|
171 | get { return SolutionCreatorParameter.Value; }
|
---|
172 | }
|
---|
173 | public Evaluator Evaluator {
|
---|
174 | get { return EvaluatorParameter.Value; }
|
---|
175 | set { EvaluatorParameter.Value = value; }
|
---|
176 | }
|
---|
177 | ISingleObjectiveEvaluator ISingleObjectiveProblem.Evaluator {
|
---|
178 | get { return EvaluatorParameter.Value; }
|
---|
179 | }
|
---|
180 | IEvaluator IProblem.Evaluator {
|
---|
181 | get { return EvaluatorParameter.Value; }
|
---|
182 | }
|
---|
183 | public GlobalSymbolicExpressionGrammar ArtificialAntExpressionGrammar {
|
---|
184 | get { return (GlobalSymbolicExpressionGrammar)ArtificialAntExpressionGrammarParameter.Value; }
|
---|
185 | }
|
---|
186 | public ISingleObjectiveSolutionsVisualizer Visualizer {
|
---|
187 | get { return VisualizerParameter.Value; }
|
---|
188 | set { VisualizerParameter.Value = value; }
|
---|
189 | }
|
---|
190 | ISolutionsVisualizer IProblem.Visualizer {
|
---|
191 | get { return VisualizerParameter.Value; }
|
---|
192 | }
|
---|
193 | public DoubleValue BestKnownQuality {
|
---|
194 | get { return BestKnownQualityParameter.Value; }
|
---|
195 | }
|
---|
196 | private List<ISymbolicExpressionTreeOperator> operators;
|
---|
197 | public IEnumerable<IOperator> Operators {
|
---|
198 | get { return operators.Cast<IOperator>(); }
|
---|
199 | }
|
---|
200 | #endregion
|
---|
201 |
|
---|
202 | public ArtificialAntProblem()
|
---|
203 | : base() {
|
---|
204 | SymbolicExpressionTreeCreator creator = new ProbabilisticTreeCreator();
|
---|
205 | Evaluator evaluator = new Evaluator();
|
---|
206 | BestAntTrailVisualizer visualizer = new BestAntTrailVisualizer();
|
---|
207 | BoolMatrix world = new BoolMatrix(santaFeAntTrail);
|
---|
208 | ISymbolicExpressionGrammar grammar = new GlobalSymbolicExpressionGrammar(new ArtificialAntExpressionGrammar());
|
---|
209 | Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the Artificial Ant Problem is a maximization problem.", new BoolValue(true)));
|
---|
210 | Parameters.Add(new ValueParameter<SymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new artificial ant solutions.", creator));
|
---|
211 | Parameters.Add(new ValueParameter<Evaluator>("Evaluator", "The operator which should be used to evaluate artificial ant solutions.", evaluator));
|
---|
212 | Parameters.Add(new ValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this artificial ant instance.", new DoubleValue(89)));
|
---|
213 | Parameters.Add(new ValueParameter<IntValue>("MaxExpressionLength", "Maximal length of the expression to control the artificial ant.", new IntValue(100)));
|
---|
214 | Parameters.Add(new ValueParameter<IntValue>("MaxExpressionDepth", "Maximal depth of the expression to control the artificial ant.", new IntValue(10)));
|
---|
215 | Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefinitions", "Maximal number of automatically defined functions in the expression to control the artificial ant.", new IntValue(3)));
|
---|
216 | 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)));
|
---|
217 | Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("ArtificialAntExpressionGrammar", "The grammar that should be used for artificial ant expressions.", grammar));
|
---|
218 | Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world));
|
---|
219 | Parameters.Add(new ValueParameter<IntValue>("MaxTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600)));
|
---|
220 | Parameters.Add(new ValueParameter<ISingleObjectiveSolutionsVisualizer>("Visualizer", "The operator which should be used to visualize artificial ant solutions.", visualizer));
|
---|
221 |
|
---|
222 | creator.SymbolicExpressionTreeParameter.ActualName = "AntTrailSolution";
|
---|
223 | evaluator.QualityParameter.ActualName = "FoodEaten";
|
---|
224 | ParameterizeSolutionCreator();
|
---|
225 | ParameterizeEvaluator();
|
---|
226 | ParameterizeVisualizer();
|
---|
227 |
|
---|
228 | Initialize();
|
---|
229 | }
|
---|
230 |
|
---|
231 | [StorableConstructor]
|
---|
232 | private ArtificialAntProblem(bool deserializing) : base() { }
|
---|
233 |
|
---|
234 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
235 | ArtificialAntProblem clone = (ArtificialAntProblem)base.Clone(cloner);
|
---|
236 | clone.Initialize();
|
---|
237 | return clone;
|
---|
238 | }
|
---|
239 |
|
---|
240 | #region Events
|
---|
241 | public event EventHandler SolutionCreatorChanged;
|
---|
242 | private void OnSolutionCreatorChanged() {
|
---|
243 | var changed = SolutionCreatorChanged;
|
---|
244 | if (changed != null)
|
---|
245 | changed(this, EventArgs.Empty);
|
---|
246 | }
|
---|
247 | public event EventHandler EvaluatorChanged;
|
---|
248 | private void OnEvaluatorChanged() {
|
---|
249 | var changed = EvaluatorChanged;
|
---|
250 | if (changed != null)
|
---|
251 | changed(this, EventArgs.Empty);
|
---|
252 | }
|
---|
253 | public event EventHandler VisualizerChanged;
|
---|
254 | private void OnVisualizerChanged() {
|
---|
255 | var changed = VisualizerChanged;
|
---|
256 | if (changed != null)
|
---|
257 | changed(this, EventArgs.Empty);
|
---|
258 | }
|
---|
259 |
|
---|
260 | public event EventHandler OperatorsChanged;
|
---|
261 | private void OnOperatorsChanged() {
|
---|
262 | var changed = OperatorsChanged;
|
---|
263 | if (changed != null)
|
---|
264 | changed(this, EventArgs.Empty);
|
---|
265 | }
|
---|
266 |
|
---|
267 | private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
268 | SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
269 | ParameterizeSolutionCreator();
|
---|
270 | ParameterizeEvaluator();
|
---|
271 | ParameterizeVisualizer();
|
---|
272 | ParameterizeOperators();
|
---|
273 | OnSolutionCreatorChanged();
|
---|
274 | }
|
---|
275 | private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
276 | ParameterizeEvaluator();
|
---|
277 | ParameterizeVisualizer();
|
---|
278 | ParameterizeOperators();
|
---|
279 | }
|
---|
280 | private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
281 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
282 | ParameterizeEvaluator();
|
---|
283 | ParameterizeVisualizer();
|
---|
284 | OnEvaluatorChanged();
|
---|
285 | }
|
---|
286 |
|
---|
287 | private void VisualizerParameter_ValueChanged(object sender, EventArgs e) {
|
---|
288 | ParameterizeVisualizer();
|
---|
289 | OnVisualizerChanged();
|
---|
290 | }
|
---|
291 |
|
---|
292 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
293 | ParameterizeVisualizer();
|
---|
294 | }
|
---|
295 |
|
---|
296 | #endregion
|
---|
297 |
|
---|
298 | #region Helpers
|
---|
299 | [StorableHook(HookType.AfterDeserialization)]
|
---|
300 | private void Initialize() {
|
---|
301 | InitializeOperators();
|
---|
302 | SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
|
---|
303 | SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
304 | EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
|
---|
305 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
306 | VisualizerParameter.ValueChanged += new EventHandler(VisualizerParameter_ValueChanged);
|
---|
307 | MaxFunctionArgumentsParameter.ValueChanged += new EventHandler(MaxFunctionArgumentsParameter_ValueChanged);
|
---|
308 | MaxFunctionArguments.ValueChanged += new EventHandler(MaxFunctionArgumentsParameter_ValueChanged);
|
---|
309 | MaxFunctionDefinitionsParameter.ValueChanged += new EventHandler(MaxFunctionDefinitionsParameter_ValueChanged);
|
---|
310 | MaxFunctionDefinitions.ValueChanged += new EventHandler(MaxFunctionDefinitionsParameter_ValueChanged);
|
---|
311 | }
|
---|
312 |
|
---|
313 | void MaxFunctionDefinitionsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
314 | ArtificialAntExpressionGrammar.MaxFunctionDefinitions = MaxFunctionDefinitions.Value;
|
---|
315 | }
|
---|
316 |
|
---|
317 | void MaxFunctionArgumentsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
318 | ArtificialAntExpressionGrammar.MaxFunctionArguments = MaxFunctionArguments.Value;
|
---|
319 | }
|
---|
320 |
|
---|
321 | private void InitializeOperators() {
|
---|
322 | operators = new List<ISymbolicExpressionTreeOperator>();
|
---|
323 | operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
|
---|
324 | ParameterizeOperators();
|
---|
325 | }
|
---|
326 |
|
---|
327 | private void ParameterizeSolutionCreator() {
|
---|
328 | SolutionCreator.SymbolicExpressionGrammarParameter.ActualName = ArtificialAntExpressionGrammarParameter.Name;
|
---|
329 | SolutionCreator.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
|
---|
330 | SolutionCreator.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
|
---|
331 | }
|
---|
332 | private void ParameterizeEvaluator() {
|
---|
333 | Evaluator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
334 | Evaluator.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
|
---|
335 | Evaluator.WorldParameter.ActualName = WorldParameter.Name;
|
---|
336 | }
|
---|
337 | private void ParameterizeVisualizer() {
|
---|
338 | if (Visualizer != null) {
|
---|
339 | Visualizer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
|
---|
340 | var antTrailVisualizer = Visualizer as IAntTrailVisualizer;
|
---|
341 | if (antTrailVisualizer != null) {
|
---|
342 | antTrailVisualizer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
343 | antTrailVisualizer.WorldParameter.ActualName = WorldParameter.Name;
|
---|
344 | antTrailVisualizer.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
|
---|
345 | }
|
---|
346 | var bestSymExpressionVisualizer = Visualizer as BestSymbolicExpressionTreeVisualizer;
|
---|
347 | if (bestSymExpressionVisualizer != null) {
|
---|
348 | bestSymExpressionVisualizer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
349 | }
|
---|
350 | }
|
---|
351 | }
|
---|
352 |
|
---|
353 | private void ParameterizeOperators() {
|
---|
354 | foreach (ISymbolicExpressionTreeOperator op in Operators.OfType<ISymbolicExpressionTreeOperator>()) {
|
---|
355 | op.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
|
---|
356 | op.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
|
---|
357 | op.SymbolicExpressionGrammarParameter.ActualName = ArtificialAntExpressionGrammarParameter.Name;
|
---|
358 | }
|
---|
359 | foreach (Evaluator op in Operators.OfType<Evaluator>()) {
|
---|
360 | op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
361 | op.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
|
---|
362 | op.WorldParameter.ActualName = WorldParameter.Name;
|
---|
363 | }
|
---|
364 | foreach (ISymbolicExpressionTreeCrossover op in Operators.OfType<ISymbolicExpressionTreeCrossover>()) {
|
---|
365 | op.ParentsParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
366 | op.ChildParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
367 | }
|
---|
368 | foreach (ISymbolicExpressionTreeManipulator op in Operators.OfType<ISymbolicExpressionTreeManipulator>()) {
|
---|
369 | op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
370 | }
|
---|
371 | foreach (ISymbolicExpressionTreeArchitectureManipulator op in Operators.OfType<ISymbolicExpressionTreeArchitectureManipulator>()) {
|
---|
372 | op.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name;
|
---|
373 | op.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
|
---|
374 | }
|
---|
375 | foreach (SymbolicExpressionTreeCreator op in Operators.OfType<SymbolicExpressionTreeCreator>()) {
|
---|
376 | op.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
|
---|
377 | op.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name;
|
---|
378 | }
|
---|
379 | }
|
---|
380 |
|
---|
381 |
|
---|
382 | #endregion
|
---|
383 | }
|
---|
384 | }
|
---|