Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanConst.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanConst.cs	(revision 8929)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanConst.cs	(revision 8982)
@@ -21,8 +21,10 @@
 
 using System;
+using System.Collections.Generic;
 using System.Linq;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
 using HeuristicLab.Data;
+using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 
@@ -31,9 +33,7 @@
   [Item(Name = "MeanConst", Description = "Constant mean function for Gaussian processes.")]
   public sealed class MeanConst : ParameterizedNamedItem, IMeanFunction {
-    [Storable]
-    private double c;
-    [Storable]
-    private readonly HyperParameter<DoubleValue> valueParameter;
-    public IValueParameter<DoubleValue> ValueParameter { get { return valueParameter; } }
+    public IValueParameter<DoubleValue> ValueParameter {
+      get { return (IValueParameter<DoubleValue>)Parameters["Value"]; }
+    }
 
     [StorableConstructor]
@@ -41,7 +41,4 @@
     private MeanConst(MeanConst original, Cloner cloner)
       : base(original, cloner) {
-      this.c = original.c;
-      this.valueParameter = cloner.Clone(original.valueParameter);
-      RegisterEvents();
     }
     public MeanConst()
@@ -50,7 +47,5 @@
       this.description = ItemDescription;
 
-      this.valueParameter = new HyperParameter<DoubleValue>("Value", "The constant value for the constant mean function.");
-      Parameters.Add(valueParameter);
-      RegisterEvents();
+      Parameters.Add(new OptionalValueParameter<DoubleValue>("Value", "The constant value for the constant mean function."));
     }
 
@@ -59,31 +54,36 @@
     }
 
-    [StorableHook(HookType.AfterDeserialization)]
-    private void AfterDeserialization() {
-      RegisterEvents();
+    public int GetNumberOfParameters(int numberOfVariables) {
+      return ValueParameter.Value != null ? 0 : 1;
     }
 
-    private void RegisterEvents() {
-      Util.AttachValueChangeHandler<DoubleValue, double>(valueParameter, () => { c = valueParameter.Value.Value; });
+    public void SetParameter(double[] p) {
+      double c;
+      GetParameters(p, out c);
+      ValueParameter.Value = new DoubleValue(c);
     }
 
-    public int GetNumberOfParameters(int numberOfVariables) {
-      return valueParameter.Fixed ? 0 : 1;
+    private void GetParameters(double[] p, out double c) {
+      if (ValueParameter.Value == null) {
+        c = p[0];
+      } else {
+        if (p.Length > 0)
+          throw new ArgumentException(
+            "The length of the parameter vector does not match the number of free parameters for the constant mean function.",
+            "p");
+        c = ValueParameter.Value.Value;
+      }
     }
 
-    public void SetParameter(double[] hyp) {
-      if (!valueParameter.Fixed) {
-        valueParameter.SetValue(new DoubleValue(hyp[0]));
-      } else if (hyp.Length > 0)
-        throw new ArgumentException("The length of the parameter vector does not match the number of free parameters for the constant mean function.", "hyp");
-    }
-
-    public double[] GetMean(double[,] x) {
-      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, x.GetLength(0)).ToArray();
+    public ParameterizedMeanFunction GetParameterizedMeanFunction(double[] p, IEnumerable<int> columnIndices) {
+      double c;
+      GetParameters(p, out c);
+      var mf = new ParameterizedMeanFunction();
+      mf.Mean = (x, i) => c;
+      mf.Gradient = (x, i, k) => {
+        if (k > 0) throw new ArgumentException();
+        return 1.0;
+      };
+      return mf;
     }
   }
