Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionModel.cs @ 5211

Last change on this file since 5211 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 3.1 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.Collections.Generic;
23using System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28using HeuristicLab.Problems.DataAnalysis.Symbolic;
29using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
30
31namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
32  [StorableClass]
33  [Item("SymbolicRegressionModel", "A symbolic regression model represents an entity that provides estimated values based on input values.")]
34  public class SymbolicRegressionModel : NamedItem, IDataAnalysisModel {
35    private SymbolicRegressionModel() : base() { } // for cloning
36    [StorableConstructor]
37    protected SymbolicRegressionModel(bool deserializing)
38      : base(deserializing) {
39    }
40    public SymbolicRegressionModel(ISymbolicExpressionTreeInterpreter interpreter, SymbolicExpressionTree tree)
41      : base() {
42      this.tree = tree;
43      this.interpreter = interpreter;
44      this.inputVariables = tree.IterateNodesPrefix().OfType<VariableTreeNode>().Select(var => var.VariableName).Distinct().ToList();
45    }
46
47    [Storable]
48    private SymbolicExpressionTree tree;
49    public SymbolicExpressionTree SymbolicExpressionTree {
50      get { return tree; }
51    }
52    [Storable]
53    private ISymbolicExpressionTreeInterpreter interpreter;
54    public ISymbolicExpressionTreeInterpreter Interpreter {
55      get { return interpreter; }
56    }
57    [Storable]
58    private List<string> inputVariables;
59    public IEnumerable<string> InputVariables {
60      get { return inputVariables.AsEnumerable(); }
61    }
62
63    public IEnumerable<double> GetEstimatedValues(DataAnalysisProblemData problemData, int start, int end) {
64      return interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, Enumerable.Range(start, end - start));
65    }
66
67    public override IDeepCloneable Clone(Cloner cloner) {
68      var clone = (SymbolicRegressionModel)base.Clone(cloner);
69      clone.tree = (SymbolicExpressionTree)cloner.Clone(tree);
70      clone.interpreter = (ISymbolicExpressionTreeInterpreter)cloner.Clone(interpreter);
71      clone.inputVariables = new List<string>(inputVariables);
72      return clone;
73    }
74  }
75}
Note: See TracBrowser for help on using the repository browser.