Index: /branches/HeuristicLab.OSGAEvaluator/HeuristicLab.OSGAEvaluator/SymbolicRegressionSingleObjectiveOSGAEvaluator.cs
===================================================================
--- /branches/HeuristicLab.OSGAEvaluator/HeuristicLab.OSGAEvaluator/SymbolicRegressionSingleObjectiveOSGAEvaluator.cs	(revision 14183)
+++ /branches/HeuristicLab.OSGAEvaluator/HeuristicLab.OSGAEvaluator/SymbolicRegressionSingleObjectiveOSGAEvaluator.cs	(revision 14184)
@@ -171,48 +171,7 @@
 
     private double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, DoubleLimit estimationLimits, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling) {
-      var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToList();
+      var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).LimitToRange(estimationLimits.Lower, estimationLimits.Upper);
       var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
-      IEnumerator<double> targetValuesEnumerator;
-
-      double alpha = 0, beta = 1;
-      if (applyLinearScaling) {
-        var linearScalingCalculator = new OnlineLinearScalingParameterCalculator();
-        targetValuesEnumerator = targetValues.GetEnumerator();
-        var estimatedValuesEnumerator = estimatedValues.GetEnumerator();
-        while (targetValuesEnumerator.MoveNext() & estimatedValuesEnumerator.MoveNext()) {
-          double target = targetValuesEnumerator.Current;
-          double estimated = estimatedValuesEnumerator.Current;
-          if (!double.IsNaN(estimated) && !double.IsInfinity(estimated))
-            linearScalingCalculator.Add(estimated, target);
-        }
-        if (linearScalingCalculator.ErrorState == OnlineCalculatorError.None && (targetValuesEnumerator.MoveNext() || estimatedValuesEnumerator.MoveNext()))
-          throw new ArgumentException("Number of elements in target and estimated values enumeration do not match.");
-
-        alpha = linearScalingCalculator.Alpha;
-        beta = linearScalingCalculator.Beta;
-        if (linearScalingCalculator.ErrorState != OnlineCalculatorError.None) {
-          alpha = 0.0;
-          beta = 1.0;
-        }
-      }
-      var scaledEstimatedValuesEnumerator = estimatedValues.Select(x => x * beta + alpha).LimitToRange(estimationLimits.Lower, estimationLimits.Upper).GetEnumerator();
-      targetValuesEnumerator = targetValues.GetEnumerator();
-
-      var pearsonRCalculator = new OnlinePearsonsRCalculator();
-
-      var interval = (int)Math.Floor(problemData.TrainingPartition.Size * RelativeFitnessEvaluationIntervalSize);
-      var i = problemData.TrainingPartition.Start;
-      var trainingEnd = problemData.TrainingPartition.End;
-      var qualityPerInterval = new List<double>();
-      while (targetValuesEnumerator.MoveNext() && scaledEstimatedValuesEnumerator.MoveNext()) {
-        pearsonRCalculator.Add(targetValuesEnumerator.Current, scaledEstimatedValuesEnumerator.Current);
-        ++i;
-        if (i % interval == 0 || i == trainingEnd) {
-          var q = pearsonRCalculator.ErrorState != OnlineCalculatorError.None ? double.NaN : pearsonRCalculator.R;
-          qualityPerInterval.Add(q * q);
-        }
-      }
-      var r = pearsonRCalculator.ErrorState != OnlineCalculatorError.None ? double.NaN : pearsonRCalculator.R;
-      var actualQuality = r * r;
+
       var parentQualities = ParentQualitiesParameter.ActualValue.Select(x => x.Value);
       var minQuality = parentQualities.Min();
@@ -222,41 +181,24 @@
       var threshold = parentQuality * RelativeParentChildQualityThreshold;
 
-      bool predictedRejected = false;
-
-      i = 0;
-      foreach (var q in qualityPerInterval) {
-        if (double.IsNaN(q) || !(q > threshold)) {
-          predictedRejected = true;
-          break;
+      var pearsonRCalculator = new OnlinePearsonsRCalculator();
+      var targetValuesEnumerator = targetValues.GetEnumerator();
+      var estimatedValuesEnumerator = estimatedValues.GetEnumerator();
+
+      var i = 0;
+      var trainingPartitionSize = problemData.TrainingPartition.Size;
+      var interval = (int)Math.Floor(trainingPartitionSize * RelativeFitnessEvaluationIntervalSize);
+      while (targetValuesEnumerator.MoveNext() && estimatedValuesEnumerator.MoveNext()) {
+        pearsonRCalculator.Add(targetValuesEnumerator.Current, estimatedValuesEnumerator.Current);
+        ++i;
+        if (i % interval == 0 || i == trainingPartitionSize) {
+          var q = pearsonRCalculator.ErrorState != OnlineCalculatorError.None ? double.NaN : pearsonRCalculator.R;
+          var quality = q * q;
+          if (!(quality > threshold))
+            return quality;
         }
-        ++i;
       }
-
-      var actuallyRejected = !(actualQuality > parentQuality);
-
-      if (RejectedStats.Rows == 0 || TotalStats.Rows == 0) {
-        RejectedStats = new IntMatrix(2, qualityPerInterval.Count);
-        RejectedStats.RowNames = new[] { "Predicted", "Actual" };
-        RejectedStats.ColumnNames = Enumerable.Range(1, RejectedStats.Columns).Select(x => string.Format("0-{0}", Math.Min(trainingEnd, x * interval)));
-        TotalStats = new IntMatrix(2, 2);
-        TotalStats.RowNames = new[] { "Predicted", "Actual" };
-        TotalStats.ColumnNames = new[] { "Rejected", "Not Rejected" };
-      }
-      // gather some statistics
-      if (predictedRejected) {
-        RejectedStats[0, i]++;
-        TotalStats[0, 0]++;
-      } else {
-        TotalStats[0, 1]++;
-      }
-      if (actuallyRejected) {
-        TotalStats[1, 0]++;
-      } else {
-        TotalStats[1, 1]++;
-      }
-      if (predictedRejected && actuallyRejected) {
-        RejectedStats[1, i]++;
-      }
-      return r * r;
+      var r = pearsonRCalculator.ErrorState != OnlineCalculatorError.None ? double.NaN : pearsonRCalculator.R;
+      var actualQuality = r * r;
+      return actualQuality;
     }
 
