Index: branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesExpressionInterpreter.cs
===================================================================
--- branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesExpressionInterpreter.cs	(revision 4555)
+++ branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesExpressionInterpreter.cs	(revision 4556)
@@ -136,5 +136,5 @@
 
       foreach (var row in rows) {
-        ResetVariableValues(dataset, row);
+        // ResetVariableValues(dataset, row);
         for (int step = 0; step < predictionHorizon; step++) {
           this.row = row + step;
@@ -169,5 +169,5 @@
 
       foreach (var row in rows) {
-        ResetVariableValues(dataset, row);
+        // ResetVariableValues(dataset, row);
         for (int step = 0; step < predictionHorizon; step++) {
           this.row = row + step;
@@ -190,20 +190,20 @@
     #endregion
 
-    private void ResetVariableValues(Dataset dataset, int start) {
-      foreach (var pair in estimatedTargetVariableValues) {
-        int targetVariableIndex = pair.Key;
-        double[] values = pair.Value;
-        for (int i = 0; i < values.Length; i++) {
-          values[i] = dataset[start + i, targetVariableIndex];
-        }
-      }
-    }
+    //private void ResetVariableValues(Dataset dataset, int start) {
+    //  foreach (var pair in estimatedTargetVariableValues) {
+    //    int targetVariableIndex = pair.Key;
+    //    double[] values = pair.Value;
+    //    for (int i = 0; i < values.Length; i++) {
+    //      values[i] = dataset[start + i, targetVariableIndex];
+    //    }
+    //  }
+    //}
 
     private Instruction PostProcessInstruction(Instruction instr) {
-      if (instr.opCode == OpCodes.Variable || instr.opCode == OpCodes.LagVariable || 
+      if (instr.opCode == OpCodes.Variable || instr.opCode == OpCodes.LagVariable ||
         instr.opCode == OpCodes.Integral || instr.opCode == OpCodes.MovingAverage || instr.opCode == OpCodes.Differential) {
         var variableTreeNode = instr.dynamicNode as VariableTreeNode;
         instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName);
-      } 
+      }
       return instr;
     }
@@ -349,5 +349,5 @@
             var lagVariableTreeNode = currentInstr.dynamicNode as LaggedVariableTreeNode;
             int actualRow = row + lagVariableTreeNode.Lag;
-            if (actualRow < 0 || actualRow >= dataset.Rows)
+            if (actualRow < 0 || actualRow >= dataset.Rows + currentPredictionHorizon)
               return double.NaN;
             return GetVariableValue(currentInstr.iArg0, lagVariableTreeNode.Lag) * lagVariableTreeNode.Weight;
@@ -355,5 +355,5 @@
         case OpCodes.MovingAverage: {
             var movingAvgTreeNode = currentInstr.dynamicNode as MovingAverageTreeNode;
-            if (row + movingAvgTreeNode.MinTimeOffset < 0 || row + movingAvgTreeNode.MaxTimeOffset >= dataset.Rows)
+            if (row + movingAvgTreeNode.MinTimeOffset < 0 || row + movingAvgTreeNode.MaxTimeOffset >= dataset.Rows + currentPredictionHorizon)
               return double.NaN;
             double sum = 0.0;
@@ -365,14 +365,14 @@
         case OpCodes.Differential: {
             var diffTreeNode = currentInstr.dynamicNode as DerivativeVariableTreeNode;
-            if (row + diffTreeNode.Lag - 2 < 0 || row + diffTreeNode.Lag >= dataset.Rows)
+            if (row + diffTreeNode.Lag - 2 < 0 || row + diffTreeNode.Lag >= dataset.Rows + currentPredictionHorizon)
               return double.NaN;
             double y_0 = GetVariableValue(currentInstr.iArg0, diffTreeNode.Lag);
             double y_1 = GetVariableValue(currentInstr.iArg0, diffTreeNode.Lag - 1);
             double y_2 = GetVariableValue(currentInstr.iArg0, diffTreeNode.Lag - 2);
-            return diffTreeNode.Weight * (3 * y_0 - 4 * y_1 + 3 * y_2) / 2;
+            return diffTreeNode.Weight * (y_0 - 4 * y_1 + 3 * y_2) / 2;
           }
         case OpCodes.Integral: {
             var integralVarTreeNode = currentInstr.dynamicNode as IntegratedVariableTreeNode;
-            if (row + integralVarTreeNode.MinTimeOffset < 0 || row + integralVarTreeNode.MaxTimeOffset >= dataset.Rows)
+            if (row + integralVarTreeNode.MinTimeOffset < 0 || row + integralVarTreeNode.MaxTimeOffset >= dataset.Rows + currentPredictionHorizon)
               return double.NaN;
             double sum = 0;
@@ -391,7 +391,13 @@
 
     private double GetVariableValue(int variableIndex, int timeoffset) {
-      if (estimatedTargetVariableValues.ContainsKey(variableIndex) &&
-                      currentPredictionHorizon + timeoffset >= 0) {
-        return estimatedTargetVariableValues[variableIndex][currentPredictionHorizon + timeoffset];
+      if (currentPredictionHorizon + timeoffset >= 0) {
+        double[] values;
+        estimatedTargetVariableValues.TryGetValue(variableIndex, out values);
+        if (values != null) {
+          return values[currentPredictionHorizon + timeoffset];
+        }
+      }
+      if (row + timeoffset < 0 || row + timeoffset >= dataset.Rows) {
+        return double.NaN;
       } else {
         return dataset[row + timeoffset, variableIndex];
Index: branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesPrognosisSolution.cs
===================================================================
--- branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesPrognosisSolution.cs	(revision 4555)
+++ branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.TimeSeriesPrognosis/3.3/Symbolic/SymbolicTimeSeriesPrognosisSolution.cs	(revision 4556)
@@ -117,5 +117,5 @@
 
     public IEnumerable<double[]> GetPrognosis(int t) {
-      return model.GetEstimatedValues(problemData, t, t + 1);
+      return model.GetEstimatedValues(problemData, t, t + 1, horizon);
     }
 
