1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Core;
|
---|
6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
7 | using HeuristicLab.Problems.DataAnalysis.Symbolic;
|
---|
8 | using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
|
---|
9 | using HeuristicLab.Problems.DataAnalysis;
|
---|
10 | using HeuristicLab.Common;
|
---|
11 | using HeuristicLab.Data;
|
---|
12 | using HeuristicLab.Parameters;
|
---|
13 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
14 |
|
---|
15 | namespace HeuristicLab.Problems.TradeRules
|
---|
16 | {
|
---|
17 | [Item("TradeRulesSingleObjectiveValidationBestSolutionAnalyzer", "An operator that analyzes the validation best symbolic regression solution for single objective symbolic regression problems.")]
|
---|
18 | [StorableClass]
|
---|
19 | public sealed class TradeRulesSingleObjectiveValidationBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer<ISymbolicRegressionSolution, ISymbolicRegressionSingleObjectiveEvaluator, IRegressionProblemData>,
|
---|
20 | ISymbolicDataAnalysisBoundedOperator
|
---|
21 | {
|
---|
22 | private const string EstimationLimitsParameterName = "EstimationLimits";
|
---|
23 | private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
|
---|
24 |
|
---|
25 | #region parameter properties
|
---|
26 | public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter {
|
---|
27 | get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
|
---|
28 | }
|
---|
29 | public IValueParameter<BoolValue> ApplyLinearScalingParameter {
|
---|
30 | get { return (IValueParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
|
---|
31 | }
|
---|
32 | #endregion
|
---|
33 |
|
---|
34 | #region properties
|
---|
35 | public BoolValue ApplyLinearScaling {
|
---|
36 | get { return ApplyLinearScalingParameter.Value; }
|
---|
37 | }
|
---|
38 | #endregion
|
---|
39 |
|
---|
40 | [StorableConstructor]
|
---|
41 | private TradeRulesSingleObjectiveValidationBestSolutionAnalyzer(bool deserializing) : base(deserializing) { }
|
---|
42 | private TradeRulesSingleObjectiveValidationBestSolutionAnalyzer(TradeRulesSingleObjectiveValidationBestSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { }
|
---|
43 | public TradeRulesSingleObjectiveValidationBestSolutionAnalyzer()
|
---|
44 | : base() {
|
---|
45 | Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model."));
|
---|
46 | Parameters.Add(new ValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the produced symbolic regression solution should be linearly scaled.", new BoolValue(false)));
|
---|
47 | }
|
---|
48 |
|
---|
49 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
50 | return new TradeRulesSingleObjectiveValidationBestSolutionAnalyzer(this, cloner);
|
---|
51 | }
|
---|
52 |
|
---|
53 | protected override ISymbolicRegressionSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
|
---|
54 | var model = new SymbolicRegressionModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
|
---|
55 | if (ApplyLinearScaling.Value)
|
---|
56 | SymbolicRegressionModel.Scale(model, ProblemDataParameter.ActualValue);
|
---|
57 | return new TradingRulesSolution(model, (IRegressionProblemData)ProblemDataParameter.ActualValue.Clone());
|
---|
58 | }
|
---|
59 |
|
---|
60 | }
|
---|
61 | }
|
---|