Changeset 7677 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveEvaluator.cs
- Timestamp:
- 03/30/12 22:48:32 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveEvaluator.cs
r7672 r7677 20 20 #endregion 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 54 55 } 55 56 } 57 58 [ThreadStatic] 59 private static double[] cache; 60 61 protected static void CalculateWithScaling(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, IOnlineCalculator calculator, int maxRows) { 62 if (cache == null || cache.GetLength(0) < maxRows) { 63 cache = new double[maxRows]; 64 } 65 66 //calculate linear scaling 67 //the static methods of the calculator could not be used as it performs a check if the enumerators have an equal amount of elements 68 //this is not true if the cache is used 69 int i = 0; 70 var linearScalingCalculator = new OnlineLinearScalingParameterCalculator(); 71 var targetValuesEnumerator = targetValues.GetEnumerator(); 72 var estimatedValuesEnumerator = estimatedValues.GetEnumerator(); 73 while (targetValuesEnumerator.MoveNext() && estimatedValuesEnumerator.MoveNext()) { 74 double target = targetValuesEnumerator.Current; 75 double estimated = estimatedValuesEnumerator.Current; 76 cache[i] = estimated; 77 linearScalingCalculator.Add(estimated, target); 78 i++; 79 } 80 double alpha = linearScalingCalculator.Alpha; 81 double beta = linearScalingCalculator.Beta; 82 83 //calculate the quality by using the passed online calculator 84 targetValuesEnumerator = targetValues.GetEnumerator(); 85 i = 0; 86 while (targetValuesEnumerator.MoveNext()) { 87 double target = targetValuesEnumerator.Current; 88 double estimated = cache[i] * beta + alpha; 89 calculator.Add(target, estimated); 90 i++; 91 } 92 } 56 93 } 57 94 }
Note: See TracChangeset
for help on using the changeset viewer.