Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/20/14 17:45:06 (10 years ago)
Author:
gkronber
Message:

#2125 fixed the bug that covariance functions returned the full gradient vector even when parameters are partially fixed.
changed the calculation of NN covariance and gradient to direct calculation (instead of AutoDiff)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceConst.cs

    r9456 r10489  
    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    }
Note: See TracChangeset for help on using the changeset viewer.