Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs	(revision 2577)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs	(revision 2578)
@@ -22,4 +22,10 @@
 using HeuristicLab.Core;
 using HeuristicLab.Data;
+using System;
+using HeuristicLab.GP.Interfaces;
+using HeuristicLab.DataAnalysis;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -39,5 +45,5 @@
 
     // evaluates the function-tree for the given target-variable and the whole dataset and returns the MSE
-    public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) {
+    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
       double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, true).Data;
       DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false);
@@ -46,22 +52,22 @@
         scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MSE"), mse));
       }
-
       double errorsSquaredSum = 0;
       int rows = end - start;
       int n = 0;
-      for (int sample = start; sample < end; sample++) {
-        double estimated = evaluator.Evaluate(sample);
+      int sample = start;
+      foreach (var estimatedValue in evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start))) {
         double original = dataset.GetValue(sample, targetVariable);
-        
+
         if (!double.IsNaN(original) && !double.IsInfinity(original)) {
-          double error = estimated - original;
+          double error = estimatedValue - original;
           errorsSquaredSum += error * error;
           n++;
         }
-        // check the limit and stop as soon as we hit the limit
-        if (errorsSquaredSum / rows >= qualityLimit) {
+        // check the limit every 30 samples and stop as soon as we hit the limit
+        if (n % 30 == 29 && errorsSquaredSum / rows >= qualityLimit) {
           mse.Data = errorsSquaredSum / (n + 1); // return estimated MSE (when the remaining errors are on average the same)
           return;
         }
+        sample++;
       }
       errorsSquaredSum /= n;
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs	(revision 2577)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/GPEvaluatorBase.cs	(revision 2578)
@@ -46,8 +46,7 @@
       int start = GetVariableValue<IntData>("SamplesStart", scope, true).Data;
       int end = GetVariableValue<IntData>("SamplesEnd", scope, true).Data;
+
       ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true);
-      
-      evaluator.PrepareForEvaluation(dataset, gpModel.FunctionTree);
-      Evaluate(scope, evaluator, dataset, targetVariable, start, end);
+      Evaluate(scope, gpModel.FunctionTree, evaluator, dataset, targetVariable, start, end);
 
       // update the value of total evaluated nodes
@@ -56,5 +55,5 @@
     }
 
-    public abstract void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end);
+    public abstract void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end);
   }
 }
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/NodeBasedVariableImpactCalculator.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/NodeBasedVariableImpactCalculator.cs	(revision 2577)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/NodeBasedVariableImpactCalculator.cs	(revision 2578)
@@ -138,10 +138,8 @@
 
     private static double CalculateMSE(Dataset dataset, ITreeEvaluator evaluator, IFunctionTree tree, int targetVariable, int start, int end) {
-      double[,] values = new double[end - start, 2];
-      evaluator.PrepareForEvaluation(dataset, tree);
-      for (int i = start; i < end; i++) {
-        values[i - start, 0] = dataset.GetValue(i, targetVariable);
-        values[i - start, 1] = evaluator.Evaluate(i);
-      }
+
+      double[,] values = Matrix<double>.Create(
+        dataset.GetVariableValues(targetVariable, start, end),
+        evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray());
       return SimpleMSEEvaluator.Calculate(values);
     }
@@ -155,10 +153,5 @@
 
     private static double CalculateReplacementValue(Dataset dataset, ITreeEvaluator evaluator, IFunctionTree tree, int targetVariable, int start, int end) {
-      double[] values = new double[end - start];
-      evaluator.PrepareForEvaluation(dataset, tree);
-      for (int i = start; i < end; i++) {
-        values[i - start] = evaluator.Evaluate(i);
-      }
-      return Statistics.Median(values);
+      return Statistics.Median(evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray());
     }
 
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleEvaluator.cs	(revision 2577)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleEvaluator.cs	(revision 2578)
@@ -23,4 +23,7 @@
 using HeuristicLab.Data;
 using HeuristicLab.DataAnalysis;
+using HeuristicLab.GP.Interfaces;
+using HeuristicLab.Modeling;
+using System.Linq;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -31,5 +34,5 @@
     }
 
-    public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
+    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
       DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, false, false);
       if (values == null) {
@@ -42,13 +45,7 @@
       }
 
-      double[,] v = new double[end - start, 2];
-
-      for (int sample = start; sample < end; sample++) {
-        double estimated = evaluator.Evaluate(sample);
-        double original = dataset.GetValue(sample, targetVariable);
-        
-        v[sample - start, 0] = original;
-        v[sample - start, 1] = estimated;
-      }
+      double[,] v = Matrix<double>.Create(
+        dataset.GetVariableValues(targetVariable, start, end),
+        evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray());
       values.Data = v;
     }
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleGPEvaluatorBase.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleGPEvaluatorBase.cs	(revision 2577)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/SimpleGPEvaluatorBase.cs	(revision 2578)
@@ -23,4 +23,7 @@
 using HeuristicLab.Data;
 using HeuristicLab.DataAnalysis;
+using HeuristicLab.Modeling;
+using HeuristicLab.GP.Interfaces;
+using System.Linq;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -33,14 +36,9 @@
     }
 
-    public override void Evaluate(IScope scope, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
+    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end) {
       // store original and estimated values in a double array
-      double[,] values = new double[end - start, 2];
-      for (int sample = start; sample < end; sample++) {
-        double original = dataset.GetValue(sample, targetVariable);
-        double estimated = evaluator.Evaluate(sample);
-        
-        values[sample - start, 0] = estimated;
-        values[sample - start, 1] = original;
-      }
+      double[,] values = Matrix<double>.Create(
+        dataset.GetVariableValues(targetVariable, start, end),
+        evaluator.Evaluate(dataset, tree, Enumerable.Range(start, end - start)).ToArray());
 
       double quality = Evaluate(values);
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/UncertainMeanSquaredErrorEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/UncertainMeanSquaredErrorEvaluator.cs	(revision 2577)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/UncertainMeanSquaredErrorEvaluator.cs	(revision 2578)
@@ -24,4 +24,7 @@
 using HeuristicLab.Data;
 using HeuristicLab.Random;
+using HeuristicLab.GP.Interfaces;
+using System.Collections.Generic;
+using System.Linq;
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -45,5 +48,5 @@
 
     // evaluates the function-tree for the given target-variable and the whole dataset and returns the MSE
-    public override void Evaluate(IScope scope, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) {
+    public override void Evaluate(IScope scope, IFunctionTree tree, ITreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, int start, int end) {
       double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, true).Data;
       int minSamples = GetVariableValue<IntData>("MinEvaluatedSamples", scope, true).Data;
@@ -72,6 +75,6 @@
       int[] indexes = InitIndexes(mt, start, end);
       int n = 0;
-      for (int sample = 0; sample < rows; sample++) {
-        double estimated = evaluator.Evaluate(indexes[sample]);
+      int sample = 0;
+      foreach (double estimated in evaluator.Evaluate(dataset, tree, indexes)) {
         double original = dataset.GetValue(indexes[sample], targetVariable);
         if (!double.IsNaN(original) && !double.IsInfinity(original)) {
@@ -91,4 +94,5 @@
           }
         }
+        sample++;
       }
 
