- Timestamp:
- 07/28/11 13:57:05 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs
r6602 r6606 31 31 [StorableClass] 32 32 public abstract class RegressionSolution : RegressionSolutionBase { 33 protected readonly Dictionary<int, double> evaluationCache; 34 33 35 [StorableConstructor] 34 protected RegressionSolution(bool deserializing) : base(deserializing) { } 36 protected RegressionSolution(bool deserializing) 37 : base(deserializing) { 38 evaluationCache = new Dictionary<int, double>(); 39 } 35 40 protected RegressionSolution(RegressionSolution original, Cloner cloner) 36 41 : base(original, cloner) { 42 evaluationCache = new Dictionary<int, double>(original.evaluationCache); 37 43 } 38 44 protected RegressionSolution(IRegressionModel model, IRegressionProblemData problemData) 39 45 : base(model, problemData) { 46 evaluationCache = new Dictionary<int, double>(); 40 47 } 41 48 … … 55 62 56 63 public override IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows) { 57 return Model.GetEstimatedValues(ProblemData.Dataset, rows); 64 var rowsToEvaluate = rows.Except(evaluationCache.Keys); 65 var rowsEnumerator = rowsToEvaluate.GetEnumerator(); 66 var valuesEnumerator = Model.GetEstimatedValues(ProblemData.Dataset, rowsToEvaluate).GetEnumerator(); 67 68 while (rowsEnumerator.MoveNext() & valuesEnumerator.MoveNext()) { 69 evaluationCache.Add(rowsEnumerator.Current, valuesEnumerator.Current); 70 } 71 72 return rows.Select(row => evaluationCache[row]); 73 } 74 75 protected override void OnProblemDataChanged() { 76 evaluationCache.Clear(); 77 base.OnProblemDataChanged(); 78 } 79 80 protected override void OnModelChanged() { 81 evaluationCache.Clear(); 82 base.OnModelChanged(); 58 83 } 59 84 }
Note: See TracChangeset
for help on using the changeset viewer.