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