Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs @ 4077

Last change on this file since 4077 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

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