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