Changeset 11594 for branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePolynomial.cs
- Timestamp:
- 11/27/14 11:23:37 (9 years ago)
- Location:
- branches/Breadcrumbs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Breadcrumbs
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
-
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePolynomial.cs
r9535 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 45 45 get { return (IValueParameter<IntValue>)Parameters["Degree"]; } 46 46 } 47 private bool HasFixedConstParameter { 48 get { return ConstParameter.Value != null; } 49 } 50 private bool HasFixedScaleParameter { 51 get { return ScaleParameter.Value != null; } 52 } 47 53 48 54 [StorableConstructor] … … 71 77 public int GetNumberOfParameters(int numberOfVariables) { 72 78 return 73 ( ConstParameter.Value != null? 0 : 1) +74 ( ScaleParameter.Value != null? 0 : 1);79 (HasFixedConstParameter ? 0 : 1) + 80 (HasFixedScaleParameter ? 0 : 1); 75 81 } 76 82 … … 85 91 // gather parameter values 86 92 int n = 0; 87 if ( ConstParameter.Value != null) {93 if (HasFixedConstParameter) { 88 94 @const = ConstParameter.Value.Value; 89 95 } else { … … 92 98 } 93 99 94 if ( ScaleParameter.Value != null) {100 if (HasFixedScaleParameter) { 95 101 scale = ScaleParameter.Value.Value; 96 102 } else { … … 106 112 if (degree <= 0) throw new ArgumentException("The degree parameter for CovariancePolynomial must be greater than zero."); 107 113 GetParameterValues(p, out @const, out scale); 114 var fixedConst = HasFixedConstParameter; 115 var fixedScale = HasFixedScaleParameter; 108 116 // create functions 109 117 var cov = new ParameterizedCovarianceFunction(); 110 118 cov.Covariance = (x, i, j) => scale * Math.Pow(@const + Util.ScalarProd(x, i, j, 1.0, columnIndices), degree); 111 119 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); 113 121 return cov; 114 122 } 115 123 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) { 117 126 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); 120 129 } 121 130 }
Note: See TracChangeset
for help on using the changeset viewer.