Index: /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedChVariableSymbol.cs
===================================================================
--- /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedChVariableSymbol.cs	(revision 14309)
+++ /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedChVariableSymbol.cs	(revision 14310)
@@ -109,5 +109,5 @@
     }
 
-    public CurvedChVariableSymbol(string name, string desc, double minAlpha = 0.001, double maxAlpha = 10, double minBeta = 0.001, double maxBeta = 10)
+    public CurvedChVariableSymbol(string name, string desc, double minAlpha = 0.001, double maxAlpha = 0.999, double minBeta = 0.001, double maxBeta = 0.999)
       : base(name, desc) {
       this.minAlpha = minAlpha;
Index: /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedChVariableTreeNode.cs
===================================================================
--- /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedChVariableTreeNode.cs	(revision 14309)
+++ /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedChVariableTreeNode.cs	(revision 14310)
@@ -77,6 +77,6 @@
       base.ShakeLocalParameters(random, shakingFactor);
       weight += NormalDistributedRandom.NextDouble(random, 0, 1.0 * shakingFactor);
-      alpha += NormalDistributedRandom.NextDouble(random, 0, 1 * shakingFactor);
-      beta += NormalDistributedRandom.NextDouble(random, 0, 1 * shakingFactor);
+      alpha += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
+      beta += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
 
       alpha = Math.Min(Symbol.MaxAlpha, Math.Max(Symbol.MinAlpha, alpha));
Index: /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedInsVariableSymbol.cs
===================================================================
--- /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedInsVariableSymbol.cs	(revision 14309)
+++ /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedInsVariableSymbol.cs	(revision 14310)
@@ -110,5 +110,5 @@
     }
 
-    public CurvedInsVariableSymbol(string name, string desc, double minAlpha = 0.001, double maxAlpha = 10, double minBeta = 0.001, double maxBeta = 10)
+    public CurvedInsVariableSymbol(string name, string desc, double minAlpha = 0.001, double maxAlpha = 0.999, double minBeta = 0.001, double maxBeta = 0.999)
       : base(name, desc) {
       this.minAlpha = minAlpha;
Index: /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedInsVariableTreeNode.cs
===================================================================
--- /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedInsVariableTreeNode.cs	(revision 14309)
+++ /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/CurvedInsVariableTreeNode.cs	(revision 14310)
@@ -78,6 +78,6 @@
       base.ShakeLocalParameters(random, shakingFactor);
       weight += NormalDistributedRandom.NextDouble(random, 0, 1.0 * shakingFactor); 
-      alpha += NormalDistributedRandom.NextDouble(random, 0, 1 * shakingFactor);
-      beta += NormalDistributedRandom.NextDouble(random, 0, 1 * shakingFactor);
+      alpha += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
+      beta += NormalDistributedRandom.NextDouble(random, 0, 0.1 * shakingFactor);
       
       alpha = Math.Min(Symbol.MaxAlpha, Math.Max(Symbol.MinAlpha, alpha));
Index: /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Grammar.cs
===================================================================
--- /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Grammar.cs	(revision 14309)
+++ /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Grammar.cs	(revision 14310)
@@ -24,5 +24,5 @@
       var exprCh = new SimpleSymbol("ExprCh", string.Empty, 1, 1);
 
-      var predGlucData = new PredictedGlucoseVariableSymbol();
+      // var predGlucData = new PredictedGlucoseVariableSymbol();
       var realGlucData = new RealGlucoseVariableSymbol();
 
@@ -60,5 +60,5 @@
       var logIns = new SimpleSymbol("LogIns", "Log", 1, 1);
       var curvedIns = new CurvedInsVariableSymbol("CurvedIns", "");
-      var realInsVar = new RealInsulineVariableSymbol();
+      // var realInsVar = new RealInsulineVariableSymbol();
 
       var constSy = new Constant();
@@ -69,5 +69,5 @@
       AddSymbol(exprIns);
       AddSymbol(exprCh);
-      AddSymbol(predGlucData);
+      // AddSymbol(predGlucData);
       AddSymbol(realGlucData);
       AddSymbol(plusGluc);
@@ -100,5 +100,5 @@
       AddSymbol(cosIns);
       AddSymbol(logIns);
-      AddSymbol(realInsVar);
+      // AddSymbol(realInsVar);
       AddSymbol(constSy);
 
@@ -115,5 +115,5 @@
                     |realData(k-<idx2hOrMore>)
       */
-      var opGlucSet = new Symbol[] { plusGluc, minusGluc, prodGluc, divGluc, expGluc, sinGluc, cosGluc, logGluc, predGlucData, realGlucData, constSy };
+      var opGlucSet = new Symbol[] { plusGluc, minusGluc, prodGluc, divGluc, expGluc, sinGluc, cosGluc, logGluc, /*predGlucData, */ realGlucData, constSy };
       foreach (var opGluc in opGlucSet) {
         AddAllowedChildSymbol(exprGluc, opGluc);
@@ -192,5 +192,5 @@
 
       */
-      var opInsSet = new Symbol[] { plusIns, minusIns, prodIns, divIns, expIns, sinIns, cosIns, logIns, realInsVar, curvedIns, constSy };
+      var opInsSet = new Symbol[] { plusIns, minusIns, prodIns, divIns, expIns, sinIns, cosIns, logIns, /* realInsVar, */ curvedIns, constSy };
       foreach (var opIns in opInsSet) {
         AddAllowedChildSymbol(exprIns, opIns);
Index: /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction-3.3.csproj
===================================================================
--- /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction-3.3.csproj	(revision 14309)
+++ /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction-3.3.csproj	(revision 14310)
@@ -102,4 +102,12 @@
       <HintPath>..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>
     </Reference>
+    <Reference Include="HeuristicLab.Algorithms.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\trunk\sources\bin\HeuristicLab.Algorithms.DataAnalysis-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
+    </Reference>
     <Reference Include="HeuristicLab.Collections-3.3">
       <HintPath>..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
@@ -138,4 +146,8 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll</HintPath>
     </Reference>
     <Reference Include="HeuristicLab.Problems.Instances-3.3">
Index: /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Interpreter.cs
===================================================================
--- /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Interpreter.cs	(revision 14309)
+++ /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Interpreter.cs	(revision 14310)
@@ -2,7 +2,9 @@
 using System.Collections;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Collections.Specialized;
 using System.Drawing.Design;
 using System.Linq;
+using HeuristicLab.Common;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 using HeuristicLab.Problems.DataAnalysis;
@@ -15,5 +17,5 @@
       public double[] realIns;
       public double[] realCh;
-      public double[] predGluc;
+      public Dictionary<ISymbolicExpressionTreeNode, double[]> precalculatedValues;
     }
 
@@ -25,16 +27,99 @@
         realIns = dataset.GetDoubleValues("Insuline", rows).ToArray(),
         realCh = dataset.GetDoubleValues("CH", rows).ToArray(),
+        precalculatedValues = CreatePrecalculatedValues(model, dataset)
       };
-      data.predGluc = new double[data.realGluc.Length];
-      Array.Copy(data.realGluc, data.predGluc, data.predGluc.Length);
-      for (int k = 0; k < data.predGluc.Length; k++) {
+      var predictions = new double[targetGluc.Length];
+      var rowsEnumerator = rows.GetEnumerator();
+      for (int k = 0; k < predictions.Length; k++, rowsEnumerator.MoveNext()) {
         if (double.IsNaN(targetGluc[k])) {
-          data.predGluc[k] = double.NaN;
+          predictions[k] = double.NaN;
         } else {
-          var rawPred = InterpretRec(model, data, k);
-          data.predGluc[k] = Math.Max(0, Math.Min(400, rawPred)); // limit output values of the model to 0 ... 400
-        }
-      }
-      return data.predGluc;
+          var rawPred = InterpretRec(model, data, rowsEnumerator.Current);
+          predictions[k] = rawPred; 
+        }
+      }
+      return predictions;
+    }
+
+    private static Dictionary<ISymbolicExpressionTreeNode, double[]> CreatePrecalculatedValues(ISymbolicExpressionTreeNode root, IDataset dataset) {
+      var dict = new Dictionary<ISymbolicExpressionTreeNode, double[]>();
+      // here we integrate ins or ch inputs over the whole day to generate smoothed ins/ch values with the same number of rows
+      // the integrated values are reset to zero whenever a new evluation period starts
+      foreach (var node in root.IterateNodesPrefix()) {
+        var curvedInsNode = node as CurvedInsVariableTreeNode;
+        var curvedChNode = node as CurvedChVariableTreeNode;
+        if (curvedInsNode != null) {
+          dict.Add(curvedInsNode, Integrate(curvedInsNode, dataset));
+        } else if (curvedChNode != null) {
+          dict.Add(curvedChNode, Integrate(curvedChNode, dataset));
+        }
+      }
+      return dict;
+    }
+
+    private static double[] Integrate(CurvedInsVariableTreeNode node, IDataset dataset) {
+      // d Q1 / dt = ins(t) - alpha * Q1(t)
+      // d Q2 / dt = alpha * (Q1(t) - Q2(t))
+      // S = Q1(t) + Q2(t)
+      var alpha = node.Alpha;
+
+      var ins = dataset.GetReadOnlyDoubleValues("Insuline");
+      var time = dataset.GetReadOnlyDoubleValues("HourMin").ToArray();
+
+      // TODO reset for new time intervals
+
+      double q1, q2, q1_prev, q2_prev;
+      // starting values: zeros
+      q1 = q2 = q1_prev = q2_prev = 0;
+      double[] s = new double[dataset.Rows];
+
+      for (int t = 1; t < dataset.Rows; t++) {
+        if (IsStartOfNewPeriod(time, t)) {
+          q1 = q2 = q1_prev = q2_prev = 0;
+        }
+        q1 = q1_prev + ins[t] - alpha * q1_prev;
+        q2 = q2_prev + alpha * (q1_prev - q2_prev);
+        s[t] = q1 + q2;
+        q1_prev = q1;
+        q2_prev = q2;
+
+      }
+      return s;
+    }
+
+    private static bool IsStartOfNewPeriod(double[] time, int t) {
+      return t == 0 ||
+             (time[t].IsAlmost(2005) && !time[t - 1].IsAlmost(2000));
+    }
+
+
+    private static double[] Integrate(CurvedChVariableTreeNode node, IDataset dataset) {
+      // d Q1 / dt = ins(t) - alpha * Q1(t)
+      // d Q2 / dt = alpha * (Q1(t) - Q2(t))
+      // S = Q1(t) + Q2(t)
+      var alpha = node.Alpha;
+
+      var ch = dataset.GetReadOnlyDoubleValues("CH");
+      var time = dataset.GetReadOnlyDoubleValues("HourMin").ToArray();
+
+      // TODO reset for new time intervals
+
+      double q1, q2, q1_prev, q2_prev;
+      // starting values: zeros
+      q1 = q2 = q1_prev = q2_prev = 0;
+      double[] s = new double[dataset.Rows];
+
+      for (int t = 1; t < dataset.Rows; t++) {
+        if (IsStartOfNewPeriod(time, t)) {
+          q1 = q2 = q1_prev = q2_prev = 0;
+        }
+        q1 = q1_prev + ch[t] - alpha * q1_prev;
+        q2 = q2_prev + alpha * (q1_prev - q2_prev);
+        s[t] = q1 + q2;
+        q1_prev = q1;
+        q2_prev = q2;
+
+      }
+      return s;
     }
 
@@ -102,26 +187,15 @@
         }
       } else if (node.Symbol is PredictedGlucoseVariableSymbol) {
-        var n = (PredictedGlucoseVariableTreeNode)node;
-        return n.Weight * data.predGluc[k + n.RowOffset];
+        throw new NotSupportedException();
       } else if (node.Symbol is RealGlucoseVariableSymbol) {
         var n = (RealGlucoseVariableTreeNode)node;
-        return n.Weight * data.realGluc[k + n.RowOffset];
+        if (k + n.RowOffset < 0 || k + n.RowOffset >= data.realGluc.Length) return double.NaN;
+        return data.realGluc[k + n.RowOffset];
       } else if (node.Symbol is CurvedChVariableSymbol) {
-        var n = (CurvedChVariableTreeNode)node;
-        double prevVal;
-        int prevValDistance;
-        GetPrevDataAndDistance(data.realCh, k, out prevVal, out prevValDistance, maxDistance: 48);
-        return n.Weight * prevVal * Beta(prevValDistance / 48.0, n.Alpha, n.Beta);
+        return data.precalculatedValues[node][k];
       } else if (node.Symbol is RealInsulineVariableSymbol) {
-        var n = (RealInsulineVariableTreeNode)node;
-        return n.Weight * data.realIns[k + n.RowOffset];
+        throw new NotSupportedException();
       } else if (node.Symbol is CurvedInsVariableSymbol) {
-        var n = (CurvedInsVariableTreeNode)node;
-        double maxVal;
-        int maxValDistance;
-        var sum = GetSumOfValues(48, k, data.realIns);
-
-        GetMaxValueAndDistance(data.realIns, k, out maxVal, out maxValDistance, maxDistance: 48);
-        return n.Weight * (sum - maxVal) * maxVal * Beta(maxValDistance / 48.0, n.Alpha, n.Beta);
+        return data.precalculatedValues[node][k];
       } else if (node.Symbol is Constant) {
         var n = (ConstantTreeNode)node;
@@ -135,36 +209,4 @@
       return 1.0 / alglib.beta(alpha, beta) * Math.Pow(x, alpha - 1) * Math.Pow(1 - x, beta - 1);
     }
-
-    private static void GetPrevDataAndDistance(double[] vals, int k, out double val, out int dist, int maxDistance = 48, double threshold = 0.0) {
-      // look backward from the current idx k and find the first value above the threshold
-      for (int i = k; i >= 0 && i >= (k - maxDistance); i--) {
-        if (vals[i] > threshold) {
-          val = vals[i];
-          dist = k - i;
-          return;
-        }
-      }
-      val = 0;
-      dist = maxDistance;
-    }
-
-    private static double GetSumOfValues(int windowSize, int k, double[] vals) {
-      var sum = 0.0;
-      for (int i = k; i >= 0 && i >= k - windowSize; i--)
-        sum += vals[i];
-      return sum;
-    }
-
-    private static void GetMaxValueAndDistance(double[] vals, int k, out double maxVal, out int dist, int maxDistance = 48) {
-      // look backward from the current idx k and find the max value and it's distance
-      maxVal = vals[k];
-      dist = 0;
-      for (int i = k; i >= 0 && i >= (k - maxDistance); i--) {
-        if (vals[i] > maxVal) {
-          maxVal = vals[i];
-          dist = k - i;
-        }
-      }
-    }
   }
 }
Index: /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Model.cs
===================================================================
--- /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Model.cs	(revision 14309)
+++ /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Model.cs	(revision 14310)
@@ -11,4 +11,5 @@
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 using HeuristicLab.Problems.DataAnalysis;
+using Microsoft.Win32.SafeHandles;
 
 namespace HeuristicLab.Problems.GeneticProgramming.GlucosePrediction {
@@ -16,15 +17,25 @@
   [Item("Model", "")]
   public sealed class Model : NamedItem, IRegressionModel {
+    [Storable]
     private readonly IRegressionProblemData problemData;
+    [Storable]
     private readonly ISymbolicExpressionTree tree;
+    [Storable]
+    private string targetVariable;
+    [Storable]
+    private string[] variablesUsedForPrediction;
 
     private Model(Model original, Cloner cloner) {
       this.problemData = cloner.Clone(original.problemData);
       this.tree = cloner.Clone(original.tree);
+      this.variablesUsedForPrediction = original.variablesUsedForPrediction;
+      this.targetVariable = original.targetVariable;
     }
 
-    public Model(IRegressionProblemData problemData, ISymbolicExpressionTree tree) {
+    public Model(IRegressionProblemData problemData, ISymbolicExpressionTree tree, string targetVariable, string[] variablesUsedForPrediction) {
       this.problemData = problemData;
       this.tree = tree;
+      this.variablesUsedForPrediction = variablesUsedForPrediction;
+      this.targetVariable = targetVariable;
     }
 
@@ -40,4 +51,21 @@
       return new Solution(this, problemData);
     }
+
+
+    public string TargetVariable {
+      get {
+        return targetVariable;
+      }
+      set {
+        throw new NotSupportedException();
+      }
+    }
+
+    public event EventHandler TargetVariableChanged;
+
+
+    public IEnumerable<string> VariablesUsedForPrediction {
+      get { return variablesUsedForPrediction; }
+    }
   }
 }
Index: /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Problem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Problem.cs	(revision 14309)
+++ /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Problem.cs	(revision 14310)
@@ -21,6 +21,8 @@
 
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
+using HeuristicLab.Analysis;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
@@ -62,5 +64,5 @@
 
     public override bool Maximization {
-      get { return false; }
+      get { return true; }
     }
 
@@ -98,6 +100,15 @@
       var rows = problemData.TrainingIndices.ToArray();
       var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
-      var predicted = Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0), problemData.Dataset, rows);  
-
+      var predicted0 = Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(0), problemData.Dataset, rows);
+      var predicted1 = Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(1), problemData.Dataset, rows);
+      var predicted2 = Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(2), problemData.Dataset, rows);
+
+      var pred0_rsq = Rsq(predicted0, target);
+      var pred1_rsq = Rsq(predicted1, target);
+      var pred2_rsq = Rsq(predicted2, target);
+      return pred0_rsq + pred1_rsq + pred2_rsq;
+    }
+
+    private double Rsq(IEnumerable<double> predicted, IEnumerable<double> target) {
       // only take predictions for which the target is not NaN
       var selectedTuples = target.Zip(predicted, Tuple.Create).Where(t => !double.IsNaN(t.Item1)).ToArray();
@@ -106,14 +117,18 @@
 
       OnlineCalculatorError errorState;
-      var mse = OnlineMeanSquaredErrorCalculator.Calculate(target, predicted, out errorState);
-      if (errorState != OnlineCalculatorError.None) mse = 1E6;
-      return mse;
-    }
-
-    public override void Analyze(ISymbolicExpressionTree[] trees, double[] qualities, ResultCollection results, IRandom random) {
+      var r = OnlinePearsonsRCalculator.Calculate(target, predicted, out errorState);
+      if (errorState != OnlineCalculatorError.None) r = 0;
+      return r * r;
+    }
+
+    public override void Analyze(ISymbolicExpressionTree[] trees, double[] qualities, ResultCollection results,
+      IRandom random) {
       base.Analyze(trees, qualities, results, random);
 
       if (!results.ContainsKey("Solution")) {
         results.Add(new Result("Solution", typeof(IRegressionSolution)));
+      }
+      if (!results.ContainsKey("Terms")) {
+        results.Add(new Result("Terms", typeof(DataTable)));
       }
 
@@ -121,5 +136,5 @@
       var bestQuality = qualities.First();
       for (int i = 1; i < trees.Length; i++) {
-        if (qualities[i] < bestQuality) {
+        if (qualities[i] > bestQuality) {
           bestQuality = qualities[i];
           bestTree = trees[i];
@@ -127,7 +142,60 @@
       }
 
+
       var clonedProblemData = (IRegressionProblemData)ProblemData.Clone();
-      var model = new Model(clonedProblemData, (ISymbolicExpressionTree)bestTree.Clone());
-      results["Solution"].Value = model.CreateRegressionSolution(clonedProblemData);
+      var rows = clonedProblemData.TrainingIndices.ToArray();
+      var target = clonedProblemData.Dataset.GetDoubleValues(clonedProblemData.TargetVariable, rows).ToArray();
+      var predicted0 =
+        Interpreter.Apply(bestTree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(0), clonedProblemData.Dataset, rows)
+          .ToArray();
+      var predicted1 =
+        Interpreter.Apply(bestTree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(1), clonedProblemData.Dataset, rows)
+          .ToArray();
+      var predicted2 =
+        Interpreter.Apply(bestTree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(2), clonedProblemData.Dataset, rows)
+          .ToArray();
+
+      var termsTable = new HeuristicLab.Analysis.DataTable("Terms");
+      var r0 = new DataRow("GlucTerm", "GlucTerm", predicted0);
+      var r1 = new DataRow("InsTerm", "InsTerm", predicted1);
+      r1.VisualProperties.SecondYAxis = true;
+      var r2 = new DataRow("ChTerm", "ChTerm", predicted2);
+      r2.VisualProperties.SecondYAxis = true;
+      var r3 = new DataRow("Target", "Target", target);
+      termsTable.Rows.Add(r0);
+      termsTable.Rows.Add(r1);
+      termsTable.Rows.Add(r2);
+      termsTable.Rows.Add(r3);
+      results["Terms"].Value = termsTable;
+
+
+      var filteredPredicted0 = rows.Where(r => !double.IsNaN(target[r])).Select(r => predicted0[r]).ToArray();
+      var filteredPredicted1 = rows.Where(r => !double.IsNaN(target[r])).Select(r => predicted1[r]).ToArray();
+      var filteredPredicted2 = rows.Where(r => !double.IsNaN(target[r])).Select(r => predicted2[r]).ToArray();
+      var filteredTarget = target.Where(t => !double.IsNaN(t)).ToArray();
+
+
+      var ds = new ModifiableDataset(new string[] { "pred0", "pred1", "pred2", "target" },
+        new List<IList>
+        {
+          filteredPredicted0.ToList(),
+          filteredPredicted1.ToList(),
+          filteredPredicted2.ToList(),
+          filteredTarget.ToList()
+        });
+      var lrProbData = new RegressionProblemData(ds, new string[] { "pred0", "pred1", "pred2" }, "target");
+      lrProbData.TrainingPartition.Start = clonedProblemData.TrainingPartition.Start;
+      lrProbData.TrainingPartition.End = clonedProblemData.TrainingPartition.End;
+      lrProbData.TestPartition.Start = clonedProblemData.TestPartition.Start;
+      lrProbData.TestPartition.End = clonedProblemData.TestPartition.End;
+
+      try {
+        double rmsError, cvRmsError;
+        var lrSolution = HeuristicLab.Algorithms.DataAnalysis.LinearRegression.CreateLinearRegressionSolution(
+          lrProbData, out rmsError, out cvRmsError);
+        results["Solution"].Value = lrSolution;
+      } catch (Exception) {
+        // ignore
+      }
     }
 
Index: /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/RealGlucoseVariableSymbol.cs
===================================================================
--- /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/RealGlucoseVariableSymbol.cs	(revision 14309)
+++ /branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/RealGlucoseVariableSymbol.cs	(revision 14310)
@@ -88,5 +88,5 @@
     public RealGlucoseVariableSymbol()
       : base(Name, string.Empty) {
-      minRowOffset = -48;
+      minRowOffset = -24;
       maxRowOffset = -24;
     }
