Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/27/14 11:23:37 (10 years ago)
Author:
jkarder
Message:

#2116: merged r10041-r11593 from trunk into branch

Location:
branches/Breadcrumbs
Files:
38 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/Breadcrumbs

  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis

  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceConst.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    3637      get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; }
    3738    }
    38 
     39    private bool HasFixedScaleParameter {
     40      get { return ScaleParameter.Value != null; }
     41    }
    3942    [StorableConstructor]
    4043    private CovarianceConst(bool deserializing)
     
    5962
    6063    public int GetNumberOfParameters(int numberOfVariables) {
    61       return ScaleParameter.Value != null ? 0 : 1;
     64      return HasFixedScaleParameter ? 0 : 1;
    6265    }
    6366
     
    7174      int c = 0;
    7275      // gather parameter values
    73       if (ScaleParameter.Value != null) {
     76      if (HasFixedScaleParameter) {
    7477        scale = ScaleParameter.Value.Value;
    7578      } else {
     
    8790      cov.Covariance = (x, i, j) => scale;
    8891      cov.CrossCovariance = (x, xt, i, j) => scale;
    89       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, columnIndices);
     92      if (HasFixedScaleParameter) {
     93        cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>();
     94      } else {
     95        cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, columnIndices);
     96      }
    9097      return cov;
    9198    }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinear.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3737      get { return (IValueParameter<DoubleArray>)Parameters["InverseLength"]; }
    3838    }
     39    private bool HasFixedInverseLengthParameter {
     40      get { return InverseLengthParameter.Value != null; }
     41    }
    3942
    4043    [StorableConstructor]
     
    5760
    5861    public int GetNumberOfParameters(int numberOfVariables) {
    59       if (InverseLengthParameter.Value == null)
     62      if (HasFixedInverseLengthParameter)
     63        return 0;
     64      else
    6065        return numberOfVariables;
    61       else
    62         return 0;
    6366    }
    6467
     
    7174    private void GetParameterValues(double[] p, out double[] inverseLength) {
    7275      // gather parameter values
    73       if (InverseLengthParameter.Value != null) {
     76      if (HasFixedInverseLengthParameter) {
    7477        inverseLength = InverseLengthParameter.Value.ToArray();
    7578      } else {
     
    8184      double[] inverseLength;
    8285      GetParameterValues(p, out inverseLength);
     86      var fixedInverseLength = HasFixedInverseLengthParameter;
    8387      // create functions
    8488      var cov = new ParameterizedCovarianceFunction();
    8589      cov.Covariance = (x, i, j) => Util.ScalarProd(x, i, j, inverseLength, columnIndices);
    8690      cov.CrossCovariance = (x, xt, i, j) => Util.ScalarProd(x, i, xt, j, inverseLength, columnIndices);
    87       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices);
     91      if (fixedInverseLength)
     92        cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>();
     93      else
     94        cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices);
    8895      return cov;
    8996    }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMask.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMaternIso.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4545      get { return (IConstrainedValueParameter<IntValue>)Parameters["D"]; }
    4646    }
    47 
     47    private bool HasFixedScaleParameter {
     48      get { return ScaleParameter.Value != null; }
     49    }
     50    private bool HasFixedInverseLengthParameter {
     51      get { return InverseLengthParameter.Value != null; }
     52    }
    4853
    4954    [StorableConstructor]
     
    7681    public int GetNumberOfParameters(int numberOfVariables) {
    7782      return
    78         (InverseLengthParameter.Value != null ? 0 : 1) +
    79         (ScaleParameter.Value != null ? 0 : 1);
     83        (HasFixedInverseLengthParameter ? 0 : 1) +
     84        (HasFixedScaleParameter ? 0 : 1);
    8085    }
    8186
     
    9095      // gather parameter values
    9196      int c = 0;
    92       if (InverseLengthParameter.Value != null) {
     97      if (HasFixedInverseLengthParameter) {
    9398        inverseLength = InverseLengthParameter.Value.Value;
    9499      } else {
     
    97102      }
    98103
    99       if (ScaleParameter.Value != null) {
     104      if (HasFixedScaleParameter) {
    100105        scale = ScaleParameter.Value.Value;
    101106      } else {
     
    110115      int d = DParameter.Value.Value;
    111116      GetParameterValues(p, out scale, out inverseLength);
     117      var fixedInverseLength = HasFixedInverseLengthParameter;
     118      var fixedScale = HasFixedScaleParameter;
    112119      // create functions
    113120      var cov = new ParameterizedCovarianceFunction();
     
    122129        return scale * m(d, dist);
    123130      };
    124       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, d, scale, inverseLength, columnIndices);
     131      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, d, scale, inverseLength, columnIndices, fixedInverseLength, fixedScale);
    125132      return cov;
    126133    }
     
    149156
    150157
    151     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int d, double scale, double inverseLength, IEnumerable<int> columnIndices) {
     158    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, int d, double scale, double inverseLength, IEnumerable<int> columnIndices,
     159      bool fixedInverseLength, bool fixedScale) {
    152160      double dist = i == j
    153161                   ? 0.0
    154162                   : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength, columnIndices));
    155163
    156       yield return scale * dm(d, dist);
    157       yield return 2 * scale * m(d, dist);
     164      if (!fixedInverseLength) yield return scale * dm(d, dist);
     165      if (!fixedScale) yield return 2 * scale * m(d, dist);
    158166    }
    159167  }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNeuralNetwork.cs

    r9542 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Linq.Expressions;
    26 using AutoDiff;
    2724using HeuristicLab.Common;
    2825using HeuristicLab.Core;
     
    4239    public IValueParameter<DoubleValue> LengthParameter {
    4340      get { return (IValueParameter<DoubleValue>)Parameters["Length"]; }
     41    }
     42    private bool HasFixedScaleParameter {
     43      get { return ScaleParameter.Value != null; }
     44    }
     45    private bool HasFixedLengthParameter {
     46      get { return LengthParameter.Value != null; }
    4447    }
    4548
     
    6871    public int GetNumberOfParameters(int numberOfVariables) {
    6972      return
    70         (ScaleParameter.Value != null ? 0 : 1) +
    71         (LengthParameter.Value != null ? 0 : 1);
     73        (HasFixedScaleParameter ? 0 : 1) +
     74        (HasFixedLengthParameter ? 0 : 1);
    7275    }
    7376
     
    8386      // gather parameter values
    8487      int c = 0;
    85       if (LengthParameter.Value != null) {
     88      if (HasFixedLengthParameter) {
    8689        length = LengthParameter.Value.Value;
    8790      } else {
     
    9093      }
    9194
    92       if (ScaleParameter.Value != null) {
     95      if (HasFixedScaleParameter) {
    9396        scale = ScaleParameter.Value.Value;
    9497      } else {
     
    99102    }
    100103
    101 
    102     private static Func<Term, UnaryFunc> asin = UnaryFunc.Factory(
    103         x => Math.Asin(x),      // evaluate
    104         x => 1 / Math.Sqrt(1 - x * x));  // derivative of atan
    105     private static Func<Term, UnaryFunc> sqrt = UnaryFunc.Factory(
    106       x => Math.Sqrt(x),
    107       x => 1 / (2 * Math.Sqrt(x)));
    108 
    109104    public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, IEnumerable<int> columnIndices) {
    110105      double length, scale;
    111106      GetParameterValues(p, out scale, out length);
    112       // create functions
    113       AutoDiff.Variable p0 = new AutoDiff.Variable();
    114       AutoDiff.Variable p1 = new AutoDiff.Variable();
    115       var l = TermBuilder.Exp(2.0 * p0);
    116       var s = TermBuilder.Exp(2.0 * p1);
    117       AutoDiff.Variable[] x1 = new AutoDiff.Variable[columnIndices.Count()];
    118       AutoDiff.Variable[] x2 = new AutoDiff.Variable[columnIndices.Count()];
    119       AutoDiff.Term sx = 1;
    120       AutoDiff.Term s1 = 1;
    121       AutoDiff.Term s2 = 1;
    122       for (int k = 0; k < columnIndices.Count(); k++) {
    123         x1[k] = new AutoDiff.Variable();
    124         x2[k] = new AutoDiff.Variable();
    125         sx += x1[k] * x2[k];
    126         s1 += x1[k] * x1[k];
    127         s2 += x2[k] * x2[k];
    128       }
    129 
    130       var parameter = x1.Concat(x2).Concat(new AutoDiff.Variable[] { p0, p1 }).ToArray();
    131       var values = new double[x1.Length + x2.Length + 2];
    132       var c = (s * asin(sx / (sqrt((l + s1) * (l + s2))))).Compile(parameter);
     107      var fixedLength = HasFixedLengthParameter;
     108      var fixedScale = HasFixedScaleParameter;
    133109
    134110      var cov = new ParameterizedCovarianceFunction();
    135111      cov.Covariance = (x, i, j) => {
    136         int k = 0;
     112        double sx = 1.0;
     113        double s1 = 1.0;
     114        double s2 = 1.0;
    137115        foreach (var col in columnIndices) {
    138           values[k] = x[i, col];
    139           k++;
     116          sx += x[i, col] * x[j, col];
     117          s1 += x[i, col] * x[i, col];
     118          s2 += x[j, col] * x[j, col];
    140119        }
    141         foreach (var col in columnIndices) {
    142           values[k] = x[j, col];
    143           k++;
    144         }
    145         values[k] = Math.Log(Math.Sqrt(length));
    146         values[k + 1] = Math.Log(Math.Sqrt(scale));
    147         return c.Evaluate(values);
     120
     121        return (scale * Math.Asin(sx / (Math.Sqrt((length + s1) * (length + s2)))));
    148122      };
    149123      cov.CrossCovariance = (x, xt, i, j) => {
    150         int k = 0;
     124        double sx = 1.0;
     125        double s1 = 1.0;
     126        double s2 = 1.0;
    151127        foreach (var col in columnIndices) {
    152           values[k] = x[i, col];
    153           k++;
     128          sx += x[i, col] * xt[j, col];
     129          s1 += x[i, col] * x[i, col];
     130          s2 += xt[j, col] * xt[j, col];
    154131        }
    155         foreach (var col in columnIndices) {
    156           values[k] = xt[j, col];
    157           k++;
    158         }
    159         values[k] = Math.Log(Math.Sqrt(length));
    160         values[k + 1] = Math.Log(Math.Sqrt(scale));
    161         return c.Evaluate(values);
     132
     133        return (scale * Math.Asin(sx / (Math.Sqrt((length + s1) * (length + s2)))));
    162134      };
    163       cov.CovarianceGradient = (x, i, j) => {
    164         int k = 0;
    165         foreach (var col in columnIndices) {
    166           values[k] = x[i, col];
    167           k++;
    168         }
    169         foreach (var col in columnIndices) {
    170           values[k] = x[j, col];
    171           k++;
    172         }
    173         values[k] = Math.Log(Math.Sqrt(length));
    174         values[k + 1] = Math.Log(Math.Sqrt(scale));
    175         return c.Differentiate(values).Item1.Skip(columnIndices.Count() * 2);
    176       };
     135      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, length, scale, columnIndices, fixedLength, fixedScale);
    177136      return cov;
    178137    }
    179138
     139    // order of returned gradients must match the order in GetParameterValues!
     140    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double length, double scale, IEnumerable<int> columnIndices,
     141      bool fixedLength, bool fixedScale) {
     142      {
     143        double sx = 1.0;
     144        double s1 = 1.0;
     145        double s2 = 1.0;
     146        foreach (var col in columnIndices) {
     147          sx += x[i, col] * x[j, col];
     148          s1 += x[i, col] * x[i, col];
     149          s2 += x[j, col] * x[j, col];
     150        }
     151        var h = (length + s1) * (length + s2);
     152        var f = sx / Math.Sqrt(h);
     153        if (!fixedLength) {
     154          yield return -scale / Math.Sqrt(1.0 - f * f) * ((length * sx * (2.0 * length + s1 + s2)) / Math.Pow(h, 3.0 / 2.0));
     155        }
     156        if (!fixedScale) {
     157          yield return 2.0 * scale * Math.Asin(f);
     158        }
     159      }
     160    }
    180161  }
    181162}
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNoise.cs

    r9544 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3737      get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; }
    3838    }
     39    private bool HasFixedScaleParameter {
     40      get { return ScaleParameter.Value != null; }
     41    }
    3942
    4043    [StorableConstructor]
     
    6063
    6164    public int GetNumberOfParameters(int numberOfVariables) {
    62       return ScaleParameter.Value != null ? 0 : 1;
     65      return HasFixedScaleParameter ? 0 : 1;
    6366    }
    6467
     
    7275      int c = 0;
    7376      // gather parameter values
    74       if (ScaleParameter.Value != null) {
     77      if (HasFixedScaleParameter) {
    7578        scale = ScaleParameter.Value.Value;
    7679      } else {
     
    8487      double scale;
    8588      GetParameterValues(p, out scale);
     89      var fixedScale = HasFixedScaleParameter;
    8690      // create functions
    8791      var cov = new ParameterizedCovarianceFunction();
    8892      cov.Covariance = (x, i, j) => i == j ? scale : 0.0;
    8993      cov.CrossCovariance = (x, xt, i, j) => Util.SqrDist(x, i, xt, j, 1.0, columnIndices) < 1e-9 ? scale : 0.0;
    90       cov.CovarianceGradient = (x, i, j) => Enumerable.Repeat(i == j ? 2.0 * scale : 0.0, 1);
     94      if (fixedScale)
     95        cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>();
     96      else
     97        cov.CovarianceGradient = (x, i, j) => Enumerable.Repeat(i == j ? 2.0 * scale : 0.0, 1);
    9198      return cov;
    9299    }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePeriodic.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4646    }
    4747
     48    private bool HasFixedScaleParameter {
     49      get { return ScaleParameter.Value != null; }
     50    }
     51    private bool HasFixedInverseLengthParameter {
     52      get { return InverseLengthParameter.Value != null; }
     53    }
     54    private bool HasFixedPeriodParameter {
     55      get { return PeriodParameter.Value != null; }
     56    }
     57
    4858
    4959    [StorableConstructor]
     
    6878
    6979    public int GetNumberOfParameters(int numberOfVariables) {
    70       return (ScaleParameter.Value != null ? 0 : 1) +
    71        (PeriodParameter.Value != null ? 0 : 1) +
    72        (InverseLengthParameter.Value != null ? 0 : 1);
     80      return (HasFixedScaleParameter ? 0 : 1) +
     81       (HasFixedPeriodParameter ? 0 : 1) +
     82       (HasFixedInverseLengthParameter ? 0 : 1);
    7383    }
    7484
     
    8292
    8393
    84     private void GetParameterValues(double[] 
     94    private void GetParameterValues(double[]
    8595      p, out double scale, out double period, out double inverseLength) {
    8696      // gather parameter values
    8797      int c = 0;
    88       if (InverseLengthParameter.Value != null) {
     98      if (HasFixedInverseLengthParameter) {
    8999        inverseLength = InverseLengthParameter.Value.Value;
    90100      } else {
     
    92102        c++;
    93103      }
    94       if (PeriodParameter.Value != null) {
     104      if (HasFixedPeriodParameter) {
    95105        period = PeriodParameter.Value.Value;
    96106      } else {
     
    98108        c++;
    99109      }
    100       if (ScaleParameter.Value != null) {
     110      if (HasFixedScaleParameter) {
    101111        scale = ScaleParameter.Value.Value;
    102112      } else {
     
    110120      double inverseLength, period, scale;
    111121      GetParameterValues(p, out scale, out period, out inverseLength);
     122      var fixedInverseLength = HasFixedInverseLengthParameter;
     123      var fixedPeriod = HasFixedPeriodParameter;
     124      var fixedScale = HasFixedScaleParameter;
    112125      // create functions
    113126      var cov = new ParameterizedCovarianceFunction();
     
    128141        return scale * Math.Exp(-2.0 * k);
    129142      };
    130       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, period, inverseLength);
     143      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, period, inverseLength, fixedInverseLength, fixedPeriod, fixedScale);
    131144      return cov;
    132145    }
    133146
    134147
    135     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double period, double inverseLength) {
     148    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double period, double inverseLength,
     149      bool fixedInverseLength, bool fixedPeriod, bool fixedScale) {
    136150      double k = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period;
    137151      double gradient = Math.Sin(k) * inverseLength;
    138152      gradient *= gradient;
    139       yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient;
    140       double r = Math.Sin(k) * inverseLength;
    141       yield return 2.0 * k * scale * Math.Exp(-2 * r * r) *Math.Sin(2*k) * inverseLength * inverseLength;
    142       yield return 2.0 * scale * Math.Exp(-2 * gradient);
     153      if (!fixedInverseLength) yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient;
     154      if (!fixedPeriod) {
     155        double r = Math.Sin(k) * inverseLength;
     156        yield return 2.0 * k * scale * Math.Exp(-2 * r * r) * Math.Sin(2 * k) * inverseLength * inverseLength;
     157      }
     158      if (!fixedScale)
     159        yield return 2.0 * scale * Math.Exp(-2 * gradient);
    143160
    144161    }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePiecewisePolynomial.cs

    r9543 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4545      get { return (IConstrainedValueParameter<IntValue>)Parameters["V"]; }
    4646    }
     47    private bool HasFixedLengthParameter {
     48      get { return LengthParameter.Value != null; }
     49    }
     50    private bool HasFixedScaleParameter {
     51      get { return ScaleParameter.Value != null; }
     52    }
    4753
    4854    [StorableConstructor]
     
    7783    public int GetNumberOfParameters(int numberOfVariables) {
    7884      return
    79         (LengthParameter.Value != null ? 0 : 1) +
    80         (ScaleParameter.Value != null ? 0 : 1);
     85        (HasFixedLengthParameter ? 0 : 1) +
     86        (HasFixedScaleParameter ? 0 : 1);
    8187    }
    8288
     
    9197      // gather parameter values
    9298      int n = 0;
    93       if (LengthParameter.Value != null) {
     99      if (HasFixedLengthParameter) {
    94100        length = LengthParameter.Value.Value;
    95101      } else {
     
    98104      }
    99105
    100       if (ScaleParameter.Value != null) {
     106      if (HasFixedScaleParameter) {
    101107        scale = ScaleParameter.Value.Value;
    102108      } else {
     
    111117      int v = VParameter.Value.Value;
    112118      GetParameterValues(p, out length, out scale);
     119      var fixedLength = HasFixedLengthParameter;
     120      var fixedScale = HasFixedScaleParameter;
    113121      int exp = (int)Math.Floor(columnIndices.Count() / 2.0) + v + 1;
    114122
     
    147155        return scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k);
    148156      };
    149       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, length, scale, v, exp, f, df, columnIndices);
     157      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, length, scale, v, exp, f, df, columnIndices, fixedLength, fixedScale);
    150158      return cov;
    151159    }
    152160
    153     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) {
     161    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,
     162      bool fixedLength, bool fixedScale) {
    154163      double k = Math.Sqrt(Util.SqrDist(x, i, x, j, 1.0 / length, columnIndices));
    155       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));
    156       yield return 2.0 * scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k);
     164      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));
     165      if (!fixedScale) yield return 2.0 * scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k);
    157166    }
    158167  }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePolynomial.cs

    r9535 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4545      get { return (IValueParameter<IntValue>)Parameters["Degree"]; }
    4646    }
     47    private bool HasFixedConstParameter {
     48      get { return ConstParameter.Value != null; }
     49    }
     50    private bool HasFixedScaleParameter {
     51      get { return ScaleParameter.Value != null; }
     52    }
    4753
    4854    [StorableConstructor]
     
    7177    public int GetNumberOfParameters(int numberOfVariables) {
    7278      return
    73         (ConstParameter.Value != null ? 0 : 1) +
    74         (ScaleParameter.Value != null ? 0 : 1);
     79        (HasFixedConstParameter ? 0 : 1) +
     80        (HasFixedScaleParameter ? 0 : 1);
    7581    }
    7682
     
    8591      // gather parameter values
    8692      int n = 0;
    87       if (ConstParameter.Value != null) {
     93      if (HasFixedConstParameter) {
    8894        @const = ConstParameter.Value.Value;
    8995      } else {
     
    9298      }
    9399
    94       if (ScaleParameter.Value != null) {
     100      if (HasFixedScaleParameter) {
    95101        scale = ScaleParameter.Value.Value;
    96102      } else {
     
    106112      if (degree <= 0) throw new ArgumentException("The degree parameter for CovariancePolynomial must be greater than zero.");
    107113      GetParameterValues(p, out @const, out scale);
     114      var fixedConst = HasFixedConstParameter;
     115      var fixedScale = HasFixedScaleParameter;
    108116      // create functions
    109117      var cov = new ParameterizedCovarianceFunction();
    110118      cov.Covariance = (x, i, j) => scale * Math.Pow(@const + Util.ScalarProd(x, i, j, 1.0, columnIndices), degree);
    111119      cov.CrossCovariance = (x, xt, i, j) => scale * Math.Pow(@const + Util.ScalarProd(x, i, xt, j, 1.0, columnIndices), degree);
    112       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, @const, scale, degree, columnIndices);
     120      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, @const, scale, degree, columnIndices, fixedConst, fixedScale);
    113121      return cov;
    114122    }
    115123
    116     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double c, double scale, int degree, IEnumerable<int> columnIndices) {
     124    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double c, double scale, int degree, IEnumerable<int> columnIndices,
     125      bool fixedConst, bool fixedScale) {
    117126      double s = Util.ScalarProd(x, i, j, 1.0, columnIndices);
    118       yield return c * degree * scale * Math.Pow(c + s, degree - 1);
    119       yield return 2 * scale * Math.Pow(c + s, degree);
     127      if (!fixedConst) yield return c * degree * scale * Math.Pow(c + s, degree - 1);
     128      if (!fixedScale) yield return 2 * scale * Math.Pow(c + s, degree);
    120129    }
    121130  }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceProduct.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticArd.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4545      get { return (IValueParameter<DoubleValue>)Parameters["Shape"]; }
    4646    }
     47    private bool HasFixedScaleParameter {
     48      get { return ScaleParameter.Value != null; }
     49    }
     50    private bool HasFixedInverseLengthParameter {
     51      get { return InverseLengthParameter.Value != null; }
     52    }
     53    private bool HasFixedShapeParameter {
     54      get { return ShapeParameter.Value != null; }
     55    }
    4756
    4857    [StorableConstructor]
     
    7180    public int GetNumberOfParameters(int numberOfVariables) {
    7281      return
    73         (ScaleParameter.Value != null ? 0 : 1) +
    74         (ShapeParameter.Value != null ? 0 : 1) +
    75         (InverseLengthParameter.Value != null ? 0 : numberOfVariables);
     82        (HasFixedScaleParameter ? 0 : 1) +
     83        (HasFixedShapeParameter ? 0 : 1) +
     84        (HasFixedInverseLengthParameter ? 0 : numberOfVariables);
    7685    }
    7786
     
    8897      int c = 0;
    8998      // gather parameter values
    90       if (InverseLengthParameter.Value != null) {
     99      if (HasFixedInverseLengthParameter) {
    91100        inverseLength = InverseLengthParameter.Value.ToArray();
    92101      } else {
    93102        int length = p.Length;
    94         if (ScaleParameter.Value == null) length--;
    95         if (ShapeParameter.Value == null) length--;
     103        if (!HasFixedScaleParameter) length--;
     104        if (!HasFixedShapeParameter) length--;
    96105        inverseLength = p.Select(e => 1.0 / Math.Exp(e)).Take(length).ToArray();
    97106        c += inverseLength.Length;
    98107      }
    99       if (ScaleParameter.Value != null) {
     108      if (HasFixedScaleParameter) {
    100109        scale = ScaleParameter.Value.Value;
    101110      } else {
     
    103112        c++;
    104113      }
    105       if (ShapeParameter.Value != null) {
     114      if (HasFixedShapeParameter) {
    106115        shape = ShapeParameter.Value.Value;
    107116      } else {
     
    116125      double[] inverseLength;
    117126      GetParameterValues(p, out scale, out shape, out inverseLength);
     127      var fixedInverseLength = HasFixedInverseLengthParameter;
     128      var fixedScale = HasFixedScaleParameter;
     129      var fixedShape = HasFixedShapeParameter;
    118130      // create functions
    119131      var cov = new ParameterizedCovarianceFunction();
     
    128140        return scale * Math.Pow(1 + 0.5 * d / shape, -shape);
    129141      };
    130       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength);
     142      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength, fixedInverseLength, fixedScale, fixedShape);
    131143      return cov;
    132144    }
    133145
    134     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double[] inverseLength) {
     146    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double[] inverseLength,
     147      bool fixedInverseLength, bool fixedScale, bool fixedShape) {
    135148      double d = i == j
    136149                   ? 0.0
     
    138151      double b = 1 + 0.5 * d / shape;
    139152      int k = 0;
    140       foreach (var columnIndex in columnIndices) {
    141         yield return scale * Math.Pow(b, -shape - 1) * Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
    142         k++;
     153      if (!fixedInverseLength) {
     154        foreach (var columnIndex in columnIndices) {
     155          yield return
     156            scale * Math.Pow(b, -shape - 1) *
     157            Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
     158          k++;
     159        }
    143160      }
    144       yield return 2 * scale * Math.Pow(b, -shape);
    145       yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));
     161      if (!fixedScale) yield return 2 * scale * Math.Pow(b, -shape);
     162      if (!fixedShape) yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));
    146163    }
    147164  }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticIso.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4444      get { return (IValueParameter<DoubleValue>)Parameters["Shape"]; }
    4545    }
     46
     47    private bool HasFixedScaleParameter {
     48      get { return ScaleParameter.Value != null; }
     49    }
     50    private bool HasFixedInverseLengthParameter {
     51      get { return InverseLengthParameter.Value != null; }
     52    }
     53    private bool HasFixedShapeParameter {
     54      get { return ShapeParameter.Value != null; }
     55    }
     56
     57
    4658    [StorableConstructor]
    4759    private CovarianceRationalQuadraticIso(bool deserializing)
     
    6880
    6981    public int GetNumberOfParameters(int numberOfVariables) {
    70       return (ScaleParameter.Value != null ? 0 : 1) +
    71         (ShapeParameter.Value != null ? 0 : 1) +
    72         (InverseLengthParameter.Value != null ? 0 : 1);
     82      return (HasFixedScaleParameter ? 0 : 1) +
     83        (HasFixedShapeParameter ? 0 : 1) +
     84        (HasFixedInverseLengthParameter ? 0 : 1);
    7385    }
    7486
     
    8496      int c = 0;
    8597      // gather parameter values
    86       if (InverseLengthParameter.Value != null) {
     98      if (HasFixedInverseLengthParameter) {
    8799        inverseLength = InverseLengthParameter.Value.Value;
    88100      } else {
     
    90102        c++;
    91103      }
    92       if (ScaleParameter.Value != null) {
     104      if (HasFixedScaleParameter) {
    93105        scale = ScaleParameter.Value.Value;
    94106      } else {
     
    96108        c++;
    97109      }
    98       if (ShapeParameter.Value != null) {
     110      if (HasFixedShapeParameter) {
    99111        shape = ShapeParameter.Value.Value;
    100112      } else {
     
    108120      double scale, shape, inverseLength;
    109121      GetParameterValues(p, out scale, out shape, out inverseLength);
     122      var fixedInverseLength = HasFixedInverseLengthParameter;
     123      var fixedScale = HasFixedScaleParameter;
     124      var fixedShape = HasFixedShapeParameter;
    110125      // create functions
    111126      var cov = new ParameterizedCovarianceFunction();
     
    120135        return scale * Math.Pow(1 + 0.5 * d / shape, -shape);
    121136      };
    122       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength);
     137      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength, fixedInverseLength, fixedScale, fixedShape);
    123138      return cov;
    124139    }
    125140
    126     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double inverseLength) {
     141    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double inverseLength,
     142      bool fixedInverseLength, bool fixedScale, bool fixedShape) {
    127143      double d = i == j
    128144                   ? 0.0
     
    130146
    131147      double b = 1 + 0.5 * d / shape;
    132       yield return scale * Math.Pow(b, -shape - 1) * d;
    133       yield return 2 * scale * Math.Pow(b, -shape);
    134       yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));
     148      if (!fixedInverseLength) yield return scale * Math.Pow(b, -shape - 1) * d;
     149      if (!fixedScale) yield return 2 * scale * Math.Pow(b, -shape);
     150      if (!fixedShape) yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));
    135151    }
    136152  }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceScale.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3737      get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; }
    3838    }
     39    private bool HasFixedScaleParameter {
     40      get { return ScaleParameter.Value != null; }
     41    }
    3942
    4043    public IValueParameter<ICovarianceFunction> CovarianceFunctionParameter {
     
    6568
    6669    public int GetNumberOfParameters(int numberOfVariables) {
    67       return (ScaleParameter.Value != null ? 0 : 1) + CovarianceFunctionParameter.Value.GetNumberOfParameters(numberOfVariables);
     70      return (HasFixedScaleParameter ? 0 : 1) + CovarianceFunctionParameter.Value.GetNumberOfParameters(numberOfVariables);
    6871    }
    6972
     
    7780    private void GetParameterValues(double[] p, out double scale) {
    7881      // gather parameter values
    79       if (ScaleParameter.Value != null) {
     82      if (HasFixedScaleParameter) {
    8083        scale = ScaleParameter.Value.Value;
    8184      } else {
     
    8790      double scale;
    8891      GetParameterValues(p, out scale);
     92      var fixedScale = HasFixedScaleParameter;
    8993      var subCov = CovarianceFunctionParameter.Value.GetParameterizedCovarianceFunction(p.Skip(1).ToArray(), columnIndices);
    9094      // create functions
     
    9296      cov.Covariance = (x, i, j) => scale * subCov.Covariance(x, i, j);
    9397      cov.CrossCovariance = (x, xt, i, j) => scale * subCov.CrossCovariance(x, xt, i, j);
    94       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, subCov);
     98      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, subCov, fixedScale);
    9599      return cov;
    96100    }
    97101
    98     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, ParameterizedCovarianceFunction cov) {
    99       yield return 2 * scale * cov.Covariance(x, i, j);
     102    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, ParameterizedCovarianceFunction cov,
     103      bool fixedScale) {
     104      if (!fixedScale) {
     105        yield return 2 * scale * cov.Covariance(x, i, j);
     106      }
    100107      foreach (var g in cov.CovarianceGradient(x, i, j))
    101108        yield return scale * g;
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSpectralMixture.cs

    r11170 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialArd.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4040      get { return (IValueParameter<DoubleArray>)Parameters["InverseLength"]; }
    4141    }
     42    private bool HasFixedInverseLengthParameter {
     43      get { return InverseLengthParameter.Value != null; }
     44    }
     45    private bool HasFixedScaleParameter {
     46      get { return ScaleParameter.Value != null; }
     47    }
    4248
    4349    [StorableConstructor]
     
    6167    public int GetNumberOfParameters(int numberOfVariables) {
    6268      return
    63         (ScaleParameter.Value != null ? 0 : 1) +
    64         (InverseLengthParameter.Value != null ? 0 : numberOfVariables);
     69        (HasFixedScaleParameter ? 0 : 1) +
     70        (HasFixedInverseLengthParameter ? 0 : numberOfVariables);
    6571    }
    6672
     
    7682      int c = 0;
    7783      // gather parameter values
    78       if (InverseLengthParameter.Value != null) {
     84      if (HasFixedInverseLengthParameter) {
    7985        inverseLength = InverseLengthParameter.Value.ToArray();
    8086      } else {
    8187        int length = p.Length;
    82         if (ScaleParameter.Value == null) length--;
     88        if (!HasFixedScaleParameter) length--;
    8389        inverseLength = p.Select(e => 1.0 / Math.Exp(e)).Take(length).ToArray();
    8490        c += inverseLength.Length;
    8591      }
    86       if (ScaleParameter.Value != null) {
     92      if (HasFixedScaleParameter) {
    8793        scale = ScaleParameter.Value.Value;
    8894      } else {
     
    97103      double[] inverseLength;
    98104      GetParameterValues(p, out scale, out inverseLength);
     105      var fixedInverseLength = HasFixedInverseLengthParameter;
     106      var fixedScale = HasFixedScaleParameter;
    99107      // create functions
    100108      var cov = new ParameterizedCovarianceFunction();
     
    109117        return scale * Math.Exp(-d / 2.0);
    110118      };
    111       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, inverseLength);
     119      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, inverseLength, fixedInverseLength, fixedScale);
    112120      return cov;
    113121    }
    114122
    115123    // order of returned gradients must match the order in GetParameterValues!
    116     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double[] inverseLength) {
     124    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double[] inverseLength,
     125      bool fixedInverseLength, bool fixedScale) {
    117126      double d = i == j
    118127                   ? 0.0
     
    120129
    121130      int k = 0;
    122       foreach (var columnIndex in columnIndices) {
    123         double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
    124         yield return scale * Math.Exp(-d / 2.0) * sqrDist;
    125         k++;
     131      if (!fixedInverseLength) {
     132        foreach (var columnIndex in columnIndices) {
     133          double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]);
     134          yield return scale * Math.Exp(-d / 2.0) * sqrDist;
     135          k++;
     136        }
    126137      }
    127       yield return 2.0 * scale * Math.Exp(-d / 2.0);
     138      if (!fixedScale) yield return 2.0 * scale * Math.Exp(-d / 2.0);
    128139    }
    129140  }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialIso.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4242    }
    4343
     44    private bool HasFixedInverseLengthParameter {
     45      get { return InverseLengthParameter.Value != null; }
     46    }
     47    private bool HasFixedScaleParameter {
     48      get { return ScaleParameter.Value != null; }
     49    }
     50
    4451    [StorableConstructor]
    4552    private CovarianceSquaredExponentialIso(bool deserializing)
     
    6673    public int GetNumberOfParameters(int numberOfVariables) {
    6774      return
    68         (ScaleParameter.Value != null ? 0 : 1) +
    69         (InverseLengthParameter.Value != null ? 0 : 1);
     75        (HasFixedScaleParameter ? 0 : 1) +
     76        (HasFixedInverseLengthParameter ? 0 : 1);
    7077    }
    7178
     
    8188      // gather parameter values
    8289      int c = 0;
    83       if (InverseLengthParameter.Value != null) {
     90      if (HasFixedInverseLengthParameter) {
    8491        inverseLength = InverseLengthParameter.Value.Value;
    8592      } else {
     
    8895      }
    8996
    90       if (ScaleParameter.Value != null) {
     97      if (HasFixedScaleParameter) {
    9198        scale = ScaleParameter.Value.Value;
    9299      } else {
     
    100107      double inverseLength, scale;
    101108      GetParameterValues(p, out scale, out inverseLength);
     109      var fixedInverseLength = HasFixedInverseLengthParameter;
     110      var fixedScale = HasFixedScaleParameter;
    102111      // create functions
    103112      var cov = new ParameterizedCovarianceFunction();
     
    112121        return scale * Math.Exp(-d / 2.0);
    113122      };
    114       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, inverseLength, columnIndices);
     123      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, inverseLength, columnIndices,
     124        fixedInverseLength, fixedScale);
    115125      return cov;
    116126    }
    117127
    118128    // order of returned gradients must match the order in GetParameterValues!
    119     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double sf2, double inverseLength, IEnumerable<int> columnIndices) {
     129    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double sf2, double inverseLength, IEnumerable<int> columnIndices,
     130      bool fixedInverseLength, bool fixedScale) {
    120131      double d = i == j
    121132                   ? 0.0
    122133                   : Util.SqrDist(x, i, j, inverseLength, columnIndices);
    123134      double g = Math.Exp(-d / 2.0);
    124       yield return sf2 * g * d;
    125       yield return 2.0 * sf2 * g;
     135      if (!fixedInverseLength) yield return sf2 * g * d;
     136      if (!fixedScale) yield return 2.0 * sf2 * g;
    126137    }
    127138  }
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSum.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessBase.cs

    r9456 r11594  
    22#region License Information
    33/* HeuristicLab
    4  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    55 *
    66 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassification.cs

    r9456 r11594  
    22#region License Information
    33/* HeuristicLab
    4  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    55 *
    66 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassificationModelCreator.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassificationSolutionCreator.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessHyperparameterInitializer.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModelCreator.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegression.cs

    r9456 r11594  
    22#region License Information
    33/* HeuristicLab
    4  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    55 *
    66 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionModelCreator.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolution.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolutionCreator.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/ICovarianceFunction.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/IMeanFunction.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanConst.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanLinear.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanProduct.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanSum.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanZero.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/Util.cs

    r9456 r11594  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
Note: See TracChangeset for help on using the changeset viewer.