Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceLinear.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceLinear.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceLinear.cs	(revision 8416)
@@ -29,9 +29,10 @@
   [Item(Name = "CovarianceLinear", Description = "Linear covariance function with for Gaussian processes.")]
   public class CovarianceLinear : Item, ICovarianceFunction {
+    private static readonly double[] emptyArray = new double[0];
+
     [Storable]
     private double[,] x;
     [Storable]
     private double[,] xt;
-
 
     private double[,] k;
@@ -45,8 +46,15 @@
     protected CovarianceLinear(CovarianceLinear original, Cloner cloner)
       : base(original, cloner) {
-      // note: using shallow copies here!
-      this.x = original.x;
-      this.xt = original.xt;
+      if (original.x != null) {
+        this.x = new double[original.x.GetLength(0), original.x.GetLength(1)];
+        Array.Copy(original.x, this.x, x.Length);
 
+        this.xt = new double[original.xt.GetLength(0), original.xt.GetLength(1)];
+        Array.Copy(original.xt, this.xt, xt.Length);
+
+        this.k = new double[original.k.GetLength(0), original.k.GetLength(1)];
+        Array.Copy(original.k, this.k, k.Length);
+      }
+      this.symmetric = original.symmetric;
     }
     public CovarianceLinear()
@@ -58,11 +66,15 @@
     }
 
-    public void SetParameter(double[] hyp, double[,] x) {
-      if (hyp.Length > 0) throw new ArgumentException();
-      SetParameter(hyp, x, x);
+    public void SetParameter(double[] hyp) {
+      if (hyp.Length > 0) throw new ArgumentException("No hyperparameters are allowed for the linear covariance function.");
+      k = null;
+    }
+
+    public void SetData(double[,] x) {
+      SetData(x, x);
       this.symmetric = true;
     }
 
-    public void SetParameter(double[] hyp, double[,] x, double[,] xt) {
+    public void SetData(double[,] x, double[,] xt) {
       this.x = x;
       this.xt = xt;
@@ -77,21 +89,6 @@
     }
 
-
-    public double[] GetDiagonalCovariances() {
-      if (x != xt) throw new InvalidOperationException();
-      int rows = x.GetLength(0);
-      int cols = x.GetLength(1);
-      var k = new double[rows];
-      for (int i = 0; i < rows; i++) {
-        k[i] = 0;
-        for (int j = 0; j < cols; j++) {
-          k[i] += x[i, j] * x[i, j];
-        }
-      }
-      return k;
-    }
-
     public double[] GetGradient(int i, int j) {
-      throw new NotSupportedException();
+      return emptyArray;
     }
 
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceProd.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceProd.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceProd.cs	(revision 8416)
@@ -1,56 +1,91 @@
-﻿using System.Collections.Generic;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
 using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 
-namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
-  public class CovarianceProd : ICovarianceFunction {
-    private IList<ICovarianceFunction> covariances;
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  [StorableClass]
+  [Item(Name = "CovarianceProd",
+    Description = "Product covariance function for Gaussian processes.")]
+  public class CovarianceProd : Item, ICovarianceFunction {
+    [Storable]
+    private ItemList<ICovarianceFunction> factors;
 
-    public int NumberOfParameters {
-      get { return covariances.Sum(c => c.NumberOfParameters); }
+    [Storable]
+    private int numberOfVariables;
+    public ItemList<ICovarianceFunction> Factors {
+      get { return factors; }
     }
 
-    public CovarianceProd(IEnumerable<ICovarianceFunction> covariances) {
-      this.covariances = covariances.ToList();
+    [StorableConstructor]
+    protected CovarianceProd(bool deserializing)
+      : base(deserializing) {
     }
 
-    public void SetMatrix(double[,] x) {
-      foreach (var covariance in covariances) {
-        covariance.SetMatrix(x, x);
+    protected CovarianceProd(CovarianceProd original, Cloner cloner)
+      : base(original, cloner) {
+      this.factors = cloner.Clone(original.factors);
+      this.numberOfVariables = original.numberOfVariables;
+    }
+
+    public CovarianceProd()
+      : base() {
+      this.factors = new ItemList<ICovarianceFunction>();
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new CovarianceProd(this, cloner);
+    }
+
+    public int GetNumberOfParameters(int numberOfVariables) {
+      this.numberOfVariables = numberOfVariables;
+      return factors.Select(t => t.GetNumberOfParameters(numberOfVariables)).Sum();
+    }
+
+    public void SetParameter(double[] hyp) {
+      int offset = 0;
+      foreach (var t in factors) {
+        var numberOfParameters = t.GetNumberOfParameters(numberOfVariables);
+        t.SetParameter(hyp.Skip(offset).Take(numberOfParameters).ToArray());
+        offset += numberOfParameters;
       }
     }
-
-    public void SetMatrix(double[,] x, double[,] xt) {
-      foreach (var covariance in covariances) {
-        covariance.SetMatrix(x, xt);
-      }
+    public void SetData(double[,] x) {
+      SetData(x, x);
     }
 
-    public void SetHyperparamter(double[] hyp) {
-      int i = 0;
-      foreach (var covariance in covariances) {
-        int n = covariance.NumberOfParameters;
-        covariance.SetHyperparamter(hyp.Skip(i).Take(n).ToArray());
-        i += n;
+    public void SetData(double[,] x, double[,] xt) {
+      foreach (var t in factors) {
+        t.SetData(x, xt);
       }
     }
 
     public double GetCovariance(int i, int j) {
-      return covariances.Select(c => c.GetCovariance(i, j))
-        .Aggregate((a, b) => a * b);
+      return factors.Select(t => t.GetCovariance(i, j)).Aggregate((a, b) => a * b);
     }
 
-
-    public double[] GetDiagonalCovariances() {
-      return covariances
-        .Select(c => c.GetDiagonalCovariances())
-        .Aggregate((s, d) => s.Zip(d, (a, b) => a * b).ToArray())
-        .ToArray();
-    }
-
-    public double[] GetDerivatives(int i, int j) {
-      return covariances
-        .Select(c => c.GetDerivatives(i, j))
-        .Aggregate(Enumerable.Empty<double>(), (h0, h1) => h0.Concat(h1))
-        .ToArray();
+    public double[] GetGradient(int i, int j) {
+      return factors.Select(t => t.GetGradient(i, j)).SelectMany(seq => seq).ToArray();
     }
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSEard.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSEard.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSEard.cs	(revision 8416)
@@ -49,9 +49,19 @@
     protected CovarianceSEard(CovarianceSEard original, Cloner cloner)
       : base(original, cloner) {
-      // note: using shallow copies here!
-      this.x = original.x;
-      this.xt = original.xt;
+      if (original.x != null) {
+        this.x = new double[original.x.GetLength(0), original.x.GetLength(1)];
+        Array.Copy(original.x, this.x, x.Length);
+
+        this.xt = new double[original.xt.GetLength(0), original.xt.GetLength(1)];
+        Array.Copy(original.xt, this.xt, xt.Length);
+
+        this.sd = new double[original.sd.GetLength(0), original.sd.GetLength(1)];
+        Array.Copy(original.sd, this.sd, sd.Length);
+
+        this.l = new double[original.l.Length];
+        Array.Copy(original.l, this.l, l.Length);
+      }
       this.sf2 = original.sf2;
-      this.l = original.l;
+      this.symmetric = original.symmetric;
     }
     public CovarianceSEard()
@@ -63,14 +73,5 @@
     }
 
-    public void SetParameter(double[] hyp, double[,] x) {
-      SetParameter(hyp, x, x);
-      this.symmetric = true;
-    }
-
-    public void SetParameter(double[] hyp, double[,] x, double[,] xt) {
-      this.x = x;
-      this.xt = xt;
-      this.symmetric = false;
-
+    public void SetParameter(double[] hyp) {
       this.l = hyp.Take(hyp.Length - 1).Select(Math.Exp).ToArray();
       this.sf2 = Math.Exp(2 * hyp[hyp.Length - 1]);
@@ -80,20 +81,20 @@
     }
 
+    public void SetData(double[,] x) {
+      SetData(x, x);
+      this.symmetric = true;
+    }
+
+    public void SetData(double[,] x, double[,] xt) {
+      this.x = x;
+      this.xt = xt;
+      this.symmetric = false;
+
+      sd = null;
+    }
+
     public double GetCovariance(int i, int j) {
       if (sd == null) CalculateSquaredDistances();
       return sf2 * Math.Exp(-sd[i, j] / 2.0);
-    }
-
-
-    public double[] GetDiagonalCovariances() {
-      if (x != xt) throw new InvalidOperationException();
-      int rows = x.GetLength(0);
-      var sd = new double[rows];
-      for (int i = 0; i < rows; i++) {
-        sd[i] = Util.SqrDist(
-          Util.GetRow(x, i).Select((e, k) => e / l[k]),
-          Util.GetRow(xt, i).Select((e, k) => e / l[k]));
-      }
-      return sd.Select(d => sf2 * Math.Exp(-d / 2.0)).ToArray();
     }
 
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSEiso.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSEiso.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSEiso.cs	(revision 8416)
@@ -50,7 +50,15 @@
     protected CovarianceSEiso(CovarianceSEiso original, Cloner cloner)
       : base(original, cloner) {
-      // note: using shallow copies here
-      this.x = original.x;
-      this.xt = original.xt;
+      if (original.x != null) {
+        this.x = new double[original.x.GetLength(0), original.x.GetLength(1)];
+        Array.Copy(original.x, this.x, x.Length);
+
+        this.xt = new double[original.xt.GetLength(0), original.xt.GetLength(1)];
+        Array.Copy(original.xt, this.xt, xt.Length);
+
+        this.sd = new double[original.sd.GetLength(0), original.sd.GetLength(1)];
+        Array.Copy(original.sd, this.sd, sd.Length);
+        this.sf2 = original.sf2;
+      }
       this.sf2 = original.sf2;
       this.l = original.l;
@@ -70,14 +78,16 @@
     }
 
-    public void SetParameter(double[] hyp, double[,] x) {
-      SetParameter(hyp, x, x);
+    public void SetParameter(double[] hyp) {
+      this.l = Math.Exp(hyp[0]);
+      this.sf2 = Math.Min(1E6, Math.Exp(2 * hyp[1])); // upper limit for scale
+      sd = null;
+    }
+    public void SetData(double[,] x) {
+      SetData(x, x);
       this.symmetric = true;
     }
 
 
-    public void SetParameter(double[] hyp, double[,] x, double[,] xt) {
-      this.l = Math.Exp(hyp[0]);
-      this.sf2 = Math.Exp(2 * hyp[1]);
-
+    public void SetData(double[,] x, double[,] xt) {
       this.symmetric = false;
       this.x = x;
@@ -90,16 +100,4 @@
       return sf2 * Math.Exp(-sd[i, j] / 2.0);
     }
-
-
-    public double[] GetDiagonalCovariances() {
-      if (x != xt) throw new InvalidOperationException();
-      int rows = x.GetLength(0);
-      var sd = new double[rows];
-      for (int i = 0; i < rows; i++) {
-        sd[i] = Util.SqrDist(Util.GetRow(x, i).Select(e => e / l), Util.GetRow(xt, i).Select(e => e / l));
-      }
-      return sd.Select(d => sf2 * Math.Exp(-d / 2.0)).ToArray();
-    }
-
 
     public double[] GetGradient(int i, int j) {
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSum.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSum.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSum.cs	(revision 8416)
@@ -1,3 +1,23 @@
-﻿using System;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
 using System.Linq;
 using HeuristicLab.Common;
@@ -5,5 +25,5 @@
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 
-namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
+namespace HeuristicLab.Algorithms.DataAnalysis {
   [StorableClass]
   [Item(Name = "CovarianceSum",
@@ -26,9 +46,11 @@
     protected CovarianceSum(CovarianceSum original, Cloner cloner)
       : base(original, cloner) {
-      this.terms = cloner.Clone(terms);
+      this.terms = cloner.Clone(original.terms);
+      this.numberOfVariables = original.numberOfVariables;
     }
 
     public CovarianceSum()
       : base() {
+      this.terms = new ItemList<ICovarianceFunction>();
     }
 
@@ -42,66 +64,28 @@
     }
 
-    public void SetParameter(double[] hyp, double[,] x) {
+    public void SetParameter(double[] hyp) {
       int offset = 0;
       foreach (var t in terms) {
-        t.SetParameter(hyp.Skip(offset).Take(t.GetNumberOfParameters(numberOfVariables)), x);
-        offset += numberOfVariables;
+        var numberOfParameters = t.GetNumberOfParameters(numberOfVariables);
+        t.SetParameter(hyp.Skip(offset).Take(numberOfParameters).ToArray());
+        offset += numberOfParameters;
+      }
+    }
+    public void SetData(double[,] x) {
+      SetData(x, x);
+    }
+
+    public void SetData(double[,] x, double[,] xt) {
+      foreach (var t in terms) {
+        t.SetData(x, xt);
       }
     }
 
-
-    public void SetParameter(double[] hyp, double[,] x, double[,] xt) {
-      this.l = Math.Exp(hyp[0]);
-      this.sf2 = Math.Exp(2 * hyp[1]);
-
-      this.symmetric = false;
-      this.x = x;
-      this.xt = xt;
-      sd = null;
+    public double GetCovariance(int i, int j) {
+      return terms.Select(t => t.GetCovariance(i, j)).Sum();
     }
 
-    public double GetCovariance(int i, int j) {
-      if (sd == null) CalculateSquaredDistances();
-      return sf2 * Math.Exp(-sd[i, j] / 2.0);
-    }
-
-
-    public double[] GetDiagonalCovariances() {
-      if (x != xt) throw new InvalidOperationException();
-      int rows = x.GetLength(0);
-      var sd = new double[rows];
-      for (int i = 0; i < rows; i++) {
-        sd[i] = Util.SqrDist(Util.GetRow(x, i).Select(e => e / l), Util.GetRow(xt, i).Select(e => e / l));
-      }
-      return sd.Select(d => sf2 * Math.Exp(-d / 2.0)).ToArray();
-    }
-
-
     public double[] GetGradient(int i, int j) {
-      var res = new double[2];
-      res[0] = sf2 * Math.Exp(-sd[i, j] / 2.0) * sd[i, j];
-      res[1] = 2.0 * sf2 * Math.Exp(-sd[i, j] / 2.0);
-      return res;
-    }
-
-    private void CalculateSquaredDistances() {
-      if (x.GetLength(1) != xt.GetLength(1)) throw new InvalidOperationException();
-      int rows = x.GetLength(0);
-      int cols = xt.GetLength(0);
-      sd = new double[rows, cols];
-      if (symmetric) {
-        for (int i = 0; i < rows; i++) {
-          for (int j = i; j < rows; j++) {
-            sd[i, j] = Util.SqrDist(Util.GetRow(x, i).Select(e => e / l), Util.GetRow(xt, j).Select(e => e / l));
-            sd[j, i] = sd[i, j];
-          }
-        }
-      } else {
-        for (int i = 0; i < rows; i++) {
-          for (int j = 0; j < cols; j++) {
-            sd[i, j] = Util.SqrDist(Util.GetRow(x, i).Select(e => e / l), Util.GetRow(xt, j).Select(e => e / l));
-          }
-        }
-      }
+      return terms.Select(t => t.GetGradient(i, j)).SelectMany(seq => seq).ToArray();
     }
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs	(revision 8416)
@@ -37,5 +37,4 @@
     [Storable]
     private double negativeLogLikelihood;
-
     public double NegativeLogLikelihood {
       get { return negativeLogLikelihood; }
@@ -53,9 +52,4 @@
     }
     [Storable]
-    private double[] hyp;
-    public IEnumerable<double> Hyperparameters {
-      get { return hyp; }
-    }
-    [Storable]
     private string targetVariable;
     public string TargetVariable {
@@ -72,8 +66,4 @@
     [Storable]
     private double sqrSigmaNoise;
-    [Storable]
-    private double[] meanHyp;
-    [Storable]
-    private double[] covHyp;
 
     [Storable]
@@ -90,15 +80,14 @@
     private GaussianProcessModel(GaussianProcessModel original, Cloner cloner)
       : base(original, cloner) {
-      this.hyp = original.hyp;
       this.meanFunction = cloner.Clone(original.meanFunction);
       this.covarianceFunction = cloner.Clone(original.covarianceFunction);
+      this.scaling = cloner.Clone(original.scaling);
       this.negativeLogLikelihood = original.negativeLogLikelihood;
       this.targetVariable = original.targetVariable;
+      this.sqrSigmaNoise = original.sqrSigmaNoise;
+
+      // shallow copies of arrays because they cannot be modified
       this.allowedInputVariables = original.allowedInputVariables;
       this.alpha = original.alpha;
-      this.sqrSigmaNoise = original.sqrSigmaNoise;
-      this.scaling = cloner.Clone(original.scaling);
-      this.meanHyp = original.meanHyp;
-      this.covHyp = original.covHyp;
       this.l = original.l;
       this.x = original.x;
@@ -109,20 +98,24 @@
       this.name = ItemName;
       this.description = ItemDescription;
-      this.hyp = hyp.ToArray();
-      this.meanFunction = meanFunction;
-      this.covarianceFunction = covarianceFunction;
+      this.meanFunction = (IMeanFunction)meanFunction.Clone();
+      this.covarianceFunction = (ICovarianceFunction)covarianceFunction.Clone();
       this.targetVariable = targetVariable;
       this.allowedInputVariables = allowedInputVariables.ToArray();
-      int nAllowedVariables = allowedInputVariables.Count();
 
       sqrSigmaNoise = Math.Exp(2.0 * hyp.First());
       sqrSigmaNoise = Math.Max(10E-6, sqrSigmaNoise); // lower limit for the noise level
-      meanHyp = hyp.Skip(1).Take(meanFunction.GetNumberOfParameters(nAllowedVariables)).ToArray();
-      covHyp = hyp.Skip(1 + meanFunction.GetNumberOfParameters(nAllowedVariables)).Take(covarianceFunction.GetNumberOfParameters(nAllowedVariables)).ToArray();
-
-      CalculateModel(ds, targetVariable, allowedInputVariables, rows);
-    }
-
-    private void CalculateModel(Dataset ds, string targetVariable, IEnumerable<string> allowedInputVariables, IEnumerable<int> rows) {
+
+      int nVariables = this.allowedInputVariables.Length;
+      this.meanFunction.SetParameter(hyp.Skip(1)
+        .Take(this.meanFunction.GetNumberOfParameters(nVariables))
+        .ToArray());
+      this.covarianceFunction.SetParameter(hyp.Skip(1 + this.meanFunction.GetNumberOfParameters(nVariables))
+        .Take(this.covarianceFunction.GetNumberOfParameters(nVariables))
+        .ToArray());
+
+      CalculateModel(ds, rows);
+    }
+
+    private void CalculateModel(Dataset ds, IEnumerable<int> rows) {
       scaling = new Scaling(ds, allowedInputVariables, rows);
       x = AlglibUtil.PrepareAndScaleInputMatrix(ds, allowedInputVariables, rows, scaling);
@@ -133,6 +126,6 @@
       l = new double[n, n];
 
-      meanFunction.SetParameter(meanHyp, x);
-      covarianceFunction.SetParameter(covHyp, x);
+      meanFunction.SetData(x);
+      covarianceFunction.SetData(x);
 
       // calculate means and covariances
@@ -245,6 +238,6 @@
       //kss = covarianceFunction.GetDiagonalCovariances();
 
-      covarianceFunction.SetParameter(covHyp, x, newX);
-      meanFunction.SetParameter(meanHyp, newX);
+      covarianceFunction.SetData(x, newX);
+      meanFunction.SetData(newX);
       var ms = meanFunction.GetMean(newX);
       for (int i = 0; i < newN; i++) {
@@ -268,13 +261,4 @@
 
     }
-
-    #region events
-    public event EventHandler Changed;
-    private void OnChanged(EventArgs e) {
-      var handlers = Changed;
-      if (handlers != null)
-        handlers(this, e);
-    }
-    #endregion
   }
 }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolutionCreator.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolutionCreator.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolutionCreator.cs	(revision 8416)
@@ -83,9 +83,9 @@
       var results = ResultsParameter.ActualValue;
       if (!results.ContainsKey(SolutionParameterName)) {
-        results.Add(new Result(ResultsParameterName, "The Gaussian process regression solution", s));
+        results.Add(new Result(SolutionParameterName, "The Gaussian process regression solution", s));
         results.Add(new Result(TrainingRSquaredResultName, "The Pearson's R² of the Gaussian process solution on the training partition.", new DoubleValue(s.TrainingRSquared)));
         results.Add(new Result(TestRSquaredResultName, "The Pearson's R² of the Gaussian process solution on the test partition.", new DoubleValue(s.TestRSquared)));
       } else {
-        results[ResultsParameterName].Value = s;
+        results[SolutionParameterName].Value = s;
         results[TrainingRSquaredResultName].Value = new DoubleValue(s.TrainingRSquared);
         results[TestRSquaredResultName].Value = new DoubleValue(s.TestRSquared);
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/ICovarianceFunction.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/ICovarianceFunction.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/ICovarianceFunction.cs	(revision 8416)
@@ -25,9 +25,9 @@
   public interface ICovarianceFunction : IItem {
     int GetNumberOfParameters(int numberOfVariables);
-    void SetParameter(double[] hyp, double[,] x);
-    void SetParameter(double[] hyp, double[,] x, double[,] xt);
+    void SetParameter(double[] hyp);
+    void SetData(double[,] x);
+    void SetData(double[,] x, double[,] xt);
 
     double GetCovariance(int i, int j);
-    double[] GetDiagonalCovariances();
     double[] GetGradient(int i, int j);
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/IMeanFunction.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/IMeanFunction.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/IMeanFunction.cs	(revision 8416)
@@ -24,5 +24,6 @@
   public interface IMeanFunction : IItem {
     int GetNumberOfParameters(int numberOfVariables);
-    void SetParameter(double[] hyp, double[,] x);
+    void SetParameter(double[] hyp);
+    void SetData(double[,] x);
     double[] GetMean(double[,] x);
     double[] GetGradients(int k, double[,] x);
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanConst.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanConst.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanConst.cs	(revision 8416)
@@ -32,6 +32,4 @@
     [Storable]
     private double c;
-    [Storable]
-    private int n;
     public int GetNumberOfParameters(int numberOfVariables) {
       return 1;
@@ -42,5 +40,4 @@
       : base(original, cloner) {
       this.c = original.c;
-      this.n = original.n;
     }
     public MeanConst()
@@ -48,17 +45,19 @@
     }
 
-    public void SetParameter(double[] hyp, double[,] x) {
+    public void SetParameter(double[] hyp) {
       if (hyp.Length != 1) throw new ArgumentException("Only one hyper-parameter allowed for constant mean function.", "hyp");
       this.c = hyp[0];
-      this.n = x.GetLength(0);
+    }
+    public void SetData(double[,] x) {
+      // nothing to do
     }
 
     public double[] GetMean(double[,] x) {
-      return Enumerable.Repeat(c, n).ToArray();
+      return Enumerable.Repeat(c, x.GetLength(0)).ToArray();
     }
 
     public double[] GetGradients(int k, double[,] x) {
       if (k > 0) throw new ArgumentException();
-      return Enumerable.Repeat(1.0, n).ToArray();
+      return Enumerable.Repeat(1.0, x.GetLength(0)).ToArray();
     }
 
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanLinear.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanLinear.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanLinear.cs	(revision 8416)
@@ -31,6 +31,4 @@
     [Storable]
     private double[] alpha;
-    [Storable]
-    private int n;
     public int GetNumberOfParameters(int numberOfVariables) {
       return numberOfVariables;
@@ -44,5 +42,4 @@
         Array.Copy(original.alpha, alpha, original.alpha.Length);
       }
-      this.n = original.n;
     }
     public MeanLinear()
@@ -50,13 +47,17 @@
     }
 
-    public void SetParameter(double[] hyp, double[,] x) {
-      if (hyp.Length != x.GetLength(1)) throw new ArgumentException("Number of hyper-parameters must match the number of variables.", "hyp");
+    public void SetParameter(double[] hyp) {
       this.alpha = new double[hyp.Length];
       Array.Copy(hyp, alpha, hyp.Length);
-      this.n = x.GetLength(0);
+    }
+    public void SetData(double[,] x) {
+      // nothing to do
     }
 
     public double[] GetMean(double[,] x) {
+      // sanity check
+      if (alpha.Length != x.GetLength(1)) throw new ArgumentException("The number of hyperparameters must match the number of variables for the linear mean function.");
       int cols = x.GetLength(1);
+      int n = x.GetLength(0);
       return (from i in Enumerable.Range(0, n)
               let rowVector = from j in Enumerable.Range(0, cols)
@@ -68,4 +69,5 @@
     public double[] GetGradients(int k, double[,] x) {
       int cols = x.GetLength(1);
+      int n = x.GetLength(0);
       if (k > cols) throw new ArgumentException();
       return (from r in Enumerable.Range(0, n)
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanZero.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanZero.cs	(revision 8403)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanZero.cs	(revision 8416)
@@ -29,6 +29,4 @@
   [Item(Name = "MeanZero", Description = "Constant zero mean function for Gaussian processes.")]
   public class MeanZero : Item, IMeanFunction {
-    [Storable]
-    private int n;
     public int GetNumberOfParameters(int numberOfVariables) {
       return 0;
@@ -38,21 +36,23 @@
     protected MeanZero(MeanZero original, Cloner cloner)
       : base(original, cloner) {
-      this.n = original.n;
     }
     public MeanZero() {
     }
 
-    public void SetParameter(double[] hyp, double[,] x) {
+    public void SetParameter(double[] hyp) {
       if (hyp.Length > 0) throw new ArgumentException("No hyper-parameters allowed for zero mean function.", "hyp");
-      this.n = x.GetLength(0);
+    }
+
+    public void SetData(double[,] x) {
+      // do nothing
     }
 
     public double[] GetMean(double[,] x) {
-      return Enumerable.Repeat(0.0, n).ToArray();
+      return Enumerable.Repeat(0.0, x.GetLength(0)).ToArray();
     }
 
     public double[] GetGradients(int k, double[,] x) {
       if (k > 0) throw new ArgumentException();
-      return Enumerable.Repeat(0.0, n).ToArray();
+      return Enumerable.Repeat(0.0, x.GetLength(0)).ToArray();
     }
     public override IDeepCloneable Clone(Cloner cloner) {
