Index: /trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs
===================================================================
--- /trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs	(revision 14903)
+++ /trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs	(revision 14904)
@@ -40,4 +40,6 @@
   [StorableClass]
   public sealed class CrossValidation : ParameterizedNamedItem, IAlgorithm, IStorableContent {
+    private IDataAnalysisProblemData shuffledProblemData;
+
     public CrossValidation()
       : base() {
@@ -315,4 +317,12 @@
             clonedAlgorithms.Add(clonedAlgorithm);
           }
+          // save the shuffled problem data because it is necessary when creating the ensemble solution
+          if (shuffledProblemData == null && shuffledDataset != null) {
+            var dataAnalysisProblem = (IDataAnalysisProblem)algorithm.Problem;
+            var dataset = (Dataset)dataAnalysisProblem.ProblemData.Dataset;
+            var cloner = new Cloner();
+            cloner.RegisterClonedObject(dataset, shuffledDataset);
+            shuffledProblemData = cloner.Clone(dataAnalysisProblem.ProblemData);
+          }
         }
 
@@ -436,5 +446,7 @@
         // clone manually to correctly clone references between cloned root objects 
         Cloner cloner = new Cloner();
-        var problemDataClone = (IRegressionProblemData)cloner.Clone(Problem.ProblemData);
+        var problemDataClone = ShuffleSamples.Value
+          ? (IRegressionProblemData)cloner.Clone(shuffledProblemData)
+          : (IRegressionProblemData)cloner.Clone(Problem.ProblemData);
         // set partitions of problem data clone correctly
         problemDataClone.TrainingPartition.Start = SamplesStart.Value; problemDataClone.TrainingPartition.End = SamplesEnd.Value;
@@ -467,6 +479,7 @@
         // at least one algorithm (GBT with logistic regression loss) produces a classification solution even though the original problem is a regression problem.
         var targetVariable = solutions.Value.First().ProblemData.TargetVariable;
-        var problemDataClone = new ClassificationProblemData(Problem.ProblemData.Dataset,
-          Problem.ProblemData.AllowedInputVariables, targetVariable);
+        var problemDataClone = ShuffleSamples.Value
+          ? new ClassificationProblemData(shuffledProblemData.Dataset, shuffledProblemData.AllowedInputVariables, targetVariable)
+          : new ClassificationProblemData(Problem.ProblemData.Dataset, Problem.ProblemData.AllowedInputVariables, targetVariable);
         // set partitions of problem data clone correctly
         problemDataClone.TrainingPartition.Start = SamplesStart.Value; problemDataClone.TrainingPartition.End = SamplesEnd.Value;
@@ -551,10 +564,16 @@
       algorithm.ProblemChanged += new EventHandler(Algorithm_ProblemChanged);
       algorithm.ExecutionStateChanged += new EventHandler(Algorithm_ExecutionStateChanged);
-      if (Problem != null) Problem.Reset += new EventHandler(Problem_Reset);
+      if (Problem != null) {
+        Problem.Reset += new EventHandler(Problem_Reset);
+        Problem.ProblemDataChanged += Problem_ProblemDataChanged;
+      }
     }
     private void DeregisterAlgorithmEvents() {
       algorithm.ProblemChanged -= new EventHandler(Algorithm_ProblemChanged);
       algorithm.ExecutionStateChanged -= new EventHandler(Algorithm_ExecutionStateChanged);
-      if (Problem != null) Problem.Reset -= new EventHandler(Problem_Reset);
+      if (Problem != null) {
+        Problem.Reset -= new EventHandler(Problem_Reset);
+        Problem.ProblemDataChanged -= Problem_ProblemDataChanged;
+      }
     }
     private void Algorithm_ProblemChanged(object sender, EventArgs e) {
@@ -574,9 +593,16 @@
       ConfigureProblem();
     }
-
+    public event EventHandler ProblemDataChanged;
+    private void OnProblemDataChanged() {
+      var handler = ProblemDataChanged;
+      if (handler != null) handler(this, EventArgs.Empty);
+      shuffledProblemData = null;
+    }
+    private void Problem_ProblemDataChanged(object sender, EventArgs e) {
+      OnProblemDataChanged();
+    }
     private void Problem_Reset(object sender, EventArgs e) {
       ConfigureProblem();
     }
-
     private void ConfigureProblem() {
       SamplesStart.Value = 0;
