Index: trunk/sources/HeuristicLab.StructureIdentification/Evaluation/CoefficientOfDeterminationEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Evaluation/CoefficientOfDeterminationEvaluator.cs	(revision 91)
+++ trunk/sources/HeuristicLab.StructureIdentification/Evaluation/CoefficientOfDeterminationEvaluator.cs	(revision 128)
@@ -31,61 +31,23 @@
 
 namespace HeuristicLab.StructureIdentification {
-  public class CoefficientOfDeterminationEvaluator : OperatorBase {
+  public class CoefficientOfDeterminationEvaluator : GPEvaluatorBase {
     public override string Description {
-      get { return @"Applies 'OperatorTree' to samples 'FirstSampleIndex' - 'LastSampleIndex' (inclusive) of 'Dataset' and calculates
-the 'coefficient of determination' of estimated values vs. real values of 'TargetVariable'."; }
+      get {
+        return @"Applies 'OperatorTree' to all samples of 'Dataset' and calculates
+the 'coefficient of determination' of estimated values vs. real values of 'TargetVariable'.";
+      }
     }
 
     public CoefficientOfDeterminationEvaluator()
       : base() {
-      AddVariableInfo(new VariableInfo("OperatorTree", "The function tree that should be evaluated", typeof(IFunction), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TargetVariable", "Index of the target variable in the dataset", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FirstSampleIndex", "Index of the first row of the dataset on which the function should be evaluated", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("LastSampleIndex", "Index of the last row of the dataset on which the function should be evaluated (inclusive)", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("PunishmentFactor", "Punishment factor for invalid estimations", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("UseEstimatedTargetValues", "When the function tree contains the target variable this variable determines " +
-      "if we should use the estimated or the original values of the target variable in the evaluation", typeof(BoolData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Quality", "The coefficient of determination of the model", typeof(DoubleData), VariableKind.New));
-
     }
 
-
-    private double[] savedTargetVariable = new double[1];
-    public override IOperation Apply(IScope scope) {
-      int firstSampleIndex = GetVariableValue<IntData>("FirstSampleIndex", scope, true).Data;
-      int lastSampleIndex = GetVariableValue<IntData>("LastSampleIndex", scope, true).Data;
-
-      if(lastSampleIndex < firstSampleIndex) {
-        throw new InvalidProgramException();
-      }
-
-      IFunction function = GetVariableValue<IFunction>("OperatorTree", scope, true);
-
-      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
-
-      int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
-      bool useEstimatedTargetValues = GetVariableValue<BoolData>("UseEstimatedTargetValues", scope, true).Data;
-      double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data;
-
-      if(useEstimatedTargetValues && savedTargetVariable.Length != lastSampleIndex - firstSampleIndex + 1) {
-        savedTargetVariable = new double[lastSampleIndex - firstSampleIndex + 1];
-      }
-
-      double maximumPunishment = punishmentFactor * dataset.GetRange(targetVariable, firstSampleIndex, lastSampleIndex);
-
+    public override double Evaluate(IScope scope, IFunction function, int targetVariable, Dataset dataset) {
       double errorsSquaredSum = 0.0;
-      double originalsSum = 0.0;
-      double targetMean = dataset.GetMean(targetVariable, firstSampleIndex, lastSampleIndex);
-
-      for(int sample = firstSampleIndex; sample <= lastSampleIndex; sample++) {
+      double originalDeviationTotalSumOfSquares = 0.0;
+      double targetMean = dataset.GetMean(targetVariable);
+      for(int sample = 0; sample < dataset.Rows; sample++) {
         double estimated = function.Evaluate(dataset, sample);
         double original = dataset.GetValue(sample, targetVariable);
-
-        if(useEstimatedTargetValues) {
-          savedTargetVariable[sample - firstSampleIndex] = original;
-          dataset.SetValue(sample, targetVariable, estimated);
-        }
-
         if(!double.IsNaN(original) && !double.IsInfinity(original)) {
           if(double.IsNaN(estimated) || double.IsInfinity(estimated))
@@ -98,40 +60,15 @@
           double error = estimated - original;
           errorsSquaredSum += error * error;
-          originalsSum += original;
+
+          double origDeviation = original - targetMean;
+          originalDeviationTotalSumOfSquares += origDeviation * origDeviation;
         }
       }
-
-      double originalsMean = originalsSum / (lastSampleIndex - firstSampleIndex +1);
-      
-      double originalTotalSumOfSquares = 0.0;
-
-      for(int sample=0; sample <savedTargetVariable.Length; sample++) {
-        double original = savedTargetVariable[sample];
-
-        if(!double.IsInfinity(original) && !double.IsNaN(original)) {
-          original = original - originalsMean;
-          originalTotalSumOfSquares += original * original;
-        }
-      }
-
-      double quality = 1 - errorsSquaredSum / originalTotalSumOfSquares;
-
-      if(quality > 1) {
+      double quality = 1 - errorsSquaredSum / originalDeviationTotalSumOfSquares;
+      if(quality > 1) 
         throw new InvalidProgramException();
-      }
-
-      if(double.IsNaN(quality) || double.IsInfinity(quality)) {
+      if(double.IsNaN(quality) || double.IsInfinity(quality)) 
         quality = double.MaxValue;
-      }
-
-      if(useEstimatedTargetValues) {
-        // restore original values of the target variable
-        for(int sample = firstSampleIndex; sample <= lastSampleIndex; sample++) {
-          dataset.SetValue(sample, targetVariable, savedTargetVariable[sample - firstSampleIndex]);
-        }
-      }
-
-      scope.AddVariable(new HeuristicLab.Core.Variable("Quality", new DoubleData(quality)));
-      return null;
+      return quality;
     }
   }
Index: trunk/sources/HeuristicLab.StructureIdentification/Evaluation/EarlyStoppingMeanSquaredErrorEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Evaluation/EarlyStoppingMeanSquaredErrorEvaluator.cs	(revision 128)
+++ trunk/sources/HeuristicLab.StructureIdentification/Evaluation/EarlyStoppingMeanSquaredErrorEvaluator.cs	(revision 128)
@@ -0,0 +1,77 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Functions;
+using HeuristicLab.DataAnalysis;
+
+namespace HeuristicLab.StructureIdentification {
+  public class EarlyStoppingMeanSquaredErrorEvaluator : MeanSquaredErrorEvaluator {
+    public override string Description {
+      get {
+        return @"Evaluates 'OperatorTree' for samples 'FirstSampleIndex' - 'LastSampleIndex' (inclusive) and calculates the mean-squared-error
+for the estimated values vs. the real values of 'TargetVariable'.
+This operator stops the computation as soon as an upper limit for the mean-squared-error is reached.";
+      }
+    }
+
+    public EarlyStoppingMeanSquaredErrorEvaluator()
+      : base() {
+      AddVariableInfo(new VariableInfo("QualityLimit", "The upper limit of the MSE which is used as early stopping criterion.", typeof(DoubleData), VariableKind.New));
+    }
+
+    public override double Evaluate(IScope scope, IFunction function, int targetVariable, Dataset dataset) {
+      double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, true).Data;
+      double errorsSquaredSum = 0;
+      double targetMean = dataset.GetMean(targetVariable);
+      for(int sample = 0; sample < dataset.Rows; sample++) {
+        double estimated = function.Evaluate(dataset, sample);
+        double original = dataset.GetValue(sample, targetVariable);
+        if(double.IsNaN(estimated) || double.IsInfinity(estimated)) {
+          estimated = targetMean + maximumPunishment;
+        } else if(estimated > targetMean + maximumPunishment) {
+          estimated = targetMean + maximumPunishment;
+        } else if(estimated < targetMean - maximumPunishment) {
+          estimated = targetMean - maximumPunishment;
+        }
+        double error = estimated - original;
+        errorsSquaredSum += error * error;
+
+        // check the limit every 10 samples and stop as soon as we hit the limit
+        if(sample % 10 == 9)
+          if(qualityLimit < errorsSquaredSum / dataset.Rows ||
+            double.IsNaN(errorsSquaredSum) ||
+            double.IsInfinity(errorsSquaredSum)) return errorsSquaredSum;
+      }
+      errorsSquaredSum /= dataset.Rows;
+      if(double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
+        errorsSquaredSum = double.MaxValue;
+      }
+      return errorsSquaredSum;
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.StructureIdentification/Evaluation/FunctionEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Evaluation/FunctionEvaluator.cs	(revision 91)
+++ 	(revision )
@@ -1,66 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using System.Diagnostics;
-using HeuristicLab.Functions;
-using HeuristicLab.Operators;
-using HeuristicLab.DataAnalysis;
-
-namespace HeuristicLab.StructureIdentification {
-  public class FunctionEvaluator : OperatorBase {
-    public override string Description {
-      get { return @"Evaluates 'FunctionTree' on samples 'FirstSampleIndex' - 'LastSampleIndex' (inclusive) of
-'Dataset' and stores the results in array 'Results'."; }
-    }
-
-    public FunctionEvaluator()
-      : base() {
-      AddVariableInfo(new VariableInfo("FunctionTree", "The combined operator containing a function tree that should be evaluated", typeof(IFunction), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FirstSampleIndex", "Index of the first row of the dataSet on which the function should be evaluated", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("LastSampleIndex", "Index of the last row of the dataSet on which the function should be evaluated (inclusive)", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Results", "Array of results of the function for each sample", typeof(DoubleArrayData), VariableKind.New));
-    }
-
-    public override IOperation Apply(IScope scope) {
-
-      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
-      double[] results = new double[dataset.Rows];
-
-      IFunction function = GetVariableValue<IFunction>("FunctionTree", scope, true);
-
-      int firstIndex = GetVariableValue<IntData>("FirstSampleIndex", scope, true).Data;
-      int lastIndex = GetVariableValue<IntData>("LastSampleIndex", scope, true).Data;
-
-      for(int sample = firstIndex; sample <= lastIndex; sample++) {
-        results[sample] = function.Evaluate(dataset, sample);
-      }
-
-      scope.AddVariable(new HeuristicLab.Core.Variable("Results", new DoubleArrayData(results)));
-      return null;
-    }
-  }
-}
Index: trunk/sources/HeuristicLab.StructureIdentification/Evaluation/GPEvaluatorBase.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Evaluation/GPEvaluatorBase.cs	(revision 128)
+++ trunk/sources/HeuristicLab.StructureIdentification/Evaluation/GPEvaluatorBase.cs	(revision 128)
@@ -0,0 +1,58 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Functions;
+using HeuristicLab.DataAnalysis;
+
+namespace HeuristicLab.StructureIdentification {
+  public abstract class GPEvaluatorBase : OperatorBase {
+    protected double maximumPunishment;
+
+    public GPEvaluatorBase()
+      : base() {
+      AddVariableInfo(new VariableInfo("OperatorTree", "The function tree that should be evaluated", typeof(IFunction), VariableKind.In));
+      AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));
+      AddVariableInfo(new VariableInfo("TargetVariable", "Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("PunishmentFactor", "Punishment factor for invalid estimations", typeof(DoubleData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("Quality", "The evaluated quality of the model", typeof(DoubleData), VariableKind.New));
+    }
+
+    public override IOperation Apply(IScope scope) {
+      int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
+      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
+      IFunction function = GetVariableValue<IFunction>("OperatorTree", scope, true);
+      this.maximumPunishment = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data * dataset.GetRange(targetVariable);
+
+      double result = Evaluate(scope, function, targetVariable, dataset);
+      scope.AddVariable(new HeuristicLab.Core.Variable("Quality", new DoubleData(result)));
+      return null;
+    }
+
+    public abstract double Evaluate(IScope scope, IFunction function, int targetVariable, Dataset dataset);
+  }
+}
Index: trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MeanSquaredErrorEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MeanSquaredErrorEvaluator.cs	(revision 91)
+++ trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MeanSquaredErrorEvaluator.cs	(revision 128)
@@ -31,59 +31,22 @@
 
 namespace HeuristicLab.StructureIdentification {
-  public class MeanSquaredErrorEvaluator : OperatorBase {
+  public class MeanSquaredErrorEvaluator : GPEvaluatorBase {
     public override string Description {
-      get { return @"Evaluates 'OperatorTree' for samples 'FirstSampleIndex' - 'LastSampleIndex' (inclusive) and calculates the mean-squared-error
-for the estimated values vs. the real values of 'TargetVariable'."; }
+      get {
+        return @"Evaluates 'OperatorTree' for all samples of 'DataSet' and calculates the mean-squared-error
+for the estimated values vs. the real values of 'TargetVariable'.";
+      }
     }
 
     public MeanSquaredErrorEvaluator()
       : base() {
-      AddVariableInfo(new VariableInfo("OperatorTree", "The function tree that should be evaluated", typeof(IFunction), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TargetVariable", "Index of the column of the dataset that holds the target variable", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FirstSampleIndex", "Index of the first row of the dataset on which the function should be evaluated", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("LastSampleIndex", "Index of the last row of the dataset on which the function should be evaluated (inclusive)", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("PunishmentFactor", "Punishment factor for invalid estimations", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("UseEstimatedTargetValues", "When the function tree contains the target variable this variable determines " +
-      "if we should use the estimated or the original values of the target variable in the evaluation", typeof(BoolData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Quality", "The mean squared error of the model", typeof(DoubleData), VariableKind.New));
     }
 
-    private double[] savedTargetVariable = new double[0];
-
-    public override IOperation Apply(IScope scope) {
-
-      int firstSampleIndex = GetVariableValue<IntData>("FirstSampleIndex", scope, true).Data;
-      int lastSampleIndex = GetVariableValue<IntData>("LastSampleIndex", scope, true).Data;
-
-      if(firstSampleIndex >= lastSampleIndex) {
-        throw new InvalidProgramException();
-      }
-
-
-      int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
-      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
-
-      IFunction function = GetVariableValue<IFunction>("OperatorTree", scope, true);
-
+    public override double Evaluate(IScope scope, IFunction function, int targetVariable, Dataset dataset) {
       double errorsSquaredSum = 0;
-
-      double maximumPunishment = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data * dataset.GetRange(targetVariable, firstSampleIndex, lastSampleIndex);
-      double targetMean = dataset.GetMean(targetVariable, firstSampleIndex, lastSampleIndex);
-      bool useEstimatedValues = GetVariableValue<BoolData>("UseEstimatedTargetValues", scope, true).Data;
-
-      if(useEstimatedValues && savedTargetVariable.Length != lastSampleIndex - firstSampleIndex + 1) {
-        savedTargetVariable = new double[lastSampleIndex - firstSampleIndex + 1];
-      }
-      for(int sample = firstSampleIndex; sample <= lastSampleIndex; sample++) {
-
+      double targetMean = dataset.GetMean(targetVariable);
+      for(int sample = 0; sample < dataset.Rows; sample++) {
         double estimated = function.Evaluate(dataset, sample);
         double original = dataset.GetValue(sample, targetVariable);
-
-        if(useEstimatedValues) {
-          savedTargetVariable[sample - firstSampleIndex] = original;
-          dataset.SetValue(sample, targetVariable, estimated);
-        }
-
         if(double.IsNaN(estimated) || double.IsInfinity(estimated)) {
           estimated = targetMean + maximumPunishment;
@@ -93,23 +56,12 @@
           estimated = targetMean - maximumPunishment;
         }
-
         double error = estimated - original;
         errorsSquaredSum += error * error;
       }
-
-      errorsSquaredSum /= (lastSampleIndex - firstSampleIndex);
+      errorsSquaredSum /= dataset.Rows;
       if(double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
         errorsSquaredSum = double.MaxValue;
       }
-
-      if(useEstimatedValues) {
-        // restore original values of the target variable
-        for(int sample = firstSampleIndex; sample <= lastSampleIndex; sample++) {
-          dataset.SetValue(sample, targetVariable, savedTargetVariable[sample - firstSampleIndex]);
-        }
-      }
-
-      scope.AddVariable(new HeuristicLab.Core.Variable("Quality", new DoubleData(errorsSquaredSum)));
-      return null;
+      return errorsSquaredSum;
     }
   }
Index: trunk/sources/HeuristicLab.StructureIdentification/Evaluation/VarianceAccountedForEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Evaluation/VarianceAccountedForEvaluator.cs	(revision 91)
+++ trunk/sources/HeuristicLab.StructureIdentification/Evaluation/VarianceAccountedForEvaluator.cs	(revision 128)
@@ -31,12 +31,14 @@
 
 namespace HeuristicLab.StructureIdentification {
-  public class VarianceAccountedForEvaluator : OperatorBase {
+  public class VarianceAccountedForEvaluator : GPEvaluatorBase {
     public override string Description {
-      get { return @"Evaluates 'OperatorTree' for samples 'FirstSampleIndex' - 'LastSampleIndex' (inclusive) and calculates 
+      get {
+        return @"Evaluates 'OperatorTree' for all samples of 'DataSet' and calculates 
 the variance-accounted-for quality measure for the estimated values vs. the real values of 'TargetVariable'.
 
 The Variance Accounted For (VAF) function is computed as
 VAF(y,y') = ( 1 - var(y-y')/var(y) )
-where y' denotes the predicted / modelled values for y and var(x) the variance of a signal x."; }
+where y' denotes the predicted / modelled values for y and var(x) the variance of a signal x.";
+      }
     }
 
@@ -48,51 +50,14 @@
     public VarianceAccountedForEvaluator()
       : base() {
-      AddVariableInfo(new VariableInfo("OperatorTree", "The function tree that should be evaluated", typeof(IFunction), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Dataset", "Dataset with all samples on which to apply the function", typeof(Dataset), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TargetVariable", "Index of the target variable in the dataset", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("FirstSampleIndex", "Index of the first row of the dataset on which the function should be evaluated", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("LastSampleIndex", "Index of the last row of the dataset on which the function should be evaluated (inclusive)", typeof(IntData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("PunishmentFactor", "Punishment factor for invalid estimations", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("UseEstimatedTargetValues", "When the function tree contains the target variable this variable determines " +
-      "if we should use the estimated or the original values of the target variable in the evaluation", typeof(BoolData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Quality", "Variance accounted for quality of the model", typeof(DoubleData), VariableKind.New));
-
     }
 
 
-    private double[] originalTargetVariableValues = new double[1];
-    private double[] errors = new double[1];
-
-    public override IOperation Apply(IScope scope) {
-
-      int firstSampleIndex = GetVariableValue<IntData>("FirstSampleIndex", scope, true).Data;
-      int lastSampleIndex = GetVariableValue<IntData>("LastSampleIndex", scope, true).Data;
-
-      if(lastSampleIndex < firstSampleIndex) {
-        throw new InvalidProgramException();
-      }
-
-      IFunction function = GetVariableValue<IFunction>("OperatorTree", scope, true);
-
-      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
-
-      int targetVariable = GetVariableValue<IntData>("TargetVariable", scope, true).Data;
-      bool useEstimatedTargetValues = GetVariableValue<BoolData>("UseEstimatedTargetValues", scope, true).Data;
-      double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data;
-
-      if(originalTargetVariableValues.Length != lastSampleIndex - firstSampleIndex + 1) {
-        originalTargetVariableValues = new double[lastSampleIndex - firstSampleIndex + 1];
-        errors = new double[lastSampleIndex - firstSampleIndex + 1];
-      }
-
-      double maximumPunishment = punishmentFactor * dataset.GetRange(targetVariable, firstSampleIndex, lastSampleIndex);
-
-      double targetMean = dataset.GetMean(targetVariable, firstSampleIndex, lastSampleIndex);
-
-      for(int sample = firstSampleIndex; sample <= lastSampleIndex; sample++) {
-
+    public override double Evaluate(IScope scope, IFunction function, int targetVariable, Dataset dataset) {
+      double[] errors = new double[dataset.Rows];
+      double[] originalTargetVariableValues = new double[dataset.Rows];
+      double targetMean = dataset.GetMean(targetVariable);
+      for(int sample = 0; sample < dataset.Rows; sample++) {
         double estimated = function.Evaluate(dataset, sample);
-        double original =  dataset.GetValue(sample, targetVariable);
-
+        double original = dataset.GetValue(sample, targetVariable);
         if(!double.IsNaN(original) && !double.IsInfinity(original)) {
           if(double.IsNaN(estimated) || double.IsInfinity(estimated))
@@ -104,9 +69,6 @@
         }
 
-        errors[sample-firstSampleIndex] = original - estimated;
-        originalTargetVariableValues[sample-firstSampleIndex] = original;
-        if(useEstimatedTargetValues) {
-          dataset.SetValue(sample, targetVariable, estimated);
-        }
+        errors[sample] = original - estimated;
+        originalTargetVariableValues[sample] = original;
       }
 
@@ -118,14 +80,5 @@
         quality = double.MaxValue;
       }
-
-      if(useEstimatedTargetValues) {
-        // restore original values of the target variable
-        for(int sample = firstSampleIndex; sample <= lastSampleIndex; sample++) {
-          dataset.SetValue(sample, targetVariable, originalTargetVariableValues[sample - firstSampleIndex]);
-        }
-      }
-
-      scope.AddVariable(new HeuristicLab.Core.Variable("Quality", new DoubleData(quality)));
-      return null;
+      return quality;
     }
   }
Index: trunk/sources/HeuristicLab.StructureIdentification/HeuristicLab.StructureIdentification.csproj
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/HeuristicLab.StructureIdentification.csproj	(revision 91)
+++ trunk/sources/HeuristicLab.StructureIdentification/HeuristicLab.StructureIdentification.csproj	(revision 128)
@@ -49,7 +49,6 @@
   <ItemGroup>
     <Compile Include="Evaluation\CoefficientOfDeterminationEvaluator.cs" />
-    <Compile Include="Evaluation\FunctionEvaluator.cs">
-      <SubType>Code</SubType>
-    </Compile>
+    <Compile Include="Evaluation\GPEvaluatorBase.cs" />
+    <Compile Include="Evaluation\EarlyStoppingMeanSquaredErrorEvaluator.cs" />
     <Compile Include="Evaluation\MeanSquaredErrorEvaluator.cs" />
     <Compile Include="Evaluation\VarianceAccountedForEvaluator.cs" />
