Free cookie consent management tool by TermsFeed Policy Generator

source: branches/sluengo/HeuristicLab.Problems.TradeRules/Solution/TradingRulesSolution.cs @ 15344

Last change on this file since 15344 was 9262, checked in by sluengo, 12 years ago
File size: 2.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
6using HeuristicLab.Core;
7using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
8using HeuristicLab.Problems.DataAnalysis.Symbolic;
9using HeuristicLab.Data;
10using HeuristicLab.Common;
11using HeuristicLab.Problems.DataAnalysis;
12using HeuristicLab.Optimization;
13
14namespace HeuristicLab.Problems.TradeRules
15{
16    [StorableClass]
17    [Item(Name = "TradingRulesSolution", Description = "Represents a trade rules solution (model + data) and attributes of the solution like cash earned")]
18    public sealed class TradingRulesSolution : TradeRulesSolution, ISymbolicRegressionSolution
19    {
20    private const string ModelLengthResultName = "Model Length";
21    private const string ModelDepthResultName = "Model Depth";
22
23    public new ISymbolicRegressionModel Model {
24      get { return (ISymbolicRegressionModel)base.Model; }
25      set { base.Model = value; }
26    }
27    ISymbolicDataAnalysisModel ISymbolicDataAnalysisSolution.Model {
28      get { return (ISymbolicDataAnalysisModel)base.Model; }
29    }
30    public int ModelLength {
31      get { return ((IntValue)this[ModelLengthResultName].Value).Value; }
32      private set { ((IntValue)this[ModelLengthResultName].Value).Value = value; }
33    }
34
35    public int ModelDepth {
36      get { return ((IntValue)this[ModelDepthResultName].Value).Value; }
37      private set { ((IntValue)this[ModelDepthResultName].Value).Value = value; }
38    }
39
40    [StorableConstructor]
41    private TradingRulesSolution(bool deserializing) : base(deserializing) { }
42    private TradingRulesSolution(TradingRulesSolution original, Cloner cloner)
43      : base(original, cloner) {
44    }
45    public TradingRulesSolution(ISymbolicRegressionModel model, IRegressionProblemData problemData)
46      : base(model, problemData) {
47      Add(new Result(ModelLengthResultName, "Length of the symbolic regression model.", new IntValue()));
48      Add(new Result(ModelDepthResultName, "Depth of the symbolic regression model.", new IntValue()));
49      RecalculateResults();
50    }
51
52    public override IDeepCloneable Clone(Cloner cloner) {
53        return new TradingRulesSolution(this, cloner);
54    }
55
56    protected override void RecalculateResults() {
57      base.RecalculateResults();
58      ModelLength = Model.SymbolicExpressionTree.Length;
59      ModelDepth = Model.SymbolicExpressionTree.Depth;
60    }
61    }
62}
Note: See TracBrowser for help on using the repository browser.