[9262] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 6 | using HeuristicLab.Core;
|
---|
| 7 | using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
|
---|
| 8 | using HeuristicLab.Problems.DataAnalysis.Symbolic;
|
---|
| 9 | using HeuristicLab.Data;
|
---|
| 10 | using HeuristicLab.Common;
|
---|
| 11 | using HeuristicLab.Problems.DataAnalysis;
|
---|
| 12 | using HeuristicLab.Optimization;
|
---|
| 13 |
|
---|
| 14 | namespace 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 | }
|
---|