Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/TrainingBestScaledSymbolicRegressionSolutionAnalyzer.cs @ 7214

Last change on this file since 7214 was 7214, checked in by ascheibe, 12 years ago

#1706 adapted outdated plugins to changes in IAnalyzer

File size: 24.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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.Collections.Generic;
23using System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Data;
27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
28using HeuristicLab.Operators;
29using HeuristicLab.Optimization;
30using HeuristicLab.Parameters;
31using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
32using HeuristicLab.PluginInfrastructure;
33using HeuristicLab.Problems.DataAnalysis.Evaluators;
34using HeuristicLab.Problems.DataAnalysis.Symbolic;
35
36namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers {
37  /// <summary>
38  /// An operator that analyzes the training best scaled symbolic regression solution.
39  /// </summary>
40  [Item("TrainingBestScaledSymbolicRegressionSolutionAnalyzer", "An operator that analyzes the training best scaled symbolic regression solution.")]
41  [StorableClass]
42  [NonDiscoverableType]
43  public sealed class TrainingBestScaledSymbolicRegressionSolutionAnalyzer : SingleSuccessorOperator, ISymbolicRegressionAnalyzer {
44    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
45    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
46    private const string QualityParameterName = "Quality";
47    private const string MaximizationParameterName = "Maximization";
48    private const string CalculateSolutionComplexityParameterName = "CalculateSolutionComplexity";
49    private const string CalculateSolutionAccuracyParameterName = "CalculateSolutionAccuracy";
50    private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
51    private const string ProblemDataParameterName = "DataAnalysisProblemData";
52    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
53    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
54    private const string BestSolutionParameterName = "Best training solution";
55    private const string BestSolutionQualityParameterName = "Best training solution quality";
56    private const string BestSolutionLengthParameterName = "Best training solution length";
57    private const string BestSolutionHeightParameterName = "Best training solution height";
58    private const string BestSolutionVariablesParameterName = "Best training solution variables";
59    private const string BestSolutionTrainingRSquaredParameterName = "Best training solution R² (training)";
60    private const string BestSolutionTestRSquaredParameterName = "Best training solution R² (test)";
61    private const string BestSolutionTrainingMseParameterName = "Best training solution mean squared error (training)";
62    private const string BestSolutionTestMseParameterName = "Best training solution mean squared error (test)";
63    private const string BestSolutionTrainingRelativeErrorParameterName = "Best training solution relative error (training)";
64    private const string BestSolutionTestRelativeErrorParameterName = "Best training solution relative error (test)";
65    private const string ResultsParameterName = "Results";
66
67    public bool EnabledByDefault {
68      get { return true; }
69    }
70
71    #region parameter properties
72    public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
73      get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
74    }
75    public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
76      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[QualityParameterName]; }
77    }
78    public ILookupParameter<BoolValue> MaximizationParameter {
79      get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; }
80    }
81    public IValueParameter<BoolValue> CalculateSolutionComplexityParameter {
82      get { return (IValueParameter<BoolValue>)Parameters[CalculateSolutionComplexityParameterName]; }
83    }
84    public IValueParameter<BoolValue> CalculateSolutionAccuracyParameter {
85      get { return (IValueParameter<BoolValue>)Parameters[CalculateSolutionAccuracyParameterName]; }
86    }
87    public IValueLookupParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
88      get { return (IValueLookupParameter<ISymbolicExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
89    }
90    public IValueLookupParameter<DataAnalysisProblemData> ProblemDataParameter {
91      get { return (IValueLookupParameter<DataAnalysisProblemData>)Parameters[ProblemDataParameterName]; }
92    }
93    public IValueLookupParameter<DoubleValue> UpperEstimationLimitParameter {
94      get { return (IValueLookupParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
95    }
96    public IValueLookupParameter<DoubleValue> LowerEstimationLimitParameter {
97      get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
98    }
99
100    public ILookupParameter<SymbolicRegressionSolution> BestSolutionParameter {
101      get { return (ILookupParameter<SymbolicRegressionSolution>)Parameters[BestSolutionParameterName]; }
102    }
103    public ILookupParameter<DoubleValue> BestSolutionQualityParameter {
104      get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionQualityParameterName]; }
105    }
106    public ILookupParameter<IntValue> BestSolutionLengthParameter {
107      get { return (ILookupParameter<IntValue>)Parameters[BestSolutionLengthParameterName]; }
108    }
109    public ILookupParameter<IntValue> BestSolutionHeightParameter {
110      get { return (ILookupParameter<IntValue>)Parameters[BestSolutionHeightParameterName]; }
111    }
112    public ILookupParameter<IntValue> BestSolutionVariablesParameter {
113      get { return (ILookupParameter<IntValue>)Parameters[BestSolutionVariablesParameterName]; }
114    }
115    public ILookupParameter<DoubleValue> BestSolutionTrainingRSquaredParameter {
116      get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTrainingRSquaredParameterName]; }
117    }
118    public ILookupParameter<DoubleValue> BestSolutionTestRSquaredParameter {
119      get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTestRSquaredParameterName]; }
120    }
121    public ILookupParameter<DoubleValue> BestSolutionTrainingMseParameter {
122      get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTrainingMseParameterName]; }
123    }
124    public ILookupParameter<DoubleValue> BestSolutionTestMseParameter {
125      get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTestMseParameterName]; }
126    }
127    public ILookupParameter<DoubleValue> BestSolutionTrainingRelativeErrorParameter {
128      get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTrainingRelativeErrorParameterName]; }
129    }
130    public ILookupParameter<DoubleValue> BestSolutionTestRelativeErrorParameter {
131      get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTestRelativeErrorParameterName]; }
132    }
133    public ILookupParameter<ResultCollection> ResultsParameter {
134      get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
135    }
136    public IValueLookupParameter<BoolValue> ApplyLinearScalingParameter {
137      get { return (IValueLookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
138    }
139    #endregion
140    #region properties
141    public ItemArray<SymbolicExpressionTree> SymbolicExpressionTree {
142      get { return SymbolicExpressionTreeParameter.ActualValue; }
143    }
144    public ItemArray<DoubleValue> Quality {
145      get { return QualityParameter.ActualValue; }
146    }
147    public BoolValue Maximization {
148      get { return MaximizationParameter.ActualValue; }
149    }
150    public BoolValue CalculateSolutionComplexity {
151      get { return CalculateSolutionComplexityParameter.Value; }
152      set { CalculateSolutionComplexityParameter.Value = value; }
153    }
154    public BoolValue CalculateSolutionAccuracy {
155      get { return CalculateSolutionAccuracyParameter.Value; }
156      set { CalculateSolutionAccuracyParameter.Value = value; }
157    }
158    public ISymbolicExpressionTreeInterpreter SymbolicExpressionTreeInterpreter {
159      get { return SymbolicExpressionTreeInterpreterParameter.ActualValue; }
160    }
161    public DataAnalysisProblemData ProblemData {
162      get { return ProblemDataParameter.ActualValue; }
163    }
164    public DoubleValue UpperEstimationLimit {
165      get { return UpperEstimationLimitParameter.ActualValue; }
166    }
167    public DoubleValue LowerEstimationLimit {
168      get { return LowerEstimationLimitParameter.ActualValue; }
169    }
170    public ResultCollection Results {
171      get { return ResultsParameter.ActualValue; }
172    }
173    public SymbolicRegressionSolution BestSolution {
174      get { return BestSolutionParameter.ActualValue; }
175      set { BestSolutionParameter.ActualValue = value; }
176    }
177    public DoubleValue BestSolutionQuality {
178      get { return BestSolutionQualityParameter.ActualValue; }
179      set { BestSolutionQualityParameter.ActualValue = value; }
180    }
181    public IntValue BestSolutionLength {
182      get { return BestSolutionLengthParameter.ActualValue; }
183      set { BestSolutionLengthParameter.ActualValue = value; }
184    }
185    public IntValue BestSolutionHeight {
186      get { return BestSolutionHeightParameter.ActualValue; }
187      set { BestSolutionHeightParameter.ActualValue = value; }
188    }
189    public IntValue BestSolutionVariables {
190      get { return BestSolutionVariablesParameter.ActualValue; }
191      set { BestSolutionVariablesParameter.ActualValue = value; }
192    }
193    public DoubleValue BestSolutionTrainingRSquared {
194      get { return BestSolutionTrainingRSquaredParameter.ActualValue; }
195      set { BestSolutionTrainingRSquaredParameter.ActualValue = value; }
196    }
197    public DoubleValue BestSolutionTestRSquared {
198      get { return BestSolutionTestRSquaredParameter.ActualValue; }
199      set { BestSolutionTestRSquaredParameter.ActualValue = value; }
200    }
201    public DoubleValue BestSolutionTrainingMse {
202      get { return BestSolutionTrainingMseParameter.ActualValue; }
203      set { BestSolutionTrainingMseParameter.ActualValue = value; }
204    }
205    public DoubleValue BestSolutionTestMse {
206      get { return BestSolutionTestMseParameter.ActualValue; }
207      set { BestSolutionTestMseParameter.ActualValue = value; }
208    }
209    public DoubleValue BestSolutionTrainingRelativeError {
210      get { return BestSolutionTrainingRelativeErrorParameter.ActualValue; }
211      set { BestSolutionTrainingRelativeErrorParameter.ActualValue = value; }
212    }
213    public DoubleValue BestSolutionTestRelativeError {
214      get { return BestSolutionTestRelativeErrorParameter.ActualValue; }
215      set { BestSolutionTestRelativeErrorParameter.ActualValue = value; }
216    }
217    public BoolValue ApplyLinearScaling {
218      get { return ApplyLinearScalingParameter.ActualValue; }
219      set { ApplyLinearScalingParameter.ActualValue = value; }
220    }
221    #endregion
222
223    [StorableConstructor]
224    private TrainingBestScaledSymbolicRegressionSolutionAnalyzer(bool deserializing) : base(deserializing) { }
225    private TrainingBestScaledSymbolicRegressionSolutionAnalyzer(TrainingBestScaledSymbolicRegressionSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { }
226    public TrainingBestScaledSymbolicRegressionSolutionAnalyzer()
227      : base() {
228      Parameters.Add(new ValueLookupParameter<BoolValue>(ApplyLinearScalingParameterName, "The switch determines if the best solution should be linearly scaled on the whole training set.", new BoolValue(true)));
229      Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "The direction of optimization."));
230      Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to analyze."));
231      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName, "The qualities of the symbolic expression trees to analyze."));
232      Parameters.Add(new ValueParameter<BoolValue>(CalculateSolutionComplexityParameterName, "Determines if the length and height of the training best solution should be calculated.", new BoolValue(true)));
233      Parameters.Add(new ValueParameter<BoolValue>(CalculateSolutionAccuracyParameterName, "Determines if the accuracy of the training best solution on the training and test set should be calculated.", new BoolValue(true)));
234      Parameters.Add(new ValueLookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used for the analysis of symbolic expression trees."));
235      Parameters.Add(new ValueLookupParameter<DataAnalysisProblemData>(ProblemDataParameterName, "The problem data for which the symbolic expression tree is a solution."));
236      Parameters.Add(new ValueLookupParameter<DoubleValue>(UpperEstimationLimitParameterName, "The upper estimation limit that was set for the evaluation of the symbolic expression trees."));
237      Parameters.Add(new ValueLookupParameter<DoubleValue>(LowerEstimationLimitParameterName, "The lower estimation limit that was set for the evaluation of the symbolic expression trees."));
238      Parameters.Add(new LookupParameter<SymbolicRegressionSolution>(BestSolutionParameterName, "The best symbolic regression solution."));
239      Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionQualityParameterName, "The quality of the best symbolic regression solution."));
240      Parameters.Add(new LookupParameter<IntValue>(BestSolutionLengthParameterName, "The length of the best symbolic regression solution."));
241      Parameters.Add(new LookupParameter<IntValue>(BestSolutionHeightParameterName, "The height of the best symbolic regression solution."));
242      Parameters.Add(new LookupParameter<IntValue>(BestSolutionVariablesParameterName, "The number of variables used by the best symbolic regression solution."));
243      Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTrainingRSquaredParameterName, "The R² value on the training set of the best symbolic regression solution."));
244      Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTestRSquaredParameterName, "The R² value on the test set of the best symbolic regression solution."));
245      Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTrainingMseParameterName, "The mean squared error on the training set of the best symbolic regression solution."));
246      Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTestMseParameterName, "The mean squared error value on the test set of the best symbolic regression solution."));
247      Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTrainingRelativeErrorParameterName, "The relative error on the training set of the best symbolic regression solution."));
248      Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTestRelativeErrorParameterName, "The relative error value on the test set of the best symbolic regression solution."));
249      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection where the best symbolic regression solution should be stored."));
250    }
251
252    public override IDeepCloneable Clone(Cloner cloner) {
253      return new TrainingBestScaledSymbolicRegressionSolutionAnalyzer(this, cloner);
254    }
255
256    [StorableHook(HookType.AfterDeserialization)]
257    private void AfterDeserialization() {
258      if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) {
259        Parameters.Add(new ValueLookupParameter<BoolValue>(ApplyLinearScalingParameterName, "The switch determines if the best solution should be linearly scaled on the whole training set.", new BoolValue(true)));
260      }
261    }
262
263    public override IOperation Apply() {
264      #region find best tree
265      double bestQuality = Maximization.Value ? double.NegativeInfinity : double.PositiveInfinity;
266      SymbolicExpressionTree bestTree = null;
267      SymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray();
268      double[] quality = Quality.Select(x => x.Value).ToArray();
269      for (int i = 0; i < tree.Length; i++) {
270        if ((Maximization.Value && quality[i] > bestQuality) ||
271            (!Maximization.Value && quality[i] < bestQuality)) {
272          bestQuality = quality[i];
273          bestTree = tree[i];
274        }
275      }
276      #endregion
277
278      #region update best solution
279      // if the best tree is better than the current best solution => update
280      bool newBest =
281        BestSolutionQuality == null ||
282        (Maximization.Value && bestQuality > BestSolutionQuality.Value) ||
283        (!Maximization.Value && bestQuality < BestSolutionQuality.Value);
284      if (newBest) {
285        double upperEstimationLimit = UpperEstimationLimit != null ? UpperEstimationLimit.Value : double.PositiveInfinity;
286        double lowerEstimationLimit = LowerEstimationLimit != null ? LowerEstimationLimit.Value : double.NegativeInfinity;
287        string targetVariable = ProblemData.TargetVariable.Value;
288
289        if (ApplyLinearScaling.Value) {
290          // calculate scaling parameters and only for the best tree using the full training set
291          double alpha, beta;
292          SymbolicRegressionScaledMeanSquaredErrorEvaluator.Calculate(SymbolicExpressionTreeInterpreter, bestTree,
293            lowerEstimationLimit, upperEstimationLimit,
294            ProblemData.Dataset, targetVariable,
295            ProblemData.TrainingIndizes, out beta, out alpha);
296
297          // scale tree for solution
298          bestTree = SymbolicRegressionSolutionLinearScaler.Scale(bestTree, alpha, beta);
299        }
300        var model = new SymbolicRegressionModel((ISymbolicExpressionTreeInterpreter)SymbolicExpressionTreeInterpreter.Clone(),
301          bestTree);
302        var solution = new SymbolicRegressionSolution((DataAnalysisProblemData)ProblemData.Clone(), model, lowerEstimationLimit, upperEstimationLimit);
303        solution.Name = BestSolutionParameterName;
304        solution.Description = "Best solution on training partition found over the whole run.";
305
306        BestSolution = solution;
307        BestSolutionQuality = new DoubleValue(bestQuality);
308
309        if (CalculateSolutionComplexity.Value) {
310          BestSolutionLength = new IntValue(solution.Model.SymbolicExpressionTree.Size);
311          BestSolutionHeight = new IntValue(solution.Model.SymbolicExpressionTree.Height);
312          BestSolutionVariables = new IntValue(solution.Model.InputVariables.Count());
313          if (!Results.ContainsKey(BestSolutionLengthParameterName)) {
314            Results.Add(new Result(BestSolutionLengthParameterName, "Length of the best solution on the training set.", BestSolutionLength));
315            Results.Add(new Result(BestSolutionHeightParameterName, "Height of the best solution on the training set.", BestSolutionHeight));
316            Results.Add(new Result(BestSolutionVariablesParameterName, "Number of variables used by the best solution on the training set.", BestSolutionVariables));
317          } else {
318            Results[BestSolutionLengthParameterName].Value = BestSolutionLength;
319            Results[BestSolutionHeightParameterName].Value = BestSolutionHeight;
320            Results[BestSolutionVariablesParameterName].Value = BestSolutionVariables;
321          }
322        }
323
324        if (CalculateSolutionAccuracy.Value) {
325          #region update R2,MSE, Rel Error
326          IEnumerable<double> trainingValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable.Value, ProblemData.TrainingIndizes);
327          IEnumerable<double> testValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable.Value, ProblemData.TestIndizes);
328          OnlineMeanSquaredErrorEvaluator mseEvaluator = new OnlineMeanSquaredErrorEvaluator();
329          OnlineMeanAbsolutePercentageErrorEvaluator relErrorEvaluator = new OnlineMeanAbsolutePercentageErrorEvaluator();
330          OnlinePearsonsRSquaredEvaluator r2Evaluator = new OnlinePearsonsRSquaredEvaluator();
331
332          #region training
333          var originalEnumerator = trainingValues.GetEnumerator();
334          var estimatedEnumerator = solution.EstimatedTrainingValues.GetEnumerator();
335          while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) {
336            mseEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current);
337            r2Evaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current);
338            relErrorEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current);
339          }
340          double trainingR2 = r2Evaluator.RSquared;
341          double trainingMse = mseEvaluator.MeanSquaredError;
342          double trainingRelError = relErrorEvaluator.MeanAbsolutePercentageError;
343          #endregion
344
345          mseEvaluator.Reset();
346          relErrorEvaluator.Reset();
347          r2Evaluator.Reset();
348
349          #region test
350          originalEnumerator = testValues.GetEnumerator();
351          estimatedEnumerator = solution.EstimatedTestValues.GetEnumerator();
352          while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) {
353            mseEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current);
354            r2Evaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current);
355            relErrorEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current);
356          }
357          double testR2 = r2Evaluator.RSquared;
358          double testMse = mseEvaluator.MeanSquaredError;
359          double testRelError = relErrorEvaluator.MeanAbsolutePercentageError;
360          #endregion
361          BestSolutionTrainingRSquared = new DoubleValue(trainingR2);
362          BestSolutionTestRSquared = new DoubleValue(testR2);
363          BestSolutionTrainingMse = new DoubleValue(trainingMse);
364          BestSolutionTestMse = new DoubleValue(testMse);
365          BestSolutionTrainingRelativeError = new DoubleValue(trainingRelError);
366          BestSolutionTestRelativeError = new DoubleValue(testRelError);
367
368          if (!Results.ContainsKey(BestSolutionTrainingRSquaredParameterName)) {
369            Results.Add(new Result(BestSolutionTrainingRSquaredParameterName, BestSolutionTrainingRSquared));
370            Results.Add(new Result(BestSolutionTestRSquaredParameterName, BestSolutionTestRSquared));
371            Results.Add(new Result(BestSolutionTrainingMseParameterName, BestSolutionTrainingMse));
372            Results.Add(new Result(BestSolutionTestMseParameterName, BestSolutionTestMse));
373            Results.Add(new Result(BestSolutionTrainingRelativeErrorParameterName, BestSolutionTrainingRelativeError));
374            Results.Add(new Result(BestSolutionTestRelativeErrorParameterName, BestSolutionTestRelativeError));
375          } else {
376            Results[BestSolutionTrainingRSquaredParameterName].Value = BestSolutionTrainingRSquared;
377            Results[BestSolutionTestRSquaredParameterName].Value = BestSolutionTestRSquared;
378            Results[BestSolutionTrainingMseParameterName].Value = BestSolutionTrainingMse;
379            Results[BestSolutionTestMseParameterName].Value = BestSolutionTestMse;
380            Results[BestSolutionTrainingRelativeErrorParameterName].Value = BestSolutionTrainingRelativeError;
381            Results[BestSolutionTestRelativeErrorParameterName].Value = BestSolutionTestRelativeError;
382          }
383          #endregion
384        }
385
386        if (!Results.ContainsKey(BestSolutionQualityParameterName)) {
387          Results.Add(new Result(BestSolutionQualityParameterName, BestSolutionQuality));
388          Results.Add(new Result(BestSolutionParameterName, BestSolution));
389        } else {
390          Results[BestSolutionQualityParameterName].Value = BestSolutionQuality;
391          Results[BestSolutionParameterName].Value = BestSolution;
392        }
393      }
394      #endregion
395      return base.Apply();
396    }
397  }
398}
Note: See TracBrowser for help on using the repository browser.