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.Problems.DataAnalysis.Regression;
|
---|
35 | using HeuristicLab.Problems.DataAnalysis.Symbolic;
|
---|
36 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ArchitectureManipulators;
|
---|
37 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Manipulators;
|
---|
38 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Crossovers;
|
---|
39 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
|
---|
40 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
|
---|
41 | using HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers;
|
---|
42 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Analyzers;
|
---|
43 |
|
---|
44 | namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
|
---|
45 | [Item("Symbolic Regression Problem", "Represents a symbolic regression problem.")]
|
---|
46 | [Creatable("Problems")]
|
---|
47 | [StorableClass]
|
---|
48 | public class SymbolicRegressionProblem : DataAnalysisProblem, ISingleObjectiveProblem {
|
---|
49 |
|
---|
50 | #region Parameter Properties
|
---|
51 | public ValueParameter<BoolValue> MaximizationParameter {
|
---|
52 | get { return (ValueParameter<BoolValue>)Parameters["Maximization"]; }
|
---|
53 | }
|
---|
54 | IParameter ISingleObjectiveProblem.MaximizationParameter {
|
---|
55 | get { return MaximizationParameter; }
|
---|
56 | }
|
---|
57 | public ValueParameter<SymbolicExpressionTreeCreator> SolutionCreatorParameter {
|
---|
58 | get { return (ValueParameter<SymbolicExpressionTreeCreator>)Parameters["SolutionCreator"]; }
|
---|
59 | }
|
---|
60 | IParameter IProblem.SolutionCreatorParameter {
|
---|
61 | get { return SolutionCreatorParameter; }
|
---|
62 | }
|
---|
63 | public ValueParameter<DoubleValue> LowerEstimationLimitParameter {
|
---|
64 | get { return (ValueParameter<DoubleValue>)Parameters["LowerEstimationLimit"]; }
|
---|
65 | }
|
---|
66 | public ValueParameter<DoubleValue> UpperEstimationLimitParameter {
|
---|
67 | get { return (ValueParameter<DoubleValue>)Parameters["UpperEstimationLimit"]; }
|
---|
68 | }
|
---|
69 | public ValueParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
|
---|
70 | get { return (ValueParameter<ISymbolicExpressionTreeInterpreter>)Parameters["SymbolicExpressionTreeInterpreter"]; }
|
---|
71 | }
|
---|
72 | public ValueParameter<ISymbolicRegressionEvaluator> EvaluatorParameter {
|
---|
73 | get { return (ValueParameter<ISymbolicRegressionEvaluator>)Parameters["Evaluator"]; }
|
---|
74 | }
|
---|
75 | IParameter IProblem.EvaluatorParameter {
|
---|
76 | get { return EvaluatorParameter; }
|
---|
77 | }
|
---|
78 | public ValueParameter<ISymbolicExpressionGrammar> FunctionTreeGrammarParameter {
|
---|
79 | get { return (ValueParameter<ISymbolicExpressionGrammar>)Parameters["FunctionTreeGrammar"]; }
|
---|
80 | }
|
---|
81 | public ValueParameter<IntValue> MaxExpressionLengthParameter {
|
---|
82 | get { return (ValueParameter<IntValue>)Parameters["MaxExpressionLength"]; }
|
---|
83 | }
|
---|
84 | public ValueParameter<IntValue> MaxExpressionDepthParameter {
|
---|
85 | get { return (ValueParameter<IntValue>)Parameters["MaxExpressionDepth"]; }
|
---|
86 | }
|
---|
87 | public ValueParameter<IntValue> MaxFunctionDefiningBranchesParameter {
|
---|
88 | get { return (ValueParameter<IntValue>)Parameters["MaxFunctionDefiningBranches"]; }
|
---|
89 | }
|
---|
90 | public ValueParameter<IntValue> MaxFunctionArgumentsParameter {
|
---|
91 | get { return (ValueParameter<IntValue>)Parameters["MaxFunctionArguments"]; }
|
---|
92 | }
|
---|
93 | public OptionalValueParameter<DoubleValue> BestKnownQualityParameter {
|
---|
94 | get { return (OptionalValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
|
---|
95 | }
|
---|
96 | IParameter ISingleObjectiveProblem.BestKnownQualityParameter {
|
---|
97 | get { return BestKnownQualityParameter; }
|
---|
98 | }
|
---|
99 | #endregion
|
---|
100 |
|
---|
101 | #region Properties
|
---|
102 | public IntValue MaxExpressionLength {
|
---|
103 | get { return MaxExpressionLengthParameter.Value; }
|
---|
104 | set { MaxExpressionLengthParameter.Value = value; }
|
---|
105 | }
|
---|
106 | public IntValue MaxExpressionDepth {
|
---|
107 | get { return MaxExpressionDepthParameter.Value; }
|
---|
108 | set { MaxExpressionDepthParameter.Value = value; }
|
---|
109 | }
|
---|
110 | public IntValue MaxFunctionDefiningBranches {
|
---|
111 | get { return MaxFunctionDefiningBranchesParameter.Value; }
|
---|
112 | set { MaxFunctionDefiningBranchesParameter.Value = value; }
|
---|
113 | }
|
---|
114 | public IntValue MaxFunctionArguments {
|
---|
115 | get { return MaxFunctionArgumentsParameter.Value; }
|
---|
116 | set { MaxFunctionArgumentsParameter.Value = value; }
|
---|
117 | }
|
---|
118 | public SymbolicExpressionTreeCreator SolutionCreator {
|
---|
119 | get { return SolutionCreatorParameter.Value; }
|
---|
120 | set { SolutionCreatorParameter.Value = value; }
|
---|
121 | }
|
---|
122 | ISolutionCreator IProblem.SolutionCreator {
|
---|
123 | get { return SolutionCreatorParameter.Value; }
|
---|
124 | }
|
---|
125 | public ISymbolicExpressionTreeInterpreter SymbolicExpressionTreeInterpreter {
|
---|
126 | get { return SymbolicExpressionTreeInterpreterParameter.Value; }
|
---|
127 | set { SymbolicExpressionTreeInterpreterParameter.Value = value; }
|
---|
128 | }
|
---|
129 | public DoubleValue LowerEstimationLimit {
|
---|
130 | get { return LowerEstimationLimitParameter.Value; }
|
---|
131 | set { LowerEstimationLimitParameter.Value = value; }
|
---|
132 | }
|
---|
133 | public DoubleValue UpperEstimationLimit {
|
---|
134 | get { return UpperEstimationLimitParameter.Value; }
|
---|
135 | set { UpperEstimationLimitParameter.Value = value; }
|
---|
136 | }
|
---|
137 |
|
---|
138 | public ISymbolicRegressionEvaluator Evaluator {
|
---|
139 | get { return EvaluatorParameter.Value; }
|
---|
140 | set { EvaluatorParameter.Value = value; }
|
---|
141 | }
|
---|
142 | ISingleObjectiveEvaluator ISingleObjectiveProblem.Evaluator {
|
---|
143 | get { return EvaluatorParameter.Value; }
|
---|
144 | }
|
---|
145 | IEvaluator IProblem.Evaluator {
|
---|
146 | get { return EvaluatorParameter.Value; }
|
---|
147 | }
|
---|
148 | public ISymbolicExpressionGrammar FunctionTreeGrammar {
|
---|
149 | get { return (ISymbolicExpressionGrammar)FunctionTreeGrammarParameter.Value; }
|
---|
150 | }
|
---|
151 | public DoubleValue BestKnownQuality {
|
---|
152 | get { return BestKnownQualityParameter.Value; }
|
---|
153 | }
|
---|
154 | private List<IOperator> operators;
|
---|
155 | public IEnumerable<IOperator> Operators {
|
---|
156 | get { return operators; }
|
---|
157 | }
|
---|
158 | public IEnumerable<ISymbolicRegressionAnalyzer> Analyzers {
|
---|
159 | get { return operators.OfType<ISymbolicRegressionAnalyzer>(); }
|
---|
160 | }
|
---|
161 | public DoubleValue PunishmentFactor {
|
---|
162 | get { return new DoubleValue(10.0); }
|
---|
163 | }
|
---|
164 | public IntValue TrainingSamplesStart {
|
---|
165 | get { return new IntValue(DataAnalysisProblemData.TrainingSamplesStart.Value); }
|
---|
166 | }
|
---|
167 | public IntValue TrainingSamplesEnd {
|
---|
168 | get {
|
---|
169 | return new IntValue((DataAnalysisProblemData.TrainingSamplesStart.Value +
|
---|
170 | DataAnalysisProblemData.TrainingSamplesEnd.Value) / 2);
|
---|
171 | }
|
---|
172 | }
|
---|
173 | public IntValue ValidationSamplesStart {
|
---|
174 | get { return TrainingSamplesEnd; }
|
---|
175 | }
|
---|
176 | public IntValue ValidationSamplesEnd {
|
---|
177 | get { return new IntValue(DataAnalysisProblemData.TrainingSamplesEnd.Value); }
|
---|
178 | }
|
---|
179 | public IntValue TestSamplesStart {
|
---|
180 | get { return DataAnalysisProblemData.TestSamplesStart; }
|
---|
181 | }
|
---|
182 | public IntValue TestSamplesEnd {
|
---|
183 | get { return DataAnalysisProblemData.TestSamplesEnd; }
|
---|
184 | }
|
---|
185 | #endregion
|
---|
186 |
|
---|
187 | public SymbolicRegressionProblem()
|
---|
188 | : base() {
|
---|
189 | SymbolicExpressionTreeCreator creator = new ProbabilisticTreeCreator();
|
---|
190 | var evaluator = new SymbolicRegressionScaledMeanSquaredErrorEvaluator();
|
---|
191 | var grammar = new ArithmeticExpressionGrammar();
|
---|
192 | var globalGrammar = new GlobalSymbolicExpressionGrammar(grammar);
|
---|
193 | var interpreter = new SimpleArithmeticExpressionInterpreter();
|
---|
194 | Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the error of the regression model should be minimized.", (BoolValue)new BoolValue(false).AsReadOnly()));
|
---|
195 | Parameters.Add(new ValueParameter<SymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new symbolic regression solutions.", creator));
|
---|
196 | Parameters.Add(new ValueParameter<ISymbolicExpressionTreeInterpreter>("SymbolicExpressionTreeInterpreter", "The interpreter that should be used to evaluate the symbolic expression tree.", interpreter));
|
---|
197 | Parameters.Add(new ValueParameter<ISymbolicRegressionEvaluator>("Evaluator", "The operator which should be used to evaluate symbolic regression solutions.", evaluator));
|
---|
198 | Parameters.Add(new ValueParameter<DoubleValue>("LowerEstimationLimit", "The lower limit for the estimated value that can be returned by the symbolic regression model.", new DoubleValue(double.NegativeInfinity)));
|
---|
199 | Parameters.Add(new ValueParameter<DoubleValue>("UpperEstimationLimit", "The upper limit for the estimated value that can be returned by the symbolic regression model.", new DoubleValue(double.PositiveInfinity)));
|
---|
200 | Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The minimal error value that reached by symbolic regression solutions for the problem."));
|
---|
201 | Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("FunctionTreeGrammar", "The grammar that should be used for symbolic regression models.", globalGrammar));
|
---|
202 | Parameters.Add(new ValueParameter<IntValue>("MaxExpressionLength", "Maximal length of the symbolic expression.", new IntValue(100)));
|
---|
203 | Parameters.Add(new ValueParameter<IntValue>("MaxExpressionDepth", "Maximal depth of the symbolic expression.", new IntValue(10)));
|
---|
204 | Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefiningBranches", "Maximal number of automatically defined functions.", (IntValue)new IntValue(0).AsReadOnly()));
|
---|
205 | Parameters.Add(new ValueParameter<IntValue>("MaxFunctionArguments", "Maximal number of arguments of automatically defined functions.", (IntValue)new IntValue(0).AsReadOnly()));
|
---|
206 |
|
---|
207 | creator.SymbolicExpressionTreeParameter.ActualName = "SymbolicRegressionModel";
|
---|
208 | evaluator.QualityParameter.ActualName = "TrainingMeanSquaredError";
|
---|
209 |
|
---|
210 | ParameterizeSolutionCreator();
|
---|
211 | ParameterizeEvaluator();
|
---|
212 |
|
---|
213 | UpdateGrammar();
|
---|
214 | UpdateEstimationLimits();
|
---|
215 | Initialize();
|
---|
216 | }
|
---|
217 |
|
---|
218 | [StorableConstructor]
|
---|
219 | private SymbolicRegressionProblem(bool deserializing) : base() { }
|
---|
220 |
|
---|
221 | [StorableHook(HookType.AfterDeserialization)]
|
---|
222 | private void AfterDeserializationHook() {
|
---|
223 | Initialize();
|
---|
224 | }
|
---|
225 |
|
---|
226 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
227 | SymbolicRegressionProblem clone = (SymbolicRegressionProblem)base.Clone(cloner);
|
---|
228 | clone.Initialize();
|
---|
229 | return clone;
|
---|
230 | }
|
---|
231 |
|
---|
232 | private void RegisterParameterValueEvents() {
|
---|
233 | MaxFunctionArgumentsParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
|
---|
234 | MaxFunctionDefiningBranchesParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
|
---|
235 | SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
|
---|
236 | EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
|
---|
237 | }
|
---|
238 |
|
---|
239 | private void RegisterParameterEvents() {
|
---|
240 | MaxFunctionArgumentsParameter.Value.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
|
---|
241 | MaxFunctionDefiningBranchesParameter.Value.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
|
---|
242 | SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
243 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
244 | }
|
---|
245 |
|
---|
246 | #region event handling
|
---|
247 | protected override void OnDataAnalysisProblemChanged(EventArgs e) {
|
---|
248 | base.OnDataAnalysisProblemChanged(e);
|
---|
249 | // paritions could be changed
|
---|
250 | ParameterizeEvaluator();
|
---|
251 | ParameterizeAnalyzers();
|
---|
252 | // input variables could have been changed
|
---|
253 | UpdateGrammar();
|
---|
254 | // estimation limits have to be recalculated
|
---|
255 | UpdateEstimationLimits();
|
---|
256 | }
|
---|
257 | protected virtual void OnArchitectureParameterChanged(EventArgs e) {
|
---|
258 | UpdateGrammar();
|
---|
259 | }
|
---|
260 | protected virtual void OnGrammarChanged(EventArgs e) { }
|
---|
261 | protected virtual void OnOperatorsChanged(EventArgs e) { RaiseOperatorsChanged(e); }
|
---|
262 | protected virtual void OnSolutionCreatorChanged(EventArgs e) {
|
---|
263 | SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
264 | ParameterizeSolutionCreator();
|
---|
265 | OnSolutionParameterNameChanged(e);
|
---|
266 | RaiseSolutionCreatorChanged(e);
|
---|
267 | }
|
---|
268 |
|
---|
269 | protected virtual void OnSolutionParameterNameChanged(EventArgs e) {
|
---|
270 | ParameterizeEvaluator();
|
---|
271 | ParameterizeAnalyzers();
|
---|
272 | ParameterizeOperators();
|
---|
273 | }
|
---|
274 |
|
---|
275 | protected virtual void OnEvaluatorChanged(EventArgs e) {
|
---|
276 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
277 | ParameterizeEvaluator();
|
---|
278 | ParameterizeAnalyzers();
|
---|
279 | RaiseEvaluatorChanged(e);
|
---|
280 | }
|
---|
281 | protected virtual void OnQualityParameterNameChanged(EventArgs e) {
|
---|
282 | ParameterizeAnalyzers();
|
---|
283 | }
|
---|
284 | #endregion
|
---|
285 |
|
---|
286 | #region event handlers
|
---|
287 | private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
288 | OnSolutionCreatorChanged(e);
|
---|
289 | }
|
---|
290 | private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
291 | OnSolutionParameterNameChanged(e);
|
---|
292 | }
|
---|
293 | private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
294 | OnEvaluatorChanged(e);
|
---|
295 | }
|
---|
296 | private void ArchitectureParameter_ValueChanged(object sender, EventArgs e) {
|
---|
297 | OnArchitectureParameterChanged(e);
|
---|
298 | }
|
---|
299 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
300 | OnQualityParameterNameChanged(e);
|
---|
301 | }
|
---|
302 | #endregion
|
---|
303 |
|
---|
304 | #region events
|
---|
305 | public event EventHandler SolutionCreatorChanged;
|
---|
306 | private void RaiseSolutionCreatorChanged(EventArgs e) {
|
---|
307 | var changed = SolutionCreatorChanged;
|
---|
308 | if (changed != null)
|
---|
309 | changed(this, e);
|
---|
310 | }
|
---|
311 | public event EventHandler EvaluatorChanged;
|
---|
312 | private void RaiseEvaluatorChanged(EventArgs e) {
|
---|
313 | var changed = EvaluatorChanged;
|
---|
314 | if (changed != null)
|
---|
315 | changed(this, e);
|
---|
316 | }
|
---|
317 |
|
---|
318 | public event EventHandler OperatorsChanged;
|
---|
319 | private void RaiseOperatorsChanged(EventArgs e) {
|
---|
320 | var changed = OperatorsChanged;
|
---|
321 | if (changed != null)
|
---|
322 | changed(this, e);
|
---|
323 | }
|
---|
324 | public event EventHandler Reset;
|
---|
325 | private void RaiseReset(EventArgs e) {
|
---|
326 | var changed = Reset;
|
---|
327 | if (changed != null)
|
---|
328 | changed(this, e);
|
---|
329 | }
|
---|
330 | #endregion
|
---|
331 |
|
---|
332 | #region Helpers
|
---|
333 | private void Initialize() {
|
---|
334 | InitializeOperators();
|
---|
335 | RegisterParameterEvents();
|
---|
336 | RegisterParameterValueEvents();
|
---|
337 | }
|
---|
338 |
|
---|
339 | private void UpdateGrammar() {
|
---|
340 | foreach (var varSymbol in FunctionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable>()) {
|
---|
341 | varSymbol.VariableNames = DataAnalysisProblemData.InputVariables.CheckedItems.Select(x => x.Value.Value);
|
---|
342 | }
|
---|
343 | var globalGrammar = FunctionTreeGrammar as GlobalSymbolicExpressionGrammar;
|
---|
344 | if (globalGrammar != null) {
|
---|
345 | globalGrammar.MaxFunctionArguments = MaxFunctionArguments.Value;
|
---|
346 | globalGrammar.MaxFunctionDefinitions = MaxFunctionDefiningBranches.Value;
|
---|
347 | }
|
---|
348 | }
|
---|
349 |
|
---|
350 | private void UpdateEstimationLimits() {
|
---|
351 | if (TrainingSamplesStart.Value < TrainingSamplesEnd.Value &&
|
---|
352 | DataAnalysisProblemData.Dataset.VariableNames.Contains(DataAnalysisProblemData.TargetVariable.Value)) {
|
---|
353 | var targetValues = DataAnalysisProblemData.Dataset.GetVariableValues(DataAnalysisProblemData.TargetVariable.Value, TrainingSamplesStart.Value, TrainingSamplesEnd.Value);
|
---|
354 | var mean = targetValues.Average();
|
---|
355 | var range = targetValues.Max() - targetValues.Min();
|
---|
356 | UpperEstimationLimit = new DoubleValue(mean + PunishmentFactor.Value * range);
|
---|
357 | LowerEstimationLimit = new DoubleValue(mean - PunishmentFactor.Value * range);
|
---|
358 | }
|
---|
359 | }
|
---|
360 |
|
---|
361 | private void InitializeOperators() {
|
---|
362 | operators = new List<IOperator>();
|
---|
363 | operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>().OfType<IOperator>());
|
---|
364 | operators.Add(new ValidationBestScaledSymbolicRegressionSolutionAnalyzer());
|
---|
365 | operators.Add(new MinAvgMaxSymbolicExpressionTreeSizeAnalyzer());
|
---|
366 | operators.Add(new SymbolicRegressionVariableFrequencyAnalyzer());
|
---|
367 | operators.Add(new SymbolicRegressionModelQualityAnalyzer());
|
---|
368 | ParameterizeOperators();
|
---|
369 | ParameterizeAnalyzers();
|
---|
370 | }
|
---|
371 |
|
---|
372 | private void ParameterizeSolutionCreator() {
|
---|
373 | SolutionCreator.SymbolicExpressionGrammarParameter.ActualName = FunctionTreeGrammarParameter.Name;
|
---|
374 | SolutionCreator.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
|
---|
375 | SolutionCreator.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
|
---|
376 | SolutionCreator.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
|
---|
377 | SolutionCreator.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefiningBranchesParameter.Name;
|
---|
378 | }
|
---|
379 |
|
---|
380 | private void ParameterizeEvaluator() {
|
---|
381 | Evaluator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
382 | Evaluator.RegressionProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
|
---|
383 | Evaluator.SamplesStartParameter.Value = TrainingSamplesStart;
|
---|
384 | Evaluator.SamplesEndParameter.Value = TrainingSamplesEnd;
|
---|
385 | }
|
---|
386 |
|
---|
387 | private void ParameterizeAnalyzers() {
|
---|
388 | foreach (var analyzer in Analyzers) {
|
---|
389 | analyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
390 | var bestValidationSolutionAnalyzer = analyzer as ValidationBestScaledSymbolicRegressionSolutionAnalyzer;
|
---|
391 | if (bestValidationSolutionAnalyzer != null) {
|
---|
392 | bestValidationSolutionAnalyzer.ProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
|
---|
393 | bestValidationSolutionAnalyzer.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
|
---|
394 | bestValidationSolutionAnalyzer.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name;
|
---|
395 | bestValidationSolutionAnalyzer.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
|
---|
396 | bestValidationSolutionAnalyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
397 | bestValidationSolutionAnalyzer.SamplesStartParameter.Value = ValidationSamplesStart;
|
---|
398 | bestValidationSolutionAnalyzer.SamplesEndParameter.Value = ValidationSamplesEnd;
|
---|
399 | }
|
---|
400 | var varFreqAnalyzer = analyzer as SymbolicRegressionVariableFrequencyAnalyzer;
|
---|
401 | if (varFreqAnalyzer != null) {
|
---|
402 | varFreqAnalyzer.ProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
|
---|
403 | }
|
---|
404 | var modelQualityAnalyzer = analyzer as SymbolicRegressionModelQualityAnalyzer;
|
---|
405 | if (modelQualityAnalyzer != null) {
|
---|
406 | modelQualityAnalyzer.ProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
|
---|
407 | modelQualityAnalyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
408 | modelQualityAnalyzer.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
|
---|
409 | modelQualityAnalyzer.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name;
|
---|
410 | modelQualityAnalyzer.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
|
---|
411 | modelQualityAnalyzer.TrainingSamplesStartParameter.Value = TrainingSamplesStart;
|
---|
412 | modelQualityAnalyzer.TrainingSamplesEndParameter.Value = ValidationSamplesEnd;
|
---|
413 | modelQualityAnalyzer.TestSamplesStartParameter.Value = TestSamplesStart;
|
---|
414 | modelQualityAnalyzer.TestSamplesEndParameter.Value = TestSamplesEnd;
|
---|
415 | }
|
---|
416 | }
|
---|
417 | foreach (ISymbolicExpressionTreeAnalyzer analyzer in Operators.OfType<ISymbolicExpressionTreeAnalyzer>()) {
|
---|
418 | analyzer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
419 | }
|
---|
420 | }
|
---|
421 |
|
---|
422 | private void ParameterizeOperators() {
|
---|
423 | foreach (ISymbolicExpressionTreeOperator op in Operators.OfType<ISymbolicExpressionTreeOperator>()) {
|
---|
424 | op.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
|
---|
425 | op.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
|
---|
426 | op.SymbolicExpressionGrammarParameter.ActualName = FunctionTreeGrammarParameter.Name;
|
---|
427 | }
|
---|
428 | foreach (ISymbolicExpressionTreeCrossover op in Operators.OfType<ISymbolicExpressionTreeCrossover>()) {
|
---|
429 | op.ParentsParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
430 | op.ChildParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
431 | }
|
---|
432 | foreach (ISymbolicExpressionTreeManipulator op in Operators.OfType<ISymbolicExpressionTreeManipulator>()) {
|
---|
433 | op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
434 | }
|
---|
435 | foreach (ISymbolicExpressionTreeArchitectureManipulator op in Operators.OfType<ISymbolicExpressionTreeArchitectureManipulator>()) {
|
---|
436 | op.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
|
---|
437 | op.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefiningBranchesParameter.Name;
|
---|
438 | }
|
---|
439 | }
|
---|
440 | #endregion
|
---|
441 | }
|
---|
442 | }
|
---|