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 |
|
---|
42 | namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
|
---|
43 | [Item("Symbolic Regression Problem", "Represents a symbolic regression problem.")]
|
---|
44 | [Creatable("Problems")]
|
---|
45 | [StorableClass]
|
---|
46 | public sealed class SymbolicRegressionProblem : DataAnalysisProblem, ISingleObjectiveProblem {
|
---|
47 |
|
---|
48 | #region Parameter Properties
|
---|
49 | public ValueParameter<BoolValue> MaximizationParameter {
|
---|
50 | get { return (ValueParameter<BoolValue>)Parameters["Maximization"]; }
|
---|
51 | }
|
---|
52 | IParameter ISingleObjectiveProblem.MaximizationParameter {
|
---|
53 | get { return MaximizationParameter; }
|
---|
54 | }
|
---|
55 | public ValueParameter<SymbolicExpressionTreeCreator> SolutionCreatorParameter {
|
---|
56 | get { return (ValueParameter<SymbolicExpressionTreeCreator>)Parameters["SolutionCreator"]; }
|
---|
57 | }
|
---|
58 | IParameter IProblem.SolutionCreatorParameter {
|
---|
59 | get { return SolutionCreatorParameter; }
|
---|
60 | }
|
---|
61 | public ValueParameter<DoubleValue> LowerEstimationLimitParameter {
|
---|
62 | get { return (ValueParameter<DoubleValue>)Parameters["LowerEstimationLimit"]; }
|
---|
63 | }
|
---|
64 | public ValueParameter<DoubleValue> UpperEstimationLimitParameter {
|
---|
65 | get { return (ValueParameter<DoubleValue>)Parameters["UpperEstimationLimit"]; }
|
---|
66 | }
|
---|
67 | public ValueParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
|
---|
68 | get { return (ValueParameter<ISymbolicExpressionTreeInterpreter>)Parameters["SymbolicExpressionTreeInterpreter"]; }
|
---|
69 | }
|
---|
70 | public ValueParameter<ISymbolicRegressionEvaluator> EvaluatorParameter {
|
---|
71 | get { return (ValueParameter<ISymbolicRegressionEvaluator>)Parameters["Evaluator"]; }
|
---|
72 | }
|
---|
73 | IParameter IProblem.EvaluatorParameter {
|
---|
74 | get { return EvaluatorParameter; }
|
---|
75 | }
|
---|
76 | public ValueParameter<ISymbolicExpressionGrammar> FunctionTreeGrammarParameter {
|
---|
77 | get { return (ValueParameter<ISymbolicExpressionGrammar>)Parameters["FunctionTreeGrammar"]; }
|
---|
78 | }
|
---|
79 | public ValueParameter<IntValue> MaxExpressionLengthParameter {
|
---|
80 | get { return (ValueParameter<IntValue>)Parameters["MaxExpressionLength"]; }
|
---|
81 | }
|
---|
82 | public ValueParameter<IntValue> MaxExpressionDepthParameter {
|
---|
83 | get { return (ValueParameter<IntValue>)Parameters["MaxExpressionDepth"]; }
|
---|
84 | }
|
---|
85 | public ValueParameter<IntValue> MaxFunctionDefiningBranchesParameter {
|
---|
86 | get { return (ValueParameter<IntValue>)Parameters["MaxFunctionDefiningBranches"]; }
|
---|
87 | }
|
---|
88 | public ValueParameter<IntValue> MaxFunctionArgumentsParameter {
|
---|
89 | get { return (ValueParameter<IntValue>)Parameters["MaxFunctionArguments"]; }
|
---|
90 | }
|
---|
91 | public OptionalValueParameter<ISingleObjectiveSolutionsVisualizer> VisualizerParameter {
|
---|
92 | get { return (OptionalValueParameter<ISingleObjectiveSolutionsVisualizer>)Parameters["Visualizer"]; }
|
---|
93 | }
|
---|
94 | IParameter IProblem.VisualizerParameter {
|
---|
95 | get { return VisualizerParameter; }
|
---|
96 | }
|
---|
97 | public OptionalValueParameter<DoubleValue> BestKnownQualityParameter {
|
---|
98 | get { return (OptionalValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
|
---|
99 | }
|
---|
100 | IParameter ISingleObjectiveProblem.BestKnownQualityParameter {
|
---|
101 | get { return BestKnownQualityParameter; }
|
---|
102 | }
|
---|
103 | #endregion
|
---|
104 |
|
---|
105 | #region Properties
|
---|
106 | public IntValue MaxExpressionLength {
|
---|
107 | get { return MaxExpressionLengthParameter.Value; }
|
---|
108 | set { MaxExpressionLengthParameter.Value = value; }
|
---|
109 | }
|
---|
110 | public IntValue MaxExpressionDepth {
|
---|
111 | get { return MaxExpressionDepthParameter.Value; }
|
---|
112 | set { MaxExpressionDepthParameter.Value = value; }
|
---|
113 | }
|
---|
114 | public IntValue MaxFunctionDefiningBranches {
|
---|
115 | get { return MaxFunctionDefiningBranchesParameter.Value; }
|
---|
116 | set { MaxFunctionDefiningBranchesParameter.Value = value; }
|
---|
117 | }
|
---|
118 | public IntValue MaxFunctionArguments {
|
---|
119 | get { return MaxFunctionArgumentsParameter.Value; }
|
---|
120 | set { MaxFunctionArgumentsParameter.Value = value; }
|
---|
121 | }
|
---|
122 | public SymbolicExpressionTreeCreator SolutionCreator {
|
---|
123 | get { return SolutionCreatorParameter.Value; }
|
---|
124 | set { SolutionCreatorParameter.Value = value; }
|
---|
125 | }
|
---|
126 | ISolutionCreator IProblem.SolutionCreator {
|
---|
127 | get { return SolutionCreatorParameter.Value; }
|
---|
128 | }
|
---|
129 | public ISymbolicExpressionTreeInterpreter SymbolicExpressionTreeInterpreter {
|
---|
130 | get { return SymbolicExpressionTreeInterpreterParameter.Value; }
|
---|
131 | set { SymbolicExpressionTreeInterpreterParameter.Value = value; }
|
---|
132 | }
|
---|
133 | public DoubleValue LowerEstimationLimit {
|
---|
134 | get { return LowerEstimationLimitParameter.Value; }
|
---|
135 | set { LowerEstimationLimitParameter.Value = value; }
|
---|
136 | }
|
---|
137 | public DoubleValue UpperEstimationLimit {
|
---|
138 | get { return UpperEstimationLimitParameter.Value; }
|
---|
139 | set { UpperEstimationLimitParameter.Value = value; }
|
---|
140 | }
|
---|
141 |
|
---|
142 | public ISymbolicRegressionEvaluator Evaluator {
|
---|
143 | get { return EvaluatorParameter.Value; }
|
---|
144 | set { EvaluatorParameter.Value = value; }
|
---|
145 | }
|
---|
146 | ISingleObjectiveEvaluator ISingleObjectiveProblem.Evaluator {
|
---|
147 | get { return EvaluatorParameter.Value; }
|
---|
148 | }
|
---|
149 | IEvaluator IProblem.Evaluator {
|
---|
150 | get { return EvaluatorParameter.Value; }
|
---|
151 | }
|
---|
152 | public ISymbolicExpressionGrammar FunctionTreeGrammar {
|
---|
153 | get { return (ISymbolicExpressionGrammar)FunctionTreeGrammarParameter.Value; }
|
---|
154 | }
|
---|
155 | public ISingleObjectiveSolutionsVisualizer Visualizer {
|
---|
156 | get { return VisualizerParameter.Value; }
|
---|
157 | set { VisualizerParameter.Value = value; }
|
---|
158 | }
|
---|
159 | ISolutionsVisualizer IProblem.Visualizer {
|
---|
160 | get { return VisualizerParameter.Value; }
|
---|
161 | }
|
---|
162 | public DoubleValue BestKnownQuality {
|
---|
163 | get { return BestKnownQualityParameter.Value; }
|
---|
164 | }
|
---|
165 | private List<ISymbolicExpressionTreeOperator> operators;
|
---|
166 | public IEnumerable<IOperator> Operators {
|
---|
167 | get { return operators.Cast<IOperator>(); }
|
---|
168 | }
|
---|
169 | public DoubleValue PunishmentFactor {
|
---|
170 | get { return new DoubleValue(10.0); }
|
---|
171 | }
|
---|
172 | #endregion
|
---|
173 |
|
---|
174 | public SymbolicRegressionProblem()
|
---|
175 | : base() {
|
---|
176 | SymbolicExpressionTreeCreator creator = new ProbabilisticTreeCreator();
|
---|
177 | var evaluator = new SymbolicRegressionScaledMeanSquaredErrorEvaluator();
|
---|
178 | var grammar = new ArithmeticExpressionGrammar();
|
---|
179 | var globalGrammar = new GlobalSymbolicExpressionGrammar(grammar);
|
---|
180 | var visualizer = new BestValidationSymbolicRegressionSolutionVisualizer();
|
---|
181 | var interpreter = new SimpleArithmeticExpressionInterpreter();
|
---|
182 | Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the error of the regression model should be minimized.", new BoolValue(false)));
|
---|
183 | Parameters.Add(new ValueParameter<SymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new symbolic regression solutions.", creator));
|
---|
184 | Parameters.Add(new ValueParameter<ISymbolicExpressionTreeInterpreter>("SymbolicExpressionTreeInterpreter", "The interpreter that should be used to evaluate the symbolic expression tree.", interpreter));
|
---|
185 | Parameters.Add(new ValueParameter<ISymbolicRegressionEvaluator>("Evaluator", "The operator which should be used to evaluate symbolic regression solutions.", evaluator));
|
---|
186 | 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)));
|
---|
187 | 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)));
|
---|
188 | Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The minimal error value that reached by symbolic regression solutions for the problem."));
|
---|
189 | Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("FunctionTreeGrammar", "The grammar that should be used for symbolic regression models.", globalGrammar));
|
---|
190 | Parameters.Add(new ValueParameter<IntValue>("MaxExpressionLength", "Maximal length of the symbolic expression.", new IntValue(100)));
|
---|
191 | Parameters.Add(new ValueParameter<IntValue>("MaxExpressionDepth", "Maximal depth of the symbolic expression.", new IntValue(10)));
|
---|
192 | Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefiningBranches", "Maximal number of automatically defined functions.", new IntValue(3)));
|
---|
193 | Parameters.Add(new ValueParameter<IntValue>("MaxFunctionArguments", "Maximal number of arguments of automatically defined functions.", new IntValue(3)));
|
---|
194 | Parameters.Add(new ValueParameter<ISingleObjectiveSolutionsVisualizer>("Visualizer", "The operator which should be used to visualize symbolic regression solutions.", visualizer));
|
---|
195 |
|
---|
196 | creator.SymbolicExpressionTreeParameter.ActualName = "SymbolicRegressionModel";
|
---|
197 | creator.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
|
---|
198 | creator.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefiningBranchesParameter.Name;
|
---|
199 | DataAnalysisProblemDataParameter.ValueChanged += new EventHandler(DataAnalysisProblemDataParameter_ValueChanged);
|
---|
200 | DataAnalysisProblemData.ProblemDataChanged += new EventHandler(DataAnalysisProblemData_Changed);
|
---|
201 | MaxFunctionArgumentsParameter.ValueChanged += new EventHandler(ArchitectureParameter_Changed);
|
---|
202 | MaxFunctionArgumentsParameter.Value.ValueChanged += new EventHandler(ArchitectureParameter_Changed);
|
---|
203 | MaxFunctionDefiningBranchesParameter.ValueChanged += new EventHandler(ArchitectureParameter_Changed);
|
---|
204 | MaxFunctionDefiningBranchesParameter.Value.ValueChanged += new EventHandler(ArchitectureParameter_Changed);
|
---|
205 | ParameterizeSolutionCreator();
|
---|
206 | ParameterizeEvaluator();
|
---|
207 | ParameterizeVisualizer();
|
---|
208 |
|
---|
209 | Initialize();
|
---|
210 | }
|
---|
211 |
|
---|
212 |
|
---|
213 | [StorableConstructor]
|
---|
214 | private SymbolicRegressionProblem(bool deserializing) : base() { }
|
---|
215 |
|
---|
216 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
217 | SymbolicRegressionProblem clone = (SymbolicRegressionProblem)base.Clone(cloner);
|
---|
218 | clone.Initialize();
|
---|
219 | return clone;
|
---|
220 | }
|
---|
221 |
|
---|
222 | #region Events
|
---|
223 | void DataAnalysisProblemDataParameter_ValueChanged(object sender, EventArgs e) {
|
---|
224 | DataAnalysisProblemData.ProblemDataChanged += new EventHandler(DataAnalysisProblemData_Changed);
|
---|
225 | }
|
---|
226 |
|
---|
227 | void DataAnalysisProblemData_Changed(object sender, EventArgs e) {
|
---|
228 | UpdateGrammar();
|
---|
229 | UpdatePartitioningParameters();
|
---|
230 | }
|
---|
231 |
|
---|
232 | void ArchitectureParameter_Changed(object sender, EventArgs e) {
|
---|
233 | var globalGrammar = FunctionTreeGrammar as GlobalSymbolicExpressionGrammar;
|
---|
234 | globalGrammar.MaxFunctionArguments = MaxFunctionArguments.Value;
|
---|
235 | globalGrammar.MaxFunctionDefinitions = MaxFunctionDefiningBranches.Value;
|
---|
236 | }
|
---|
237 |
|
---|
238 | private void UpdateGrammar() {
|
---|
239 | foreach (var varSymbol in FunctionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable>()) {
|
---|
240 | varSymbol.VariableNames = DataAnalysisProblemData.InputVariables.Select(x => x.Value);
|
---|
241 | }
|
---|
242 | }
|
---|
243 |
|
---|
244 | private void UpdatePartitioningParameters() {
|
---|
245 | int trainingStart = DataAnalysisProblemData.TrainingSamplesStart.Value;
|
---|
246 | int validationEnd = DataAnalysisProblemData.TrainingSamplesEnd.Value;
|
---|
247 | int trainingEnd = trainingStart + (validationEnd - trainingStart) / 2;
|
---|
248 | int validationStart = trainingEnd;
|
---|
249 | var solutionVisualizer = Visualizer as BestValidationSymbolicRegressionSolutionVisualizer;
|
---|
250 | if (solutionVisualizer != null) {
|
---|
251 | solutionVisualizer.ValidationSamplesStartParameter.Value = new IntValue(validationStart);
|
---|
252 | solutionVisualizer.ValidationSamplesEndParameter.Value = new IntValue(validationEnd);
|
---|
253 | }
|
---|
254 | Evaluator.SamplesStartParameter.Value = new IntValue(trainingStart);
|
---|
255 | Evaluator.SamplesEndParameter.Value = new IntValue(trainingEnd);
|
---|
256 |
|
---|
257 | if (trainingEnd - trainingStart > 0 && DataAnalysisProblemData.TargetVariable.Value != string.Empty) {
|
---|
258 | var targetValues = DataAnalysisProblemData.Dataset.GetVariableValues(DataAnalysisProblemData.TargetVariable.Value, trainingStart, trainingEnd);
|
---|
259 | var mean = targetValues.Average();
|
---|
260 | var range = targetValues.Max() - targetValues.Min();
|
---|
261 | UpperEstimationLimit = new DoubleValue(mean + PunishmentFactor.Value * range);
|
---|
262 | LowerEstimationLimit = new DoubleValue(mean - PunishmentFactor.Value * range);
|
---|
263 | }
|
---|
264 | }
|
---|
265 |
|
---|
266 | public event EventHandler SolutionCreatorChanged;
|
---|
267 | private void OnSolutionCreatorChanged() {
|
---|
268 | var changed = SolutionCreatorChanged;
|
---|
269 | if (changed != null)
|
---|
270 | changed(this, EventArgs.Empty);
|
---|
271 | }
|
---|
272 | public event EventHandler EvaluatorChanged;
|
---|
273 | private void OnEvaluatorChanged() {
|
---|
274 | var changed = EvaluatorChanged;
|
---|
275 | if (changed != null)
|
---|
276 | changed(this, EventArgs.Empty);
|
---|
277 | }
|
---|
278 | public event EventHandler VisualizerChanged;
|
---|
279 | private void OnVisualizerChanged() {
|
---|
280 | var changed = VisualizerChanged;
|
---|
281 | if (changed != null)
|
---|
282 | changed(this, EventArgs.Empty);
|
---|
283 | }
|
---|
284 |
|
---|
285 | public event EventHandler OperatorsChanged;
|
---|
286 | private void OnOperatorsChanged() {
|
---|
287 | var changed = OperatorsChanged;
|
---|
288 | if (changed != null)
|
---|
289 | changed(this, EventArgs.Empty);
|
---|
290 | }
|
---|
291 |
|
---|
292 | private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
293 | SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
294 | ParameterizeSolutionCreator();
|
---|
295 | ParameterizeEvaluator();
|
---|
296 | ParameterizeVisualizer();
|
---|
297 | ParameterizeOperators();
|
---|
298 | OnSolutionCreatorChanged();
|
---|
299 | }
|
---|
300 | private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
301 | ParameterizeEvaluator();
|
---|
302 | ParameterizeVisualizer();
|
---|
303 | ParameterizeOperators();
|
---|
304 | }
|
---|
305 | private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
306 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
307 | ParameterizeEvaluator();
|
---|
308 | ParameterizeVisualizer();
|
---|
309 | OnEvaluatorChanged();
|
---|
310 | }
|
---|
311 |
|
---|
312 | private void VisualizerParameter_ValueChanged(object sender, EventArgs e) {
|
---|
313 | ParameterizeVisualizer();
|
---|
314 | OnVisualizerChanged();
|
---|
315 | }
|
---|
316 |
|
---|
317 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
318 | ParameterizeVisualizer();
|
---|
319 | }
|
---|
320 |
|
---|
321 | #endregion
|
---|
322 |
|
---|
323 | #region Helpers
|
---|
324 | [StorableHook(HookType.AfterDeserialization)]
|
---|
325 | private void Initialize() {
|
---|
326 | InitializeOperators();
|
---|
327 | SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
|
---|
328 | SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
|
---|
329 | EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
|
---|
330 | Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
331 | VisualizerParameter.ValueChanged += new EventHandler(VisualizerParameter_ValueChanged);
|
---|
332 | }
|
---|
333 |
|
---|
334 | private void InitializeOperators() {
|
---|
335 | operators = new List<ISymbolicExpressionTreeOperator>();
|
---|
336 | operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
|
---|
337 | ParameterizeOperators();
|
---|
338 | UpdateGrammar();
|
---|
339 | UpdatePartitioningParameters();
|
---|
340 | }
|
---|
341 |
|
---|
342 | private void ParameterizeSolutionCreator() {
|
---|
343 | SolutionCreator.SymbolicExpressionGrammarParameter.ActualName = FunctionTreeGrammarParameter.Name;
|
---|
344 | SolutionCreator.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
|
---|
345 | SolutionCreator.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
|
---|
346 | }
|
---|
347 | private void ParameterizeEvaluator() {
|
---|
348 | Evaluator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
349 | Evaluator.RegressionProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
|
---|
350 | Evaluator.QualityParameter.ActualName = "TrainingMeanSquaredError";
|
---|
351 | Evaluator.SamplesStartParameter.Value = new IntValue(DataAnalysisProblemData.TrainingSamplesStart.Value);
|
---|
352 | Evaluator.SamplesEndParameter.Value = new IntValue((DataAnalysisProblemData.TrainingSamplesStart.Value + DataAnalysisProblemData.TrainingSamplesEnd.Value) / 2);
|
---|
353 | }
|
---|
354 | private void ParameterizeVisualizer() {
|
---|
355 | if (Visualizer != null) {
|
---|
356 | var solutionVisualizer = Visualizer as BestValidationSymbolicRegressionSolutionVisualizer;
|
---|
357 | if (solutionVisualizer != null) {
|
---|
358 | solutionVisualizer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
359 | solutionVisualizer.DataAnalysisProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
|
---|
360 | solutionVisualizer.ValidationSamplesStartParameter.Value = new IntValue((DataAnalysisProblemData.TrainingSamplesStart.Value + DataAnalysisProblemData.TrainingSamplesEnd.Value) / 2);
|
---|
361 | solutionVisualizer.ValidationSamplesEndParameter.Value = new IntValue(DataAnalysisProblemData.TrainingSamplesEnd.Value);
|
---|
362 | }
|
---|
363 | }
|
---|
364 | }
|
---|
365 |
|
---|
366 | private void ParameterizeOperators() {
|
---|
367 | foreach (ISymbolicExpressionTreeOperator op in Operators.OfType<ISymbolicExpressionTreeOperator>()) {
|
---|
368 | op.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
|
---|
369 | op.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
|
---|
370 | op.SymbolicExpressionGrammarParameter.ActualName = FunctionTreeGrammarParameter.Name;
|
---|
371 | }
|
---|
372 | foreach (ISymbolicRegressionEvaluator op in Operators.OfType<ISymbolicRegressionEvaluator>()) {
|
---|
373 | op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
374 | op.RegressionProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
|
---|
375 | }
|
---|
376 | foreach (ISymbolicExpressionTreeCrossover op in Operators.OfType<ISymbolicExpressionTreeCrossover>()) {
|
---|
377 | op.ParentsParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
378 | op.ChildParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
379 | }
|
---|
380 | foreach (ISymbolicExpressionTreeManipulator op in Operators.OfType<ISymbolicExpressionTreeManipulator>()) {
|
---|
381 | op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
382 | }
|
---|
383 | foreach (ISymbolicExpressionTreeArchitectureManipulator op in Operators.OfType<ISymbolicExpressionTreeArchitectureManipulator>()) {
|
---|
384 | op.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
|
---|
385 | op.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefiningBranchesParameter.Name;
|
---|
386 | }
|
---|
387 | }
|
---|
388 | #endregion
|
---|
389 | }
|
---|
390 | }
|
---|