Free cookie consent management tool by TermsFeed Policy Generator

source: branches/sluengo/HeuristicLab.Problems.TradeRules/TradeRulesSingleObjectiveTrainingBestSolutionAnalyzer.cs @ 14626

Last change on this file since 14626 was 9262, checked in by sluengo, 12 years ago
File size: 4.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Problems.DataAnalysis.Symbolic;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7using HeuristicLab.Core;
8using HeuristicLab.Data;
9using HeuristicLab.Problems.DataAnalysis;
10using HeuristicLab.Parameters;
11using HeuristicLab.Common;
12using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
13using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
14
15namespace HeuristicLab.Problems.TradeRules
16{
17    [Item("TradeRulesSingleObjectiveTrainingBestSolutionAnalyzer", "An operator that analyzes the training best symbolic regression solution for single objective symbolic regression problems.")]
18    [StorableClass]
19    public sealed class TradeRulesSingleObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<ISymbolicRegressionSolution>,
20  ISymbolicDataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator
21    {
22        private const string ProblemDataParameterName = "ProblemData";
23    private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
24    private const string EstimationLimitsParameterName = "EstimationLimits";
25    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
26    #region parameter properties
27    public ILookupParameter<IRegressionProblemData> ProblemDataParameter {
28      get { return (ILookupParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; }
29    }
30    public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {
31      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
32    }
33    public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter {
34      get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
35    }
36    public IValueParameter<BoolValue> ApplyLinearScalingParameter {
37      get { return (IValueParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
38    }
39    #endregion
40
41    #region properties
42    public BoolValue ApplyLinearScaling {
43      get { return ApplyLinearScalingParameter.Value; }
44    }
45    #endregion
46
47    [StorableConstructor]
48    private TradeRulesSingleObjectiveTrainingBestSolutionAnalyzer(bool deserializing) : base(deserializing) { }
49    private TradeRulesSingleObjectiveTrainingBestSolutionAnalyzer(TradeRulesSingleObjectiveTrainingBestSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { }
50    public TradeRulesSingleObjectiveTrainingBestSolutionAnalyzer()
51      : base() {
52      Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution."));
53      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree."));
54      Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model."));
55      Parameters.Add(new ValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the produced symbolic regression solution should be linearly scaled.", new BoolValue(false)));
56    }
57    public override IDeepCloneable Clone(Cloner cloner) {
58      return new TradeRulesSingleObjectiveTrainingBestSolutionAnalyzer(this, cloner);
59    }
60
61    protected override ISymbolicRegressionSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
62      var model = new SymbolicRegressionModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
63      if (ApplyLinearScaling.Value)
64          SymbolicRegressionModel.Scale(model, ProblemDataParameter.ActualValue);
65      return new TradingRulesSolution(model, (IRegressionProblemData)ProblemDataParameter.ActualValue.Clone());
66    }
67  }
68    }
69
Note: See TracBrowser for help on using the repository browser.