Changeset 5275 for branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionModel.cs
- Timestamp:
- 01/11/11 15:03:46 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionModel.cs
r4068 r5275 32 32 [StorableClass] 33 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 34 public sealed class SymbolicRegressionModel : NamedItem, IDataAnalysisModel { 36 35 [StorableConstructor] 37 protected SymbolicRegressionModel(bool deserializing) 38 : base(deserializing) { 36 private SymbolicRegressionModel(bool deserializing) : base(deserializing) { } 37 private SymbolicRegressionModel(SymbolicRegressionModel original, Cloner cloner) 38 : base(original, cloner) { 39 tree = (SymbolicExpressionTree)cloner.Clone(original.tree); 40 interpreter = (ISymbolicExpressionTreeInterpreter)cloner.Clone(original.interpreter); 41 inputVariables = new List<string>(original.inputVariables); 39 42 } 43 40 44 public SymbolicRegressionModel(ISymbolicExpressionTreeInterpreter interpreter, SymbolicExpressionTree tree) 41 45 : base() { … … 43 47 this.interpreter = interpreter; 44 48 this.inputVariables = tree.IterateNodesPrefix().OfType<VariableTreeNode>().Select(var => var.VariableName).Distinct().ToList(); 49 } 50 51 public override IDeepCloneable Clone(Cloner cloner) { 52 return new SymbolicRegressionModel(this, cloner); 53 } 54 55 [StorableHook(HookType.AfterDeserialization)] 56 private void AfterDeserialization() { 57 if (inputVariables == null) 58 this.inputVariables = tree.IterateNodesPrefix().OfType<VariableTreeNode>().Select(var => var.VariableName).Distinct().ToList(); 45 59 } 46 60 … … 62 76 63 77 public IEnumerable<double> GetEstimatedValues(DataAnalysisProblemData problemData, int start, int end) { 64 return interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, Enumerable.Range(start, end - start));78 return GetEstimatedValues(problemData, Enumerable.Range(start, end - start)); 65 79 } 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; 80 public IEnumerable<double> GetEstimatedValues(DataAnalysisProblemData problemData, IEnumerable<int> rows) { 81 return interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, rows); 73 82 } 74 83 }
Note: See TracChangeset
for help on using the changeset viewer.