Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/PopulationValidationBestScaledSymbolicRegressionSolutionAnalyzer.cs @ 3662

Last change on this file since 3662 was 3659, checked in by swagner, 15 years ago

Worked on refactoring of algorithm analysis and tracing (#999)

  • removed SubScopesSubScopesLookupParameter
  • adapted SubScopesLookupParameter and renamed it into ScopeTreeLookupParameter
File size: 9.5 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.Linq;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Operators;
27using HeuristicLab.Optimization;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
31using HeuristicLab.Problems.DataAnalysis.Regression.Symbolic;
32using HeuristicLab.Problems.DataAnalysis.Symbolic;
33using System.Collections.Generic;
34using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
35using HeuristicLab.Problems.DataAnalysis;
36
37namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers {
38  /// <summary>
39  /// An operator that analyzes the validation best scaled symbolic regression solution.
40  /// </summary>
41  [Item("PopulationValidationBestScaledSymbolicRegressionSolutionAnalyzer", "An operator that analyzes the validation best scaled symbolic regression solution.")]
42  [StorableClass]
43  public sealed class PopulationValidationBestScaledSymbolicRegressionSolutionAnalyzer : AlgorithmOperator, ISymbolicRegressionSolutionPopulationAnalyzer {
44    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
45    private const string ScaledSymbolicExpressionTreeParameterName = "ScaledSymbolicExpressionTree";
46    private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
47    private const string ProblemDataParameterName = "ProblemData";
48    private const string SamplesStartParameterName = "SamplesStart";
49    private const string SamplesEndParameterName = "SamplesEnd";
50    private const string QualityParameterName = "ScaledQuality";
51    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
52    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
53    private const string AlphaParameterName = "Alpha";
54    private const string BetaParameterName = "Beta";
55    private const string BestSolutionParameterName = "ValidationBestSolution";
56    private const string BestSolutionQualityParameterName = "ValidationBestSolutionQuality";
57    private const string ResultsParameterName = "Results";
58
59    public ILookupParameter<ItemArray<SymbolicExpressionTree>> SymbolicExpressionTreeParameter {
60      get { return (ILookupParameter<ItemArray<SymbolicExpressionTree>>)Parameters[SymbolicExpressionTreeParameterName]; }
61    }
62    public ILookupParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
63      get { return (ILookupParameter<ISymbolicExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
64    }
65    public ILookupParameter<DataAnalysisProblemData> ProblemDataParameter {
66      get { return (ILookupParameter<DataAnalysisProblemData>)Parameters[ProblemDataParameterName]; }
67    }
68    public IValueLookupParameter<IntValue> SamplesStartParameter {
69      get { return (IValueLookupParameter<IntValue>)Parameters[SamplesStartParameterName]; }
70    }
71    public IValueLookupParameter<IntValue> SamplesEndParameter {
72      get { return (IValueLookupParameter<IntValue>)Parameters[SamplesEndParameterName]; }
73    }
74    public ILookupParameter<DoubleValue> UpperEstimationLimitParameter {
75      get { return (ILookupParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
76    }
77    public ILookupParameter<DoubleValue> LowerEstimationLimitParameter {
78      get { return (ILookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
79    }
80    public ILookupParameter<SymbolicRegressionSolution> BestSolutionParameter {
81      get { return (ILookupParameter<SymbolicRegressionSolution>)Parameters[BestSolutionParameterName]; }
82    }
83    public ILookupParameter<DoubleValue> BestSolutionQualityParameter {
84      get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionQualityParameterName]; }
85    }
86    public ILookupParameter<ResultCollection> ResultsParameter {
87      get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
88    }
89
90    public PopulationValidationBestScaledSymbolicRegressionSolutionAnalyzer()
91      : base() {
92      Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to analyze."));
93      Parameters.Add(new LookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used for the analysis of symbolic expression trees."));
94      Parameters.Add(new LookupParameter<DataAnalysisProblemData>(ProblemDataParameterName, "The problem data for which the symbolic expression tree is a solution."));
95      Parameters.Add(new ValueLookupParameter<IntValue>(SamplesStartParameterName, "The first index of the validation partition of the data set."));
96      Parameters.Add(new ValueLookupParameter<IntValue>(SamplesEndParameterName, "The last index of the validation partition of the data set."));
97      Parameters.Add(new LookupParameter<DoubleValue>(UpperEstimationLimitParameterName, "The upper estimation limit that was set for the evaluation of the symbolic expression trees."));
98      Parameters.Add(new LookupParameter<DoubleValue>(LowerEstimationLimitParameterName, "The lower estimation limit that was set for the evaluation of the symbolic expression trees."));
99      Parameters.Add(new LookupParameter<SymbolicRegressionSolution>(BestSolutionParameterName, "The best symbolic regression solution."));
100      Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionQualityParameterName, "The quality of the best symbolic regression solution."));
101      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection where the best symbolic regression solution should be stored."));
102
103      #region operator initialization
104      UniformSubScopesProcessor subScopesProc = new UniformSubScopesProcessor();
105      SymbolicRegressionSolutionLinearScaler linearScaler = new SymbolicRegressionSolutionLinearScaler();
106      SymbolicRegressionMeanSquaredErrorEvaluator validationMseEvaluator = new SymbolicRegressionMeanSquaredErrorEvaluator();
107      PopulationBestSymbolicRegressionSolutionAnalyzer bestSolutionAnalyzer = new PopulationBestSymbolicRegressionSolutionAnalyzer();
108      #endregion
109
110      #region parameter wiring
111      linearScaler.AlphaParameter.ActualName = AlphaParameterName;
112      linearScaler.BetaParameter.ActualName = BetaParameterName;
113      linearScaler.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameterName;
114      linearScaler.ScaledSymbolicExpressionTreeParameter.ActualName = ScaledSymbolicExpressionTreeParameterName;
115
116      validationMseEvaluator.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameterName;
117      validationMseEvaluator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameterName;
118      validationMseEvaluator.SymbolicExpressionTreeParameter.ActualName = ScaledSymbolicExpressionTreeParameterName;
119      validationMseEvaluator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameterName;
120      validationMseEvaluator.QualityParameter.ActualName = QualityParameterName;
121      validationMseEvaluator.RegressionProblemDataParameter.ActualName = ProblemDataParameterName;
122      validationMseEvaluator.SamplesStartParameter.ActualName = SamplesStartParameterName;
123      validationMseEvaluator.SamplesEndParameter.ActualName = SamplesEndParameterName;
124
125      bestSolutionAnalyzer.BestSolutionParameter.ActualName = BestSolutionParameterName;
126      bestSolutionAnalyzer.BestSolutionQualityParameter.ActualName = BestSolutionQualityParameterName;
127      bestSolutionAnalyzer.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameterName;
128      bestSolutionAnalyzer.ProblemDataParameter.ActualName = ProblemDataParameterName;
129      bestSolutionAnalyzer.QualityParameter.ActualName = QualityParameterName;
130      bestSolutionAnalyzer.ResultsParameter.ActualName = ResultsParameterName;
131      bestSolutionAnalyzer.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameterName;
132      bestSolutionAnalyzer.SymbolicExpressionTreeParameter.ActualName = ScaledSymbolicExpressionTreeParameterName;
133      bestSolutionAnalyzer.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameterName;
134      #endregion
135
136      #region operator graph
137      OperatorGraph.InitialOperator = subScopesProc;
138      subScopesProc.Operator = linearScaler;
139      linearScaler.Successor = validationMseEvaluator;
140      validationMseEvaluator.Successor = null;
141      subScopesProc.Successor = bestSolutionAnalyzer;
142      bestSolutionAnalyzer.Successor = null;
143      #endregion
144    }
145  }
146}
Note: See TracBrowser for help on using the repository browser.