Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/05/14 17:30:38 (10 years ago)
Author:
mkommend
Message:

#1998: Updated classification model comparision branch with trunk changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs

    r8982 r10553  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 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    }
    9097
    9198    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double[] inverseLength, IEnumerable<int> columnIndices) {
    92       if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1));
    93 
    9499      int k = 0;
    95100      foreach (int columnIndex in columnIndices) {
Note: See TracChangeset for help on using the changeset viewer.