Index: trunk/sources/HeuristicLab.StructureIdentification/Evaluation/EarlyStoppingMeanSquaredErrorEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Evaluation/EarlyStoppingMeanSquaredErrorEvaluator.cs	(revision 332)
+++ trunk/sources/HeuristicLab.StructureIdentification/Evaluation/EarlyStoppingMeanSquaredErrorEvaluator.cs	(revision 334)
@@ -49,13 +49,16 @@
       double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, false).Data;
       bool useEstimatedValues = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, false).Data;
+      int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
+      int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
+      int rows = trainingEnd-trainingStart;
       if(useEstimatedValues && backupValues == null) {
-        backupValues = new double[dataset.Rows];
-        for(int i = 0; i < dataset.Rows; i++) {
-          backupValues[i] = dataset.GetValue(i, targetVariable);
+        backupValues = new double[rows];
+        for(int i = trainingStart; i < trainingEnd; i++) {
+          backupValues[i-trainingStart] = dataset.GetValue(i, targetVariable);
         }
       }
       double errorsSquaredSum = 0;
       double targetMean = dataset.GetMean(targetVariable);
-      for(int sample = 0; sample < dataset.Rows; sample++) {
+      for(int sample = trainingStart; sample < trainingEnd; sample++) {
         double estimated = functionTree.Evaluate(dataset, sample);
         double original = dataset.GetValue(sample, targetVariable);
@@ -72,8 +75,8 @@
 
         // check the limit and stop as soon as we hit the limit
-        if(errorsSquaredSum / dataset.Rows >= qualityLimit) {
-          scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * sample+1;
-          if(useEstimatedValues) RestoreDataset(dataset, targetVariable, 0, sample);
-          return errorsSquaredSum / (sample + 1); // return estimated MSE (when the remaining errors are on average the same)
+        if(errorsSquaredSum / rows >= qualityLimit) {
+          scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (sample-trainingStart + 1);
+          if(useEstimatedValues) RestoreDataset(dataset, targetVariable, trainingStart, sample);
+          return errorsSquaredSum / (sample-trainingStart + 1); // return estimated MSE (when the remaining errors are on average the same)
         }
         if(useEstimatedValues) {
@@ -81,10 +84,10 @@
         }
       }
-      if(useEstimatedValues) RestoreDataset(dataset, targetVariable, 0, dataset.Rows);
-      errorsSquaredSum /= dataset.Rows;
+      if(useEstimatedValues) RestoreDataset(dataset, targetVariable, trainingStart, trainingEnd);
+      errorsSquaredSum /= rows;
       if(double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
         errorsSquaredSum = double.MaxValue;
       }
-      scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * dataset.Rows;
+      scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * rows;
       return errorsSquaredSum;
     }
@@ -92,5 +95,5 @@
     private void RestoreDataset(Dataset dataset, int targetVariable, int from, int to) {
       for(int i = from; i < to; i++) {
-        dataset.SetValue(i, targetVariable, backupValues[i]);
+        dataset.SetValue(i, targetVariable, backupValues[i-from]);
       }
     }
Index: trunk/sources/HeuristicLab.StructureIdentification/Evaluation/GPEvaluatorBase.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Evaluation/GPEvaluatorBase.cs	(revision 332)
+++ trunk/sources/HeuristicLab.StructureIdentification/Evaluation/GPEvaluatorBase.cs	(revision 334)
@@ -43,5 +43,7 @@
       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("TotalEvaluatedNodes", "Number of evaluated nodes", typeof(DoubleData), VariableKind.In | VariableKind.Out)); 
+      AddVariableInfo(new VariableInfo("TotalEvaluatedNodes", "Number of evaluated nodes", typeof(DoubleData), VariableKind.In | VariableKind.Out));
+      AddVariableInfo(new VariableInfo("TrainingSamplesStart", "Start index of training samples in dataset", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("TrainingSamplesEnd", "End index of training samples in dataset", typeof(IntData), VariableKind.In));
       AddVariableInfo(new VariableInfo("Quality", "The evaluated quality of the model", typeof(DoubleData), VariableKind.New));
     }
@@ -54,5 +56,4 @@
       this.treeSize = scope.GetVariableValue<IntData>("TreeSize", false).Data;
       this.totalEvaluatedNodes = scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data;
-
       double result = Evaluate(scope, functionTree, targetVariable, dataset);
       scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("Quality"), new DoubleData(result)));
Index: trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MeanSquaredErrorEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MeanSquaredErrorEvaluator.cs	(revision 332)
+++ trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MeanSquaredErrorEvaluator.cs	(revision 334)
@@ -51,12 +51,14 @@
       double targetMean = dataset.GetMean(targetVariable);
       bool useEstimatedValues = GetVariableValue<BoolData>("UseEstimatedTargetValue", scope, false).Data;
+      int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
+      int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
       if(useEstimatedValues && backupValues == null) {
-        backupValues = new double[dataset.Rows];
-        for(int i = 0; i < dataset.Rows; i++) {
-          backupValues[i] = dataset.GetValue(i, targetVariable);
+        backupValues = new double[trainingEnd - trainingStart];
+        for(int i = trainingStart; i < trainingEnd; i++) {
+          backupValues[i-trainingStart] = dataset.GetValue(i, targetVariable);
         }
       }
 
-      for(int sample = 0; sample < dataset.Rows; sample++) {
+      for(int sample = trainingStart; sample < trainingEnd; sample++) {
         double estimated = functionTree.Evaluate(dataset, sample);
         double original = dataset.GetValue(sample, targetVariable);
@@ -75,16 +77,16 @@
       }
 
-      if(useEstimatedValues) RestoreDataset(dataset, targetVariable);
-      errorsSquaredSum /= dataset.Rows;
+      if(useEstimatedValues) RestoreDataset(dataset, targetVariable, trainingStart, trainingEnd);
+      errorsSquaredSum /= (trainingEnd-trainingStart);
       if(double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
         errorsSquaredSum = double.MaxValue;
       }
-      scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * dataset.Rows;
+      scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (trainingEnd-trainingStart);
       return errorsSquaredSum;
     }
 
-    private void RestoreDataset(Dataset dataset, int targetVariable) {
-      for(int i = 0; i < dataset.Rows; i++) {
-        dataset.SetValue(i, targetVariable, backupValues[i]);
+    private void RestoreDataset(Dataset dataset, int targetVariable, int from, int to) {
+      for(int i = from; i < to; i++) {
+        dataset.SetValue(i, targetVariable, backupValues[i-from]);
       }
     }
