Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceConst.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceConst.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceConst.cs	(revision 10489)
@@ -22,4 +22,5 @@
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
@@ -36,5 +37,7 @@
       get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; }
     }
-
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
     [StorableConstructor]
     private CovarianceConst(bool deserializing)
@@ -59,5 +62,5 @@
 
     public int GetNumberOfParameters(int numberOfVariables) {
-      return ScaleParameter.Value != null ? 0 : 1;
+      return HasFixedScaleParameter ? 0 : 1;
     }
 
@@ -71,5 +74,5 @@
       int c = 0;
       // gather parameter values
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -87,5 +90,9 @@
       cov.Covariance = (x, i, j) => scale;
       cov.CrossCovariance = (x, xt, i, j) => scale;
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, columnIndices);
+      if (HasFixedScaleParameter) {
+        cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>();
+      } else {
+        cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, columnIndices);
+      }
       return cov;
     }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs	(revision 10489)
@@ -37,4 +37,7 @@
       get { return (IValueParameter<DoubleArray>)Parameters["InverseLength"]; }
     }
+    private bool HasFixedInverseLengthParameter {
+      get { return InverseLengthParameter.Value != null; }
+    }
 
     [StorableConstructor]
@@ -57,8 +60,8 @@
 
     public int GetNumberOfParameters(int numberOfVariables) {
-      if (InverseLengthParameter.Value == null)
+      if (HasFixedInverseLengthParameter)
+        return 0;
+      else
         return numberOfVariables;
-      else
-        return 0;
     }
 
@@ -71,5 +74,5 @@
     private void GetParameterValues(double[] p, out double[] inverseLength) {
       // gather parameter values
-      if (InverseLengthParameter.Value != null) {
+      if (HasFixedInverseLengthParameter) {
         inverseLength = InverseLengthParameter.Value.ToArray();
       } else {
@@ -81,9 +84,13 @@
       double[] inverseLength;
       GetParameterValues(p, out inverseLength);
+      var fixedInverseLength = HasFixedInverseLengthParameter;
       // create functions
       var cov = new ParameterizedCovarianceFunction();
       cov.Covariance = (x, i, j) => Util.ScalarProd(x, i, j, inverseLength, columnIndices);
       cov.CrossCovariance = (x, xt, i, j) => Util.ScalarProd(x, i, xt, j, inverseLength, columnIndices);
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices);
+      if (fixedInverseLength)
+        cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>();
+      else
+        cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices);
       return cov;
     }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMaternIso.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMaternIso.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMaternIso.cs	(revision 10489)
@@ -45,5 +45,10 @@
       get { return (IConstrainedValueParameter<IntValue>)Parameters["D"]; }
     }
-
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
+    private bool HasFixedInverseLengthParameter {
+      get { return InverseLengthParameter.Value != null; }
+    }
 
     [StorableConstructor]
@@ -76,6 +81,6 @@
     public int GetNumberOfParameters(int numberOfVariables) {
       return
-        (InverseLengthParameter.Value != null ? 0 : 1) +
-        (ScaleParameter.Value != null ? 0 : 1);
+        (HasFixedInverseLengthParameter ? 0 : 1) +
+        (HasFixedScaleParameter ? 0 : 1);
     }
 
@@ -90,5 +95,5 @@
       // gather parameter values
       int c = 0;
-      if (InverseLengthParameter.Value != null) {
+      if (HasFixedInverseLengthParameter) {
         inverseLength = InverseLengthParameter.Value.Value;
       } else {
@@ -97,5 +102,5 @@
       }
 
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -110,4 +115,6 @@
       int d = DParameter.Value.Value;
       GetParameterValues(p, out scale, out inverseLength);
+      var fixedInverseLength = HasFixedInverseLengthParameter;
+      var fixedScale = HasFixedScaleParameter;
       // create functions
       var cov = new ParameterizedCovarianceFunction();
@@ -122,5 +129,5 @@
         return scale * m(d, dist);
       };
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, d, scale, inverseLength, columnIndices);
+      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, d, scale, inverseLength, columnIndices, fixedInverseLength, fixedScale);
       return cov;
     }
@@ -149,11 +156,12 @@
 
 
-    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int d, double scale, double inverseLength, IEnumerable<int> columnIndices) {
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int d, double scale, double inverseLength, IEnumerable<int> columnIndices,
+      bool fixedInverseLength, bool fixedScale) {
       double dist = i == j
                    ? 0.0
                    : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength, columnIndices));
 
-      yield return scale * dm(d, dist);
-      yield return 2 * scale * m(d, dist);
+      if (!fixedInverseLength) yield return scale * dm(d, dist);
+      if (!fixedScale) yield return 2 * scale * m(d, dist);
     }
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNeuralNetwork.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNeuralNetwork.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNeuralNetwork.cs	(revision 10489)
@@ -43,4 +43,10 @@
       get { return (IValueParameter<DoubleValue>)Parameters["Length"]; }
     }
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
+    private bool HasFixedLengthParameter {
+      get { return LengthParameter.Value != null; }
+    }
 
     [StorableConstructor]
@@ -68,6 +74,6 @@
     public int GetNumberOfParameters(int numberOfVariables) {
       return
-        (ScaleParameter.Value != null ? 0 : 1) +
-        (LengthParameter.Value != null ? 0 : 1);
+        (HasFixedScaleParameter ? 0 : 1) +
+        (HasFixedLengthParameter ? 0 : 1);
     }
 
@@ -83,5 +89,5 @@
       // gather parameter values
       int c = 0;
-      if (LengthParameter.Value != null) {
+      if (HasFixedLengthParameter) {
         length = LengthParameter.Value.Value;
       } else {
@@ -90,5 +96,5 @@
       }
 
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -110,70 +116,58 @@
       double length, scale;
       GetParameterValues(p, out scale, out length);
-      // create functions
-      AutoDiff.Variable p0 = new AutoDiff.Variable();
-      AutoDiff.Variable p1 = new AutoDiff.Variable();
-      var l = TermBuilder.Exp(2.0 * p0);
-      var s = TermBuilder.Exp(2.0 * p1);
-      AutoDiff.Variable[] x1 = new AutoDiff.Variable[columnIndices.Count()];
-      AutoDiff.Variable[] x2 = new AutoDiff.Variable[columnIndices.Count()];
-      AutoDiff.Term sx = 1;
-      AutoDiff.Term s1 = 1;
-      AutoDiff.Term s2 = 1;
-      for (int k = 0; k < columnIndices.Count(); k++) {
-        x1[k] = new AutoDiff.Variable();
-        x2[k] = new AutoDiff.Variable();
-        sx += x1[k] * x2[k];
-        s1 += x1[k] * x1[k];
-        s2 += x2[k] * x2[k];
-      }
-
-      var parameter = x1.Concat(x2).Concat(new AutoDiff.Variable[] { p0, p1 }).ToArray();
-      var values = new double[x1.Length + x2.Length + 2];
-      var c = (s * asin(sx / (sqrt((l + s1) * (l + s2))))).Compile(parameter);
+      var fixedLength = HasFixedLengthParameter;
+      var fixedScale = HasFixedScaleParameter;
 
       var cov = new ParameterizedCovarianceFunction();
       cov.Covariance = (x, i, j) => {
-        int k = 0;
+        double sx = 1.0;
+        double s1 = 1.0;
+        double s2 = 1.0;
         foreach (var col in columnIndices) {
-          values[k] = x[i, col];
-          k++;
+          sx += x[i, col] * x[j, col];
+          s1 += x[i, col] * x[i, col];
+          s2 += x[j, col] * x[j, col];
         }
-        foreach (var col in columnIndices) {
-          values[k] = x[j, col];
-          k++;
-        }
-        values[k] = Math.Log(Math.Sqrt(length));
-        values[k + 1] = Math.Log(Math.Sqrt(scale));
-        return c.Evaluate(values);
+
+        return (scale * Math.Asin(sx / (Math.Sqrt((length + s1) * (length + s2)))));
       };
       cov.CrossCovariance = (x, xt, i, j) => {
-        int k = 0;
+        double sx = 1.0;
+        double s1 = 1.0;
+        double s2 = 1.0;
         foreach (var col in columnIndices) {
-          values[k] = x[i, col];
-          k++;
+          sx += x[i, col] * xt[j, col];
+          s1 += x[i, col] * x[i, col];
+          s2 += xt[j, col] * xt[j, col];
         }
+
+        return (scale * Math.Asin(sx / (Math.Sqrt((length + s1) * (length + s2)))));
+      };
+      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, length, scale, columnIndices, fixedLength, fixedScale);
+      return cov;
+    }
+
+    // order of returned gradients must match the order in GetParameterValues!
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double length, double scale, IEnumerable<int> columnIndices,
+      bool fixedLength, bool fixedScale) {
+      {
+        double sx = 1.0;
+        double s1 = 1.0;
+        double s2 = 1.0;
         foreach (var col in columnIndices) {
-          values[k] = xt[j, col];
-          k++;
+          sx += x[i, col] * x[j, col];
+          s1 += x[i, col] * x[i, col];
+          s2 += x[j, col] * x[j, col];
         }
-        values[k] = Math.Log(Math.Sqrt(length));
-        values[k + 1] = Math.Log(Math.Sqrt(scale));
-        return c.Evaluate(values);
+        var h = (length + s1) * (length + s2);
+        var f = sx / Math.Sqrt(h);
+        if (!fixedLength) {
+          yield return -scale / Math.Sqrt(1.0 - f * f) * ((length * sx * (2.0 * length + s1 + s2)) / Math.Pow(h, 3.0 / 2.0));
+        }
+        if (!fixedScale) {
+          yield return 2.0 * scale * Math.Asin(f);
+        }
+
       };
-      cov.CovarianceGradient = (x, i, j) => {
-        int k = 0;
-        foreach (var col in columnIndices) {
-          values[k] = x[i, col];
-          k++;
-        }
-        foreach (var col in columnIndices) {
-          values[k] = x[j, col];
-          k++;
-        }
-        values[k] = Math.Log(Math.Sqrt(length));
-        values[k + 1] = Math.Log(Math.Sqrt(scale));
-        return c.Differentiate(values).Item1.Skip(columnIndices.Count() * 2);
-      };
-      return cov;
     }
 
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNoise.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNoise.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNoise.cs	(revision 10489)
@@ -37,4 +37,7 @@
       get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; }
     }
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
 
     [StorableConstructor]
@@ -60,5 +63,5 @@
 
     public int GetNumberOfParameters(int numberOfVariables) {
-      return ScaleParameter.Value != null ? 0 : 1;
+      return HasFixedScaleParameter ? 0 : 1;
     }
 
@@ -72,5 +75,5 @@
       int c = 0;
       // gather parameter values
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -84,9 +87,13 @@
       double scale;
       GetParameterValues(p, out scale);
+      var fixedScale = HasFixedScaleParameter;
       // create functions
       var cov = new ParameterizedCovarianceFunction();
       cov.Covariance = (x, i, j) => i == j ? scale : 0.0;
       cov.CrossCovariance = (x, xt, i, j) => Util.SqrDist(x, i, xt, j, 1.0, columnIndices) < 1e-9 ? scale : 0.0;
-      cov.CovarianceGradient = (x, i, j) => Enumerable.Repeat(i == j ? 2.0 * scale : 0.0, 1);
+      if (fixedScale)
+        cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>();
+      else
+        cov.CovarianceGradient = (x, i, j) => Enumerable.Repeat(i == j ? 2.0 * scale : 0.0, 1);
       return cov;
     }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePeriodic.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePeriodic.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePeriodic.cs	(revision 10489)
@@ -46,4 +46,14 @@
     }
 
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
+    private bool HasFixedInverseLengthParameter {
+      get { return InverseLengthParameter.Value != null; }
+    }
+    private bool HasFixedPeriodParameter {
+      get { return PeriodParameter.Value != null; }
+    }
+
 
     [StorableConstructor]
@@ -68,7 +78,7 @@
 
     public int GetNumberOfParameters(int numberOfVariables) {
-      return (ScaleParameter.Value != null ? 0 : 1) +
-       (PeriodParameter.Value != null ? 0 : 1) +
-       (InverseLengthParameter.Value != null ? 0 : 1);
+      return (HasFixedScaleParameter ? 0 : 1) +
+       (HasFixedPeriodParameter ? 0 : 1) +
+       (HasFixedInverseLengthParameter ? 0 : 1);
     }
 
@@ -82,9 +92,9 @@
 
 
-    private void GetParameterValues(double[] 
+    private void GetParameterValues(double[]
       p, out double scale, out double period, out double inverseLength) {
       // gather parameter values
       int c = 0;
-      if (InverseLengthParameter.Value != null) {
+      if (HasFixedInverseLengthParameter) {
         inverseLength = InverseLengthParameter.Value.Value;
       } else {
@@ -92,5 +102,5 @@
         c++;
       }
-      if (PeriodParameter.Value != null) {
+      if (HasFixedPeriodParameter) {
         period = PeriodParameter.Value.Value;
       } else {
@@ -98,5 +108,5 @@
         c++;
       }
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -110,4 +120,7 @@
       double inverseLength, period, scale;
       GetParameterValues(p, out scale, out period, out inverseLength);
+      var fixedInverseLength = HasFixedInverseLengthParameter;
+      var fixedPeriod = HasFixedPeriodParameter;
+      var fixedScale = HasFixedScaleParameter;
       // create functions
       var cov = new ParameterizedCovarianceFunction();
@@ -128,17 +141,21 @@
         return scale * Math.Exp(-2.0 * k);
       };
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, period, inverseLength);
+      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, period, inverseLength, fixedInverseLength, fixedPeriod, fixedScale);
       return cov;
     }
 
 
-    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double period, double inverseLength) {
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double period, double inverseLength,
+      bool fixedInverseLength, bool fixedPeriod, bool fixedScale) {
       double k = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period;
       double gradient = Math.Sin(k) * inverseLength;
       gradient *= gradient;
-      yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient;
-      double r = Math.Sin(k) * inverseLength;
-      yield return 2.0 * k * scale * Math.Exp(-2 * r * r) *Math.Sin(2*k) * inverseLength * inverseLength;
-      yield return 2.0 * scale * Math.Exp(-2 * gradient); 
+      if (!fixedInverseLength) yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient;
+      if (!fixedPeriod) {
+        double r = Math.Sin(k) * inverseLength;
+        yield return 2.0 * k * scale * Math.Exp(-2 * r * r) * Math.Sin(2 * k) * inverseLength * inverseLength;
+      }
+      if (!fixedScale)
+        yield return 2.0 * scale * Math.Exp(-2 * gradient);
 
     }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePiecewisePolynomial.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePiecewisePolynomial.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePiecewisePolynomial.cs	(revision 10489)
@@ -45,4 +45,10 @@
       get { return (IConstrainedValueParameter<IntValue>)Parameters["V"]; }
     }
+    private bool HasFixedLengthParameter {
+      get { return LengthParameter.Value != null; }
+    }
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
 
     [StorableConstructor]
@@ -77,6 +83,6 @@
     public int GetNumberOfParameters(int numberOfVariables) {
       return
-        (LengthParameter.Value != null ? 0 : 1) +
-        (ScaleParameter.Value != null ? 0 : 1);
+        (HasFixedLengthParameter ? 0 : 1) +
+        (HasFixedScaleParameter ? 0 : 1);
     }
 
@@ -91,5 +97,5 @@
       // gather parameter values
       int n = 0;
-      if (LengthParameter.Value != null) {
+      if (HasFixedLengthParameter) {
         length = LengthParameter.Value.Value;
       } else {
@@ -98,5 +104,5 @@
       }
 
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -111,4 +117,6 @@
       int v = VParameter.Value.Value;
       GetParameterValues(p, out length, out scale);
+      var fixedLength = HasFixedLengthParameter;
+      var fixedScale = HasFixedScaleParameter;
       int exp = (int)Math.Floor(columnIndices.Count() / 2.0) + v + 1;
 
@@ -147,12 +155,13 @@
         return scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k);
       };
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, length, scale, v, exp, f, df, columnIndices);
+      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, length, scale, v, exp, f, df, columnIndices, fixedLength, fixedScale);
       return cov;
     }
 
-    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double length, double scale, int v, double exp, Func<double, double> f, Func<double, double> df, IEnumerable<int> columnIndices) {
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double length, double scale, int v, double exp, Func<double, double> f, Func<double, double> df, IEnumerable<int> columnIndices,
+      bool fixedLength, bool fixedScale) {
       double k = Math.Sqrt(Util.SqrDist(x, i, x, j, 1.0 / length, columnIndices));
-      yield return scale * Math.Pow(Math.Max(1.0 - k, 0), exp + v - 1) * k * ((exp + v) * f(k) - Math.Max(1 - k, 0) * df(k));
-      yield return 2.0 * scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k);
+      if (!fixedLength) yield return scale * Math.Pow(Math.Max(1.0 - k, 0), exp + v - 1) * k * ((exp + v) * f(k) - Math.Max(1 - k, 0) * df(k));
+      if (!fixedScale) yield return 2.0 * scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k);
     }
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePolynomial.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePolynomial.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePolynomial.cs	(revision 10489)
@@ -45,4 +45,10 @@
       get { return (IValueParameter<IntValue>)Parameters["Degree"]; }
     }
+    private bool HasFixedConstParameter {
+      get { return ConstParameter.Value != null; }
+    }
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
 
     [StorableConstructor]
@@ -71,6 +77,6 @@
     public int GetNumberOfParameters(int numberOfVariables) {
       return
-        (ConstParameter.Value != null ? 0 : 1) +
-        (ScaleParameter.Value != null ? 0 : 1);
+        (HasFixedConstParameter ? 0 : 1) +
+        (HasFixedScaleParameter ? 0 : 1);
     }
 
@@ -85,5 +91,5 @@
       // gather parameter values
       int n = 0;
-      if (ConstParameter.Value != null) {
+      if (HasFixedConstParameter) {
         @const = ConstParameter.Value.Value;
       } else {
@@ -92,5 +98,5 @@
       }
 
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -106,16 +112,19 @@
       if (degree <= 0) throw new ArgumentException("The degree parameter for CovariancePolynomial must be greater than zero.");
       GetParameterValues(p, out @const, out scale);
+      var fixedConst = HasFixedConstParameter;
+      var fixedScale = HasFixedScaleParameter;
       // create functions
       var cov = new ParameterizedCovarianceFunction();
       cov.Covariance = (x, i, j) => scale * Math.Pow(@const + Util.ScalarProd(x, i, j, 1.0, columnIndices), degree);
       cov.CrossCovariance = (x, xt, i, j) => scale * Math.Pow(@const + Util.ScalarProd(x, i, xt, j, 1.0, columnIndices), degree);
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, @const, scale, degree, columnIndices);
+      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, @const, scale, degree, columnIndices, fixedConst, fixedScale);
       return cov;
     }
 
-    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double c, double scale, int degree, IEnumerable<int> columnIndices) {
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double c, double scale, int degree, IEnumerable<int> columnIndices,
+      bool fixedConst, bool fixedScale) {
       double s = Util.ScalarProd(x, i, j, 1.0, columnIndices);
-      yield return c * degree * scale * Math.Pow(c + s, degree - 1);
-      yield return 2 * scale * Math.Pow(c + s, degree);
+      if (!fixedConst) yield return c * degree * scale * Math.Pow(c + s, degree - 1);
+      if (!fixedScale) yield return 2 * scale * Math.Pow(c + s, degree);
     }
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticArd.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticArd.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticArd.cs	(revision 10489)
@@ -45,4 +45,13 @@
       get { return (IValueParameter<DoubleValue>)Parameters["Shape"]; }
     }
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
+    private bool HasFixedInverseLengthParameter {
+      get { return InverseLengthParameter.Value != null; }
+    }
+    private bool HasFixedShapeParameter {
+      get { return ShapeParameter.Value != null; }
+    }
 
     [StorableConstructor]
@@ -71,7 +80,7 @@
     public int GetNumberOfParameters(int numberOfVariables) {
       return
-        (ScaleParameter.Value != null ? 0 : 1) +
-        (ShapeParameter.Value != null ? 0 : 1) +
-        (InverseLengthParameter.Value != null ? 0 : numberOfVariables);
+        (HasFixedScaleParameter ? 0 : 1) +
+        (HasFixedShapeParameter ? 0 : 1) +
+        (HasFixedInverseLengthParameter ? 0 : numberOfVariables);
     }
 
@@ -88,14 +97,14 @@
       int c = 0;
       // gather parameter values
-      if (InverseLengthParameter.Value != null) {
+      if (HasFixedInverseLengthParameter) {
         inverseLength = InverseLengthParameter.Value.ToArray();
       } else {
         int length = p.Length;
-        if (ScaleParameter.Value == null) length--;
-        if (ShapeParameter.Value == null) length--;
+        if (!HasFixedScaleParameter) length--;
+        if (!HasFixedShapeParameter) length--;
         inverseLength = p.Select(e => 1.0 / Math.Exp(e)).Take(length).ToArray();
         c += inverseLength.Length;
       }
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -103,5 +112,5 @@
         c++;
       }
-      if (ShapeParameter.Value != null) {
+      if (HasFixedShapeParameter) {
         shape = ShapeParameter.Value.Value;
       } else {
@@ -116,4 +125,7 @@
       double[] inverseLength;
       GetParameterValues(p, out scale, out shape, out inverseLength);
+      var fixedInverseLength = HasFixedInverseLengthParameter;
+      var fixedScale = HasFixedScaleParameter;
+      var fixedShape = HasFixedShapeParameter;
       // create functions
       var cov = new ParameterizedCovarianceFunction();
@@ -128,9 +140,10 @@
         return scale * Math.Pow(1 + 0.5 * d / shape, -shape);
       };
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength);
+      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength, fixedInverseLength, fixedScale, fixedShape);
       return cov;
     }
 
-    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double[] inverseLength) {
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double[] inverseLength,
+      bool fixedInverseLength, bool fixedScale, bool fixedShape) {
       double d = i == j
                    ? 0.0
@@ -138,10 +151,14 @@
       double b = 1 + 0.5 * d / shape;
       int k = 0;
-      foreach (var columnIndex in columnIndices) {
-        yield return scale * Math.Pow(b, -shape - 1) * Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
-        k++;
+      if (!fixedInverseLength) {
+        foreach (var columnIndex in columnIndices) {
+          yield return
+            scale * Math.Pow(b, -shape - 1) *
+            Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
+          k++;
+        }
       }
-      yield return 2 * scale * Math.Pow(b, -shape);
-      yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));
+      if (!fixedScale) yield return 2 * scale * Math.Pow(b, -shape);
+      if (!fixedShape) yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));
     }
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticIso.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticIso.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticIso.cs	(revision 10489)
@@ -44,4 +44,16 @@
       get { return (IValueParameter<DoubleValue>)Parameters["Shape"]; }
     }
+
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
+    private bool HasFixedInverseLengthParameter {
+      get { return InverseLengthParameter.Value != null; }
+    }
+    private bool HasFixedShapeParameter {
+      get { return ShapeParameter.Value != null; }
+    }
+
+
     [StorableConstructor]
     private CovarianceRationalQuadraticIso(bool deserializing)
@@ -68,7 +80,7 @@
 
     public int GetNumberOfParameters(int numberOfVariables) {
-      return (ScaleParameter.Value != null ? 0 : 1) +
-        (ShapeParameter.Value != null ? 0 : 1) +
-        (InverseLengthParameter.Value != null ? 0 : 1);
+      return (HasFixedScaleParameter ? 0 : 1) +
+        (HasFixedShapeParameter ? 0 : 1) +
+        (HasFixedInverseLengthParameter ? 0 : 1);
     }
 
@@ -84,5 +96,5 @@
       int c = 0;
       // gather parameter values
-      if (InverseLengthParameter.Value != null) {
+      if (HasFixedInverseLengthParameter) {
         inverseLength = InverseLengthParameter.Value.Value;
       } else {
@@ -90,5 +102,5 @@
         c++;
       }
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -96,5 +108,5 @@
         c++;
       }
-      if (ShapeParameter.Value != null) {
+      if (HasFixedShapeParameter) {
         shape = ShapeParameter.Value.Value;
       } else {
@@ -108,4 +120,7 @@
       double scale, shape, inverseLength;
       GetParameterValues(p, out scale, out shape, out inverseLength);
+      var fixedInverseLength = HasFixedInverseLengthParameter;
+      var fixedScale = HasFixedScaleParameter;
+      var fixedShape = HasFixedShapeParameter;
       // create functions
       var cov = new ParameterizedCovarianceFunction();
@@ -120,9 +135,10 @@
         return scale * Math.Pow(1 + 0.5 * d / shape, -shape);
       };
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength);
+      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength, fixedInverseLength, fixedScale, fixedShape);
       return cov;
     }
 
-    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double inverseLength) {
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double inverseLength,
+      bool fixedInverseLength, bool fixedScale, bool fixedShape) {
       double d = i == j
                    ? 0.0
@@ -130,7 +146,7 @@
 
       double b = 1 + 0.5 * d / shape;
-      yield return scale * Math.Pow(b, -shape - 1) * d;
-      yield return 2 * scale * Math.Pow(b, -shape);
-      yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));
+      if (!fixedInverseLength) yield return scale * Math.Pow(b, -shape - 1) * d;
+      if (!fixedScale) yield return 2 * scale * Math.Pow(b, -shape);
+      if (!fixedShape) yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));
     }
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceScale.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceScale.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceScale.cs	(revision 10489)
@@ -37,4 +37,7 @@
       get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; }
     }
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
 
     public IValueParameter<ICovarianceFunction> CovarianceFunctionParameter {
@@ -65,5 +68,5 @@
 
     public int GetNumberOfParameters(int numberOfVariables) {
-      return (ScaleParameter.Value != null ? 0 : 1) + CovarianceFunctionParameter.Value.GetNumberOfParameters(numberOfVariables);
+      return (HasFixedScaleParameter ? 0 : 1) + CovarianceFunctionParameter.Value.GetNumberOfParameters(numberOfVariables);
     }
 
@@ -77,5 +80,5 @@
     private void GetParameterValues(double[] p, out double scale) {
       // gather parameter values
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -87,4 +90,5 @@
       double scale;
       GetParameterValues(p, out scale);
+      var fixedScale = HasFixedScaleParameter;
       var subCov = CovarianceFunctionParameter.Value.GetParameterizedCovarianceFunction(p.Skip(1).ToArray(), columnIndices);
       // create functions
@@ -92,10 +96,13 @@
       cov.Covariance = (x, i, j) => scale * subCov.Covariance(x, i, j);
       cov.CrossCovariance = (x, xt, i, j) => scale * subCov.CrossCovariance(x, xt, i, j);
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, subCov);
+      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, subCov, fixedScale);
       return cov;
     }
 
-    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, ParameterizedCovarianceFunction cov) {
-      yield return 2 * scale * cov.Covariance(x, i, j);
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, ParameterizedCovarianceFunction cov,
+      bool fixedScale) {
+      if (!fixedScale) {
+        yield return 2 * scale * cov.Covariance(x, i, j);
+      }
       foreach (var g in cov.CovarianceGradient(x, i, j))
         yield return scale * g;
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSpectralMixture.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSpectralMixture.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSpectralMixture.cs	(revision 10489)
@@ -54,4 +54,14 @@
     }
 
+    private bool HasFixedWeightParameter {
+      get { return WeightParameter.Value != null; }
+    }
+    private bool HasFixedFrequencyParameter {
+      get { return FrequencyParameter.Value != null; }
+    }
+    private bool HasFixedLengthScaleParameter {
+      get { return LengthScaleParameter.Value != null; }
+    }
+
     [StorableConstructor]
     private CovarianceSpectralMixture(bool deserializing)
@@ -80,7 +90,7 @@
       var q = QParameter.Value.Value;
       return
-        (WeightParameter.Value != null ? 0 : q) +
-        (FrequencyParameter.Value != null ? 0 : q * numberOfVariables) +
-        (LengthScaleParameter.Value != null ? 0 : q * numberOfVariables);
+        (HasFixedWeightParameter ? 0 : q) +
+        (HasFixedFrequencyParameter ? 0 : q * numberOfVariables) +
+        (HasFixedLengthScaleParameter ? 0 : q * numberOfVariables);
     }
 
@@ -100,5 +110,5 @@
       // guess number of elements for frequency and length (=q * numberOfVariables)
       int n = WeightParameter.Value == null ? ((p.Length - q) / 2) : (p.Length / 2);
-      if (WeightParameter.Value != null) {
+      if (HasFixedWeightParameter) {
         weight = WeightParameter.Value.ToArray();
       } else {
@@ -106,5 +116,5 @@
         c += q;
       }
-      if (FrequencyParameter.Value != null) {
+      if (HasFixedFrequencyParameter) {
         frequency = FrequencyParameter.Value.ToArray();
       } else {
@@ -112,5 +122,5 @@
         c += n;
       }
-      if (LengthScaleParameter.Value != null) {
+      if (HasFixedLengthScaleParameter) {
         lengthScale = LengthScaleParameter.Value.ToArray();
       } else {
@@ -124,4 +134,7 @@
       double[] weight, frequency, lengthScale;
       GetParameterValues(p, out weight, out frequency, out lengthScale);
+      var fixedWeight = HasFixedWeightParameter;
+      var fixedFrequency = HasFixedFrequencyParameter;
+      var fixedLengthScale = HasFixedLengthScaleParameter;
       // create functions
       var cov = new ParameterizedCovarianceFunction();
@@ -135,5 +148,5 @@
       };
       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, QParameter.Value.Value, weight, frequency,
-                             lengthScale, columnIndices);
+                             lengthScale, columnIndices, fixedWeight, fixedFrequency, fixedLengthScale);
       return cov;
     }
@@ -168,47 +181,55 @@
 
     // order of returned gradients must match the order in GetParameterValues!
-    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int maxQ, double[] weight, double[] frequency, double[] lengthScale, IEnumerable<int> columnIndices) {
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int maxQ, double[] weight, double[] frequency, double[] lengthScale, IEnumerable<int> columnIndices,
+      bool fixedWeight, bool fixedFrequency, bool fixedLengthScale) {
       double[] tau = Util.GetRow(x, i, columnIndices).Zip(Util.GetRow(x, j, columnIndices), (xi, xj) => xi - xj).ToArray();
       int numberOfVariables = lengthScale.Length / maxQ;
 
-      // weight
-      // for each component
-      for (int q = 0; q < maxQ; q++) {
-        double k = weight[q]; 
-        int idx = 0; // helper index for tau
-        // for each selected variable
-        foreach (var c in columnIndices) {
-          k *= f1(tau[idx], lengthScale[q * numberOfVariables + c]) * f2(tau[idx], frequency[q * numberOfVariables + c]);
-          idx++;
-        }
-        yield return k;
-      }
-
-      // frequency
-      // for each component
-      for (int q = 0; q < maxQ; q++) {
-        int idx = 0; // helper index for tau
-        // for each selected variable
-        foreach (var c in columnIndices) {
-          double k = f1(tau[idx], lengthScale[q * numberOfVariables + c]) *
-            -2 * Math.PI * tau[idx] * frequency[q * numberOfVariables + c] * Math.Sin(2 * Math.PI * tau[idx] * frequency[q * numberOfVariables + c]);
-          idx++;
-          yield return weight[q] * k;
-        }
-      }
-
-      // length scale
-      // for each component
-      for (int q = 0; q < maxQ; q++) {
-        int idx = 0; // helper index for tau
-        // for each selected variable
-        foreach (var c in columnIndices) {
-          double k = -2 * Math.PI * Math.PI * tau[idx] * tau[idx] * lengthScale[q * numberOfVariables + c] *
-             f1(tau[idx], lengthScale[q * numberOfVariables + c]) * f2(tau[idx], frequency[q * numberOfVariables + c]);
-          idx++;
-          yield return weight[q] * k;
-        }
-      }
-
+      if (!fixedWeight) {
+        // weight
+        // for each component
+        for (int q = 0; q < maxQ; q++) {
+          double k = weight[q];
+          int idx = 0; // helper index for tau
+          // for each selected variable
+          foreach (var c in columnIndices) {
+            k *= f1(tau[idx], lengthScale[q * numberOfVariables + c]) * f2(tau[idx], frequency[q * numberOfVariables + c]);
+            idx++;
+          }
+          yield return k;
+        }
+      }
+
+      if (!fixedFrequency) {
+        // frequency
+        // for each component
+        for (int q = 0; q < maxQ; q++) {
+          int idx = 0; // helper index for tau
+          // for each selected variable
+          foreach (var c in columnIndices) {
+            double k = f1(tau[idx], lengthScale[q * numberOfVariables + c]) *
+                       -2 * Math.PI * tau[idx] * frequency[q * numberOfVariables + c] *
+                       Math.Sin(2 * Math.PI * tau[idx] * frequency[q * numberOfVariables + c]);
+            idx++;
+            yield return weight[q] * k;
+          }
+        }
+      }
+
+      if (!fixedLengthScale) {
+        // length scale
+        // for each component
+        for (int q = 0; q < maxQ; q++) {
+          int idx = 0; // helper index for tau
+          // for each selected variable
+          foreach (var c in columnIndices) {
+            double k = -2 * Math.PI * Math.PI * tau[idx] * tau[idx] * lengthScale[q * numberOfVariables + c] *
+                       f1(tau[idx], lengthScale[q * numberOfVariables + c]) *
+                       f2(tau[idx], frequency[q * numberOfVariables + c]);
+            idx++;
+            yield return weight[q] * k;
+          }
+        }
+      }
     }
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialArd.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialArd.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialArd.cs	(revision 10489)
@@ -40,4 +40,10 @@
       get { return (IValueParameter<DoubleArray>)Parameters["InverseLength"]; }
     }
+    private bool HasFixedInverseLengthParameter {
+      get { return InverseLengthParameter.Value != null; }
+    }
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
 
     [StorableConstructor]
@@ -61,6 +67,6 @@
     public int GetNumberOfParameters(int numberOfVariables) {
       return
-        (ScaleParameter.Value != null ? 0 : 1) +
-        (InverseLengthParameter.Value != null ? 0 : numberOfVariables);
+        (HasFixedScaleParameter ? 0 : 1) +
+        (HasFixedInverseLengthParameter ? 0 : numberOfVariables);
     }
 
@@ -76,13 +82,13 @@
       int c = 0;
       // gather parameter values
-      if (InverseLengthParameter.Value != null) {
+      if (HasFixedInverseLengthParameter) {
         inverseLength = InverseLengthParameter.Value.ToArray();
       } else {
         int length = p.Length;
-        if (ScaleParameter.Value == null) length--;
+        if (HasFixedScaleParameter) length--;
         inverseLength = p.Select(e => 1.0 / Math.Exp(e)).Take(length).ToArray();
         c += inverseLength.Length;
       }
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -97,4 +103,6 @@
       double[] inverseLength;
       GetParameterValues(p, out scale, out inverseLength);
+      var fixedInverseLength = HasFixedInverseLengthParameter;
+      var fixedScale = HasFixedScaleParameter;
       // create functions
       var cov = new ParameterizedCovarianceFunction();
@@ -109,10 +117,11 @@
         return scale * Math.Exp(-d / 2.0);
       };
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, inverseLength);
+      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, inverseLength, fixedInverseLength, fixedScale);
       return cov;
     }
 
     // order of returned gradients must match the order in GetParameterValues!
-    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double[] inverseLength) {
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double[] inverseLength,
+      bool fixedInverseLength, bool fixedScale) {
       double d = i == j
                    ? 0.0
@@ -120,10 +129,12 @@
 
       int k = 0;
-      foreach (var columnIndex in columnIndices) {
-        double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
-        yield return scale * Math.Exp(-d / 2.0) * sqrDist;
-        k++;
+      if (!fixedInverseLength) {
+        foreach (var columnIndex in columnIndices) {
+          double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
+          yield return scale * Math.Exp(-d / 2.0) * sqrDist;
+          k++;
+        }
       }
-      yield return 2.0 * scale * Math.Exp(-d / 2.0);
+      if (!fixedScale) yield return 2.0 * scale * Math.Exp(-d / 2.0);
     }
   }
Index: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialIso.cs
===================================================================
--- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialIso.cs	(revision 10488)
+++ trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialIso.cs	(revision 10489)
@@ -42,4 +42,11 @@
     }
 
+    private bool HasFixedInverseLengthParameter {
+      get { return InverseLengthParameter.Value != null; }
+    }
+    private bool HasFixedScaleParameter {
+      get { return ScaleParameter.Value != null; }
+    }
+
     [StorableConstructor]
     private CovarianceSquaredExponentialIso(bool deserializing)
@@ -66,6 +73,6 @@
     public int GetNumberOfParameters(int numberOfVariables) {
       return
-        (ScaleParameter.Value != null ? 0 : 1) +
-        (InverseLengthParameter.Value != null ? 0 : 1);
+        (HasFixedScaleParameter ? 0 : 1) +
+        (HasFixedInverseLengthParameter ? 0 : 1);
     }
 
@@ -81,5 +88,5 @@
       // gather parameter values
       int c = 0;
-      if (InverseLengthParameter.Value != null) {
+      if (HasFixedInverseLengthParameter) {
         inverseLength = InverseLengthParameter.Value.Value;
       } else {
@@ -88,5 +95,5 @@
       }
 
-      if (ScaleParameter.Value != null) {
+      if (HasFixedScaleParameter) {
         scale = ScaleParameter.Value.Value;
       } else {
@@ -100,4 +107,6 @@
       double inverseLength, scale;
       GetParameterValues(p, out scale, out inverseLength);
+      var fixedInverseLength = HasFixedInverseLengthParameter;
+      var fixedScale = HasFixedScaleParameter;
       // create functions
       var cov = new ParameterizedCovarianceFunction();
@@ -112,16 +121,18 @@
         return scale * Math.Exp(-d / 2.0);
       };
-      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, inverseLength, columnIndices);
+      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, inverseLength, columnIndices,
+        fixedInverseLength, fixedScale);
       return cov;
     }
 
     // order of returned gradients must match the order in GetParameterValues!
-    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double sf2, double inverseLength, IEnumerable<int> columnIndices) {
+    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double sf2, double inverseLength, IEnumerable<int> columnIndices, 
+      bool fixedInverseLength, bool fixedScale) {
       double d = i == j
                    ? 0.0
                    : Util.SqrDist(x, i, j, inverseLength, columnIndices);
       double g = Math.Exp(-d / 2.0);
-      yield return sf2 * g * d;
-      yield return 2.0 * sf2 * g;
+      if (!fixedInverseLength) yield return sf2 * g * d;
+      if (!fixedScale) yield return 2.0 * sf2 * g;
     }
   }
