Index: branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs
===================================================================
--- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs	(revision 7100)
+++ branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs	(revision 7154)
@@ -161,4 +161,5 @@
     protected void CalculateResults() {
       OnlineCalculatorError errorState;
+      string[] targetVariables = ProblemData.TargetVariables.ToArray();
       /*
       double[] estimatedTrainingValues = PrognosedTrainingValues.ToArray(); // cache values
@@ -193,67 +194,60 @@
               */
 
-      double[] trainingDs = new double[ProblemData.TargetVariables.Count()];
-      double[] testDs = new double[ProblemData.TargetVariables.Count()];
-
-      double[] trainingWds = new double[ProblemData.TargetVariables.Count()];
-      double[] testWds = new double[ProblemData.TargetVariables.Count()];
-
-      double[] trainingTheilsU = new double[ProblemData.TargetVariables.Count()];
-      double[] testTheilsU = new double[ProblemData.TargetVariables.Count()];
-      int i = 0;
-      var predictedContinuationTraining = PrognosedTrainingValues.ToArray();
-      var predictedContinuationTest = PrognosedTestValues.ToArray();
-
-      foreach (var targetVariable in ProblemData.TargetVariables) {
-        var actualTrainingValues = ProblemData.Dataset.GetDoubleValues(targetVariable, ProblemData.TrainingIndizes).ToArray();
-        var startTrainingValues = actualTrainingValues.Take(1);
-        // only one continuation (but the full training set)
-        var actualContinuationTraining = actualTrainingValues.Skip(1);
-
-        var actualTestValues = ProblemData.Dataset.GetDoubleValues(targetVariable, ProblemData.TestIndizes).ToArray();
-        var startTestValues = actualTestValues.Take(1);
-        // only one continuation (but the full training set)
-        var actualContinuationTest = actualTestValues.Skip(1);
-
-
-        trainingDs[i] = OnlineDirectionalSymmetryCalculator.Calculate(startTrainingValues,
-          Enumerable.Repeat(actualContinuationTraining, 1),
-          Enumerable.Repeat(predictedContinuationTraining[i], 1), out errorState);
-        if (errorState != OnlineCalculatorError.None) trainingDs[i] = double.NaN;
-
-        testDs[i] = OnlineDirectionalSymmetryCalculator.Calculate(startTestValues,
-          Enumerable.Repeat(actualContinuationTest, 1),
-          Enumerable.Repeat(predictedContinuationTest[i], 1), out errorState);
-        if (errorState != OnlineCalculatorError.None) testDs[i] = double.NaN;
-
-        trainingWds[i] =
-          OnlineWeightedDirectionalSymmetryCalculator.Calculate(startTrainingValues,
-          Enumerable.Repeat(actualContinuationTraining, 1),
-          Enumerable.Repeat(predictedContinuationTraining[i], 1), out errorState);
-        if (errorState != OnlineCalculatorError.None) trainingWds[i] = double.NaN;
-
-        testWds[i] = OnlineWeightedDirectionalSymmetryCalculator.Calculate(startTestValues,
-          Enumerable.Repeat(actualContinuationTest, 1),
-          Enumerable.Repeat(predictedContinuationTest[i], 1), out errorState);
-        if (errorState != OnlineCalculatorError.None) testWds[i] = double.NaN;
-
-        trainingTheilsU[i] = OnlineTheilsUStatisticCalculator.Calculate(startTrainingValues,
-          Enumerable.Repeat(actualContinuationTraining, 1),
-          Enumerable.Repeat(predictedContinuationTraining[i], 1), out errorState);
-        if (errorState != OnlineCalculatorError.None) trainingTheilsU[i] = double.NaN;
-
-        testTheilsU[i] = OnlineTheilsUStatisticCalculator.Calculate(startTestValues,
-          Enumerable.Repeat(actualContinuationTest, 1),
-          Enumerable.Repeat(predictedContinuationTest[i], 1), out errorState);
-        if (errorState != OnlineCalculatorError.None) testTheilsU[i] = double.NaN;
-        i++;
+      //double[] trainingDs = new double[targetVariables.Length];
+      //double[] testDs = new double[targetVariables.Length];
+
+      //double[] trainingWds = new double[targetVariables.Length];
+      //double[] testWds = new double[targetVariables.Length];
+
+      //double[] trainingTheilsU = new double[targetVariables.Length];
+      //double[] testTheilsU = new double[targetVariables.Length];
+
+      var trainingDsCalculators = new OnlineDirectionalSymmetryCalculator[targetVariables.Length];
+      var testDsCalculators = new OnlineDirectionalSymmetryCalculator[targetVariables.Length];
+      var trainingWdsCalculators = new OnlineWeightedDirectionalSymmetryCalculator[targetVariables.Length];
+      var testWdsCalculators = new OnlineWeightedDirectionalSymmetryCalculator[targetVariables.Length];
+      var trainingTheilsUCalculators = new OnlineTheilsUStatisticCalculator[targetVariables.Length];
+      var testTheilsUCalculators = new OnlineTheilsUStatisticCalculator[targetVariables.Length];
+      for (int i = 0; i < targetVariables.Length; i++) {
+        trainingDsCalculators[i] = new OnlineDirectionalSymmetryCalculator();
+        testDsCalculators[i] = new OnlineDirectionalSymmetryCalculator();
+        trainingWdsCalculators[i] = new OnlineWeightedDirectionalSymmetryCalculator();
+        testWdsCalculators[i] = new OnlineWeightedDirectionalSymmetryCalculator();
+        trainingTheilsUCalculators[i] = new OnlineTheilsUStatisticCalculator();
+        testTheilsUCalculators[i] = new OnlineTheilsUStatisticCalculator();
       }
 
-      TrainingDirectionalSymmetry = trainingDs;
-      TestDirectionalSymmetry = testDs;
-      TrainingWeightedDirectionalSymmetry = trainingWds;
-      TestWeightedDirectionalSymmetry = testWds;
-      TrainingTheilsUStatistic = trainingTheilsU;
-      TestTheilsUStatistic = testTheilsU;
+      var allPrognosedTrainingValues = PrognosedTrainingValues.SelectMany(x => x).ToArray();
+      var allPrognosedTestValues = PrognosedTestValues.SelectMany(x => x).ToArray();
+      for (int t = 0; t < targetVariables.Length; t++) {
+        var actualTrainingValues = ProblemData.Dataset.GetDoubleValues(targetVariables[t], ProblemData.TrainingIndizes);
+        double startTrainingValue = ProblemData.Dataset.GetDoubleValue(targetVariables[t], ProblemData.TrainingIndizes.First() - 1);
+        var prognosedTrainingValues = allPrognosedTrainingValues.Skip(t).TakeEvery(targetVariables.Length);
+        trainingDsCalculators[t].Add(startTrainingValue, actualTrainingValues, prognosedTrainingValues);
+        trainingWdsCalculators[t].Add(startTrainingValue, actualTrainingValues, prognosedTrainingValues);
+        trainingTheilsUCalculators[t].Add(startTrainingValue, actualTrainingValues, prognosedTrainingValues);
+
+        var actualTestValues = ProblemData.Dataset.GetDoubleValues(targetVariables[t], ProblemData.TestIndizes);
+        double startTestValue = ProblemData.Dataset.GetDoubleValue(targetVariables[t], ProblemData.TestIndizes.First() - 1);
+        var prognosedTestValues = allPrognosedTestValues.Skip(t).TakeEvery(targetVariables.Length);
+        testDsCalculators[t].Add(startTestValue, actualTestValues, prognosedTestValues);
+        testWdsCalculators[t].Add(startTestValue, actualTestValues, prognosedTestValues);
+        testTheilsUCalculators[t].Add(startTestValue, actualTestValues, prognosedTestValues);
+      }
+
+      TrainingDirectionalSymmetry = trainingDsCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : 0.0)
+        .ToArray();
+      TestDirectionalSymmetry = testDsCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : 0.0)
+        .ToArray();
+      TrainingWeightedDirectionalSymmetry = trainingWdsCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
+        .ToArray();
+      TestWeightedDirectionalSymmetry = testWdsCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
+        .ToArray();
+      TrainingTheilsUStatistic = trainingDsCalculators
+        .Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
+        .ToArray();
+      TestTheilsUStatistic = testTheilsUCalculators
+        .Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
+        .ToArray();
     }
   }
