1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2013 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.Drawing;
|
---|
24 | using System.Linq;
|
---|
25 | using HeuristicLab.Common;
|
---|
26 | using HeuristicLab.Common.Resources;
|
---|
27 | using HeuristicLab.Core;
|
---|
28 | using HeuristicLab.Data;
|
---|
29 | using HeuristicLab.Encodings.IntegerVectorEncoding;
|
---|
30 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
31 | using HeuristicLab.Optimization;
|
---|
32 | using HeuristicLab.Parameters;
|
---|
33 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
34 | using HeuristicLab.PluginInfrastructure;
|
---|
35 | using HeuristicLab.Problems.DataAnalysis;
|
---|
36 | using HeuristicLab.Problems.DataAnalysis.Symbolic;
|
---|
37 | using HeuristicLab.Problems.GrammaticalEvolution.Mappers;
|
---|
38 | using HeuristicLab.Problems.Instances;
|
---|
39 |
|
---|
40 | namespace HeuristicLab.Problems.GrammaticalEvolution {
|
---|
41 | [StorableClass]
|
---|
42 | // TODO: ISymbolicDataAnalysisProblem -> IGESymbolicDataAnalysisProblem
|
---|
43 | public abstract class GESymbolicDataAnalysisProblem<T, U, V> : HeuristicOptimizationProblem<U, V>, IDataAnalysisProblem<T>,
|
---|
44 | ISymbolicDataAnalysisProblem, IStorableContent,
|
---|
45 | IProblemInstanceConsumer<T>, IProblemInstanceExporter<T>
|
---|
46 | where T : class, IDataAnalysisProblemData
|
---|
47 | where U : class, IGESymbolicDataAnalysisEvaluator<T>
|
---|
48 | where V : class, IIntegerVectorCreator {
|
---|
49 |
|
---|
50 | #region parameter names & descriptions
|
---|
51 | private const string ProblemDataParameterName = "ProblemData";
|
---|
52 | private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
|
---|
53 | private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
|
---|
54 | private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
|
---|
55 | private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
|
---|
56 | private const string MaximumFunctionDefinitionsParameterName = "MaximumFunctionDefinitions";
|
---|
57 | private const string MaximumFunctionArgumentsParameterName = "MaximumFunctionArguments";
|
---|
58 | private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples";
|
---|
59 | private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition";
|
---|
60 | private const string ValidationPartitionParameterName = "ValidationPartition";
|
---|
61 | private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
|
---|
62 | private const string BoundsParameterName = "Bounds";
|
---|
63 | private const string GenotypeToPhenotypeMapperParameterName = "GenotypeToPhenotypeMapper";
|
---|
64 |
|
---|
65 | private const string ProblemDataParameterDescription = "";
|
---|
66 | private const string SymbolicExpressionTreeGrammarParameterDescription = "The grammar that should be used for symbolic expression tree.";
|
---|
67 | private const string SymoblicExpressionTreeInterpreterParameterDescription = "The interpreter that should be used to evaluate the symbolic expression tree.";
|
---|
68 | private const string MaximumSymbolicExpressionTreeDepthParameterDescription = "Maximal depth of the symbolic expression. The minimum depth needed for the algorithm is 3 because two levels are reserved for the ProgramRoot and the Start symbol.";
|
---|
69 | private const string MaximumSymbolicExpressionTreeLengthParameterDescription = "Maximal length of the symbolic expression.";
|
---|
70 | private const string MaximumFunctionDefinitionsParameterDescription = "Maximal number of automatically defined functions";
|
---|
71 | private const string MaximumFunctionArgumentsParameterDescription = "Maximal number of arguments of automatically defined functions.";
|
---|
72 | private const string RelativeNumberOfEvaluatedSamplesParameterDescription = "The relative number of samples of the dataset partition, which should be randomly chosen for evaluation.";
|
---|
73 | private const string FitnessCalculationPartitionParameterDescription = "The partition of the problem data training partition, that should be used to calculate the fitness of an individual.";
|
---|
74 | private const string ValidationPartitionParameterDescription = "The partition of the problem data training partition, that should be used to select the best model from (optional).";
|
---|
75 | private const string ApplyLinearScalingParameterDescription = "Flag that indicates if the individual should be linearly scaled before evaluating.";
|
---|
76 | private const string BoundsParameterDescription = "The integer number range in which the single genomes of a genotype are created.";
|
---|
77 | private const string GenotypeToPhenotypeMapperParameterDescription = "Maps the genotype (an integer vector) to the phenotype (a symbolic expression tree).";
|
---|
78 | #endregion
|
---|
79 |
|
---|
80 | #region parameter properties
|
---|
81 | IParameter IDataAnalysisProblem.ProblemDataParameter {
|
---|
82 | get { return ProblemDataParameter; }
|
---|
83 | }
|
---|
84 | public IValueParameter<T> ProblemDataParameter {
|
---|
85 | get { return (IValueParameter<T>)Parameters[ProblemDataParameterName]; }
|
---|
86 | }
|
---|
87 | public IValueParameter<ISymbolicDataAnalysisGrammar> SymbolicExpressionTreeGrammarParameter {
|
---|
88 | get { return (IValueParameter<ISymbolicDataAnalysisGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
|
---|
89 | }
|
---|
90 | public IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
|
---|
91 | get { return (IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
|
---|
92 | }
|
---|
93 | public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
|
---|
94 | get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
|
---|
95 | }
|
---|
96 | public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
|
---|
97 | get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
|
---|
98 | }
|
---|
99 | public IFixedValueParameter<IntValue> MaximumFunctionDefinitionsParameter {
|
---|
100 | get { return (IFixedValueParameter<IntValue>)Parameters[MaximumFunctionDefinitionsParameterName]; }
|
---|
101 | }
|
---|
102 | public IFixedValueParameter<IntValue> MaximumFunctionArgumentsParameter {
|
---|
103 | get { return (IFixedValueParameter<IntValue>)Parameters[MaximumFunctionArgumentsParameterName]; }
|
---|
104 | }
|
---|
105 | public IFixedValueParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter {
|
---|
106 | get { return (IFixedValueParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; }
|
---|
107 | }
|
---|
108 | public IFixedValueParameter<IntRange> FitnessCalculationPartitionParameter {
|
---|
109 | get { return (IFixedValueParameter<IntRange>)Parameters[FitnessCalculationPartitionParameterName]; }
|
---|
110 | }
|
---|
111 | public IFixedValueParameter<IntRange> ValidationPartitionParameter {
|
---|
112 | get { return (IFixedValueParameter<IntRange>)Parameters[ValidationPartitionParameterName]; }
|
---|
113 | }
|
---|
114 | public IFixedValueParameter<BoolValue> ApplyLinearScalingParameter {
|
---|
115 | get { return (IFixedValueParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
|
---|
116 | }
|
---|
117 | public IValueParameter<IntMatrix> BoundsParameter {
|
---|
118 | get { return (IValueParameter<IntMatrix>)Parameters[BoundsParameterName]; }
|
---|
119 | }
|
---|
120 | public IValueParameter<IGenotypeToPhenotypeMapper> GenotypeToPhenotypeMapperParameter {
|
---|
121 | get { return (IValueParameter<IGenotypeToPhenotypeMapper>)Parameters[GenotypeToPhenotypeMapperParameterName]; }
|
---|
122 | }
|
---|
123 | #endregion
|
---|
124 |
|
---|
125 | #region properties
|
---|
126 | public string Filename { get; set; }
|
---|
127 | public static new Image StaticItemImage { get { return VSImageLibrary.Type; } }
|
---|
128 |
|
---|
129 | IDataAnalysisProblemData IDataAnalysisProblem.ProblemData {
|
---|
130 | get { return ProblemData; }
|
---|
131 | }
|
---|
132 | public T ProblemData {
|
---|
133 | get { return ProblemDataParameter.Value; }
|
---|
134 | set { ProblemDataParameter.Value = value; }
|
---|
135 | }
|
---|
136 |
|
---|
137 | public ISymbolicDataAnalysisGrammar SymbolicExpressionTreeGrammar {
|
---|
138 | get { return SymbolicExpressionTreeGrammarParameter.Value; }
|
---|
139 | set { SymbolicExpressionTreeGrammarParameter.Value = value; }
|
---|
140 | }
|
---|
141 | public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicExpressionTreeInterpreter {
|
---|
142 | get { return SymbolicExpressionTreeInterpreterParameter.Value; }
|
---|
143 | set { SymbolicExpressionTreeInterpreterParameter.Value = value; }
|
---|
144 | }
|
---|
145 |
|
---|
146 | public IntValue MaximumSymbolicExpressionTreeDepth {
|
---|
147 | get { return MaximumSymbolicExpressionTreeDepthParameter.Value; }
|
---|
148 | }
|
---|
149 | public IntValue MaximumSymbolicExpressionTreeLength {
|
---|
150 | get { return MaximumSymbolicExpressionTreeLengthParameter.Value; }
|
---|
151 | }
|
---|
152 | public IntValue MaximumFunctionDefinitions {
|
---|
153 | get { return MaximumFunctionDefinitionsParameter.Value; }
|
---|
154 | }
|
---|
155 | public IntValue MaximumFunctionArguments {
|
---|
156 | get { return MaximumFunctionArgumentsParameter.Value; }
|
---|
157 | }
|
---|
158 | public PercentValue RelativeNumberOfEvaluatedSamples {
|
---|
159 | get { return RelativeNumberOfEvaluatedSamplesParameter.Value; }
|
---|
160 | }
|
---|
161 |
|
---|
162 | public IntRange FitnessCalculationPartition {
|
---|
163 | get { return FitnessCalculationPartitionParameter.Value; }
|
---|
164 | }
|
---|
165 | public IntRange ValidationPartition {
|
---|
166 | get { return ValidationPartitionParameter.Value; }
|
---|
167 | }
|
---|
168 | public BoolValue ApplyLinearScaling {
|
---|
169 | get { return ApplyLinearScalingParameter.Value; }
|
---|
170 | }
|
---|
171 | #endregion
|
---|
172 |
|
---|
173 | [StorableConstructor]
|
---|
174 | protected GESymbolicDataAnalysisProblem(bool deserializing) : base(deserializing) { }
|
---|
175 | [StorableHook(HookType.AfterDeserialization)]
|
---|
176 | private void AfterDeserialization() {
|
---|
177 | if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) {
|
---|
178 | Parameters.Add(new FixedValueParameter<BoolValue>(ApplyLinearScalingParameterName, ApplyLinearScalingParameterDescription, new BoolValue(false)));
|
---|
179 | ApplyLinearScalingParameter.Hidden = true;
|
---|
180 |
|
---|
181 | //it is assumed that for all symbolic regression algorithms linear scaling was set to true
|
---|
182 | //there is no possibility to determine the previous value of the parameter as it was stored in the evaluator
|
---|
183 | if (GetType().Name.Contains("SymbolicRegression"))
|
---|
184 | ApplyLinearScaling.Value = true;
|
---|
185 | }
|
---|
186 |
|
---|
187 | RegisterEventHandlers();
|
---|
188 | }
|
---|
189 | protected GESymbolicDataAnalysisProblem(GESymbolicDataAnalysisProblem<T, U, V> original, Cloner cloner)
|
---|
190 | : base(original, cloner) {
|
---|
191 | RegisterEventHandlers();
|
---|
192 | }
|
---|
193 |
|
---|
194 | protected GESymbolicDataAnalysisProblem(T problemData, U evaluator, V solutionCreator)
|
---|
195 | : base(evaluator, solutionCreator) {
|
---|
196 | Parameters.Add(new ValueParameter<T>(ProblemDataParameterName, ProblemDataParameterDescription, problemData));
|
---|
197 | Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(SymbolicExpressionTreeGrammarParameterName, SymbolicExpressionTreeGrammarParameterDescription));
|
---|
198 | Parameters.Add(new ValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, SymoblicExpressionTreeInterpreterParameterDescription));
|
---|
199 | Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, MaximumSymbolicExpressionTreeDepthParameterDescription));
|
---|
200 | Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, MaximumSymbolicExpressionTreeLengthParameterDescription));
|
---|
201 | Parameters.Add(new FixedValueParameter<IntValue>(MaximumFunctionDefinitionsParameterName, MaximumFunctionDefinitionsParameterDescription));
|
---|
202 | Parameters.Add(new FixedValueParameter<IntValue>(MaximumFunctionArgumentsParameterName, MaximumFunctionArgumentsParameterDescription));
|
---|
203 | Parameters.Add(new FixedValueParameter<IntRange>(FitnessCalculationPartitionParameterName, FitnessCalculationPartitionParameterDescription));
|
---|
204 | Parameters.Add(new FixedValueParameter<IntRange>(ValidationPartitionParameterName, ValidationPartitionParameterDescription));
|
---|
205 | Parameters.Add(new FixedValueParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, RelativeNumberOfEvaluatedSamplesParameterDescription, new PercentValue(1)));
|
---|
206 | Parameters.Add(new FixedValueParameter<BoolValue>(ApplyLinearScalingParameterName, ApplyLinearScalingParameterDescription, new BoolValue(false)));
|
---|
207 | IntMatrix m = new IntMatrix(new int[,] { { 0, 100 } });
|
---|
208 | Parameters.Add(new ValueParameter<IntMatrix>(BoundsParameterName, BoundsParameterDescription, m));
|
---|
209 | Parameters.Add(new ValueParameter<IGenotypeToPhenotypeMapper>(GenotypeToPhenotypeMapperParameterName, GenotypeToPhenotypeMapperParameterDescription, new DepthFirstMapper()));
|
---|
210 |
|
---|
211 | SymbolicExpressionTreeInterpreterParameter.Hidden = true;
|
---|
212 | MaximumFunctionArgumentsParameter.Hidden = true;
|
---|
213 | MaximumFunctionDefinitionsParameter.Hidden = true;
|
---|
214 | ApplyLinearScalingParameter.Hidden = true;
|
---|
215 |
|
---|
216 | SymbolicExpressionTreeGrammar = new TypeCoherentExpressionGrammar();
|
---|
217 | SymbolicExpressionTreeInterpreter = new SymbolicDataAnalysisExpressionTreeLinearInterpreter();
|
---|
218 |
|
---|
219 | FitnessCalculationPartition.Start = ProblemData.TrainingPartition.Start;
|
---|
220 | FitnessCalculationPartition.End = ProblemData.TrainingPartition.End;
|
---|
221 |
|
---|
222 | InitializeOperators();
|
---|
223 |
|
---|
224 | UpdateGrammar();
|
---|
225 | RegisterEventHandlers();
|
---|
226 | }
|
---|
227 |
|
---|
228 | protected virtual void UpdateGrammar() {
|
---|
229 | SymbolicExpressionTreeGrammar.MaximumFunctionArguments = MaximumFunctionArguments.Value;
|
---|
230 | SymbolicExpressionTreeGrammar.MaximumFunctionDefinitions = MaximumFunctionDefinitions.Value;
|
---|
231 | foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>()) {
|
---|
232 | if (!varSymbol.Fixed) {
|
---|
233 | varSymbol.AllVariableNames = ProblemData.InputVariables.Select(x => x.Value);
|
---|
234 | varSymbol.VariableNames = ProblemData.AllowedInputVariables;
|
---|
235 | }
|
---|
236 | }
|
---|
237 | foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>()) {
|
---|
238 | if (!varSymbol.Fixed) {
|
---|
239 | varSymbol.AllVariableNames = ProblemData.InputVariables.Select(x => x.Value);
|
---|
240 | varSymbol.VariableNames = ProblemData.AllowedInputVariables;
|
---|
241 | }
|
---|
242 | }
|
---|
243 | }
|
---|
244 |
|
---|
245 | private void InitializeOperators() {
|
---|
246 | Operators.AddRange(ApplicationManager.Manager.GetInstances<IIntegerVectorOperator>().OfType<IOperator>());
|
---|
247 | // Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicDataAnalysisExpressionCrossover<T>>());
|
---|
248 | Operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());
|
---|
249 | Operators.Add(new SymbolicDataAnalysisVariableFrequencyAnalyzer());
|
---|
250 | Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
|
---|
251 | Operators.Add(new SymbolicExpressionTreeLengthAnalyzer());
|
---|
252 | ParameterizeOperators();
|
---|
253 | }
|
---|
254 |
|
---|
255 | #region events
|
---|
256 | private void RegisterEventHandlers() {
|
---|
257 | ProblemDataParameter.ValueChanged += new EventHandler(ProblemDataParameter_ValueChanged);
|
---|
258 | ProblemDataParameter.Value.Changed += (object sender, EventArgs e) => OnProblemDataChanged();
|
---|
259 |
|
---|
260 | SymbolicExpressionTreeGrammarParameter.ValueChanged += new EventHandler(SymbolicExpressionTreeGrammarParameter_ValueChanged);
|
---|
261 |
|
---|
262 | MaximumFunctionArguments.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
|
---|
263 | MaximumFunctionDefinitions.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
|
---|
264 | MaximumSymbolicExpressionTreeDepth.ValueChanged += new EventHandler(MaximumSymbolicExpressionTreeDepth_ValueChanged);
|
---|
265 | }
|
---|
266 |
|
---|
267 | private void ProblemDataParameter_ValueChanged(object sender, EventArgs e) {
|
---|
268 | ValidationPartition.Start = 0;
|
---|
269 | ValidationPartition.End = 0;
|
---|
270 | ProblemDataParameter.Value.Changed += (object s, EventArgs args) => OnProblemDataChanged();
|
---|
271 | OnProblemDataChanged();
|
---|
272 | }
|
---|
273 |
|
---|
274 | private void SymbolicExpressionTreeGrammarParameter_ValueChanged(object sender, EventArgs e) {
|
---|
275 | UpdateGrammar();
|
---|
276 | }
|
---|
277 |
|
---|
278 | private void ArchitectureParameterValue_ValueChanged(object sender, EventArgs e) {
|
---|
279 | UpdateGrammar();
|
---|
280 | }
|
---|
281 |
|
---|
282 | private void MaximumSymbolicExpressionTreeDepth_ValueChanged(object sender, EventArgs e) {
|
---|
283 | if (MaximumSymbolicExpressionTreeDepth != null && MaximumSymbolicExpressionTreeDepth.Value < 3)
|
---|
284 | MaximumSymbolicExpressionTreeDepth.Value = 3;
|
---|
285 | }
|
---|
286 |
|
---|
287 | /*
|
---|
288 | protected override void OnSolutionCreatorChanged() {
|
---|
289 | base.OnSolutionCreatorChanged();
|
---|
290 | ParameterizeOperators();
|
---|
291 | }
|
---|
292 | */
|
---|
293 |
|
---|
294 | protected override void OnEvaluatorChanged() {
|
---|
295 | base.OnEvaluatorChanged();
|
---|
296 | Evaluator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(Evaluator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
297 | ParameterizeOperators();
|
---|
298 | }
|
---|
299 |
|
---|
300 | private void Evaluator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
301 | ParameterizeOperators();
|
---|
302 | }
|
---|
303 |
|
---|
304 | public event EventHandler ProblemDataChanged;
|
---|
305 | protected virtual void OnProblemDataChanged() {
|
---|
306 | FitnessCalculationPartition.Start = ProblemData.TrainingPartition.Start;
|
---|
307 | FitnessCalculationPartition.End = ProblemData.TrainingPartition.End;
|
---|
308 |
|
---|
309 | UpdateGrammar();
|
---|
310 | ParameterizeOperators();
|
---|
311 |
|
---|
312 | var handler = ProblemDataChanged;
|
---|
313 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
314 |
|
---|
315 | OnReset();
|
---|
316 | }
|
---|
317 | #endregion
|
---|
318 |
|
---|
319 | protected virtual void ParameterizeOperators() {
|
---|
320 | var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators).ToList();
|
---|
321 |
|
---|
322 | foreach (var op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) {
|
---|
323 | op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter.Name;
|
---|
324 | }
|
---|
325 | /*
|
---|
326 | foreach (var op in operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) {
|
---|
327 | op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter.Name;
|
---|
328 | op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter.Name;
|
---|
329 | }
|
---|
330 | foreach (var op in operators.OfType<ISymbolicExpressionTreeArchitectureAlteringOperator>()) {
|
---|
331 | op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameter.Name;
|
---|
332 | op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter.Name;
|
---|
333 | }
|
---|
334 | */
|
---|
335 | foreach (var op in operators.OfType<IGESymbolicDataAnalysisEvaluator<T>>()) {
|
---|
336 | op.ProblemDataParameter.ActualName = ProblemDataParameterName;
|
---|
337 | op.SymbolicExpressionTreeParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
|
---|
338 | op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name;
|
---|
339 | op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name;
|
---|
340 | op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name;
|
---|
341 | op.IntegerVectorParameter.ActualName = SolutionCreator.IntegerVectorParameter.Name;
|
---|
342 | op.GenotypeToPhenotypeMapperParameter.ActualName = GenotypeToPhenotypeMapperParameter.Name;
|
---|
343 | op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter.Name;
|
---|
344 | }
|
---|
345 | foreach (var op in operators.OfType<IIntegerVectorCrossover>()) {
|
---|
346 | op.ParentsParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
|
---|
347 | op.ChildParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
|
---|
348 | }
|
---|
349 | foreach (var op in operators.OfType<IIntegerVectorManipulator>()) {
|
---|
350 | op.IntegerVectorParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
|
---|
351 | }
|
---|
352 | foreach (var op in operators.OfType<IIntegerVectorCreator>()) {
|
---|
353 | op.BoundsParameter.ActualName = BoundsParameter.Name;
|
---|
354 | op.LengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter.Name;
|
---|
355 | }
|
---|
356 | foreach (var op in operators.OfType<ISymbolicExpressionTreeAnalyzer>()) {
|
---|
357 | op.SymbolicExpressionTreeParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
|
---|
358 | }
|
---|
359 | foreach (var op in operators.OfType<ISymbolicDataAnalysisSingleObjectiveAnalyzer>()) {
|
---|
360 | op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name;
|
---|
361 | }
|
---|
362 | foreach (var op in operators.OfType<ISymbolicDataAnalysisMultiObjectiveAnalyzer>()) {
|
---|
363 | op.ApplyLinearScalingParameter.ActualName = ApplyLinearScalingParameter.Name;
|
---|
364 | }
|
---|
365 | foreach (var op in operators.OfType<ISymbolicDataAnalysisAnalyzer>()) {
|
---|
366 | op.SymbolicExpressionTreeParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
|
---|
367 | }
|
---|
368 | foreach (var op in operators.OfType<IGESymbolicDataAnalysisValidationAnalyzer<U, T>>()) {
|
---|
369 | op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name;
|
---|
370 | op.ValidationPartitionParameter.ActualName = ValidationPartitionParameter.Name;
|
---|
371 | }
|
---|
372 | foreach (var op in operators.OfType<ISymbolicDataAnalysisInterpreterOperator>()) {
|
---|
373 | op.SymbolicDataAnalysisTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
|
---|
374 | }
|
---|
375 | /*
|
---|
376 | foreach (var op in operators.OfType<ISymbolicDataAnalysisExpressionCrossover<T>>()) {
|
---|
377 | op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name;
|
---|
378 | op.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
|
---|
379 | op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name;
|
---|
380 | op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name;
|
---|
381 | op.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
|
---|
382 | }
|
---|
383 | */
|
---|
384 | }
|
---|
385 |
|
---|
386 | #region Import & Export
|
---|
387 | public virtual void Load(T data) {
|
---|
388 | Name = data.Name;
|
---|
389 | Description = data.Description;
|
---|
390 | ProblemData = data;
|
---|
391 | }
|
---|
392 |
|
---|
393 | public virtual T Export() {
|
---|
394 | return ProblemData;
|
---|
395 | }
|
---|
396 | #endregion
|
---|
397 | }
|
---|
398 | }
|
---|