Changeset 11594 for branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePiecewisePolynomial.cs
- Timestamp:
- 11/27/14 11:23:37 (10 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/CovariancePiecewisePolynomial.cs
r9543 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 (IConstrainedValueParameter<IntValue>)Parameters["V"]; } 46 46 } 47 private bool HasFixedLengthParameter { 48 get { return LengthParameter.Value != null; } 49 } 50 private bool HasFixedScaleParameter { 51 get { return ScaleParameter.Value != null; } 52 } 47 53 48 54 [StorableConstructor] … … 77 83 public int GetNumberOfParameters(int numberOfVariables) { 78 84 return 79 ( LengthParameter.Value != null? 0 : 1) +80 ( ScaleParameter.Value != null? 0 : 1);85 (HasFixedLengthParameter ? 0 : 1) + 86 (HasFixedScaleParameter ? 0 : 1); 81 87 } 82 88 … … 91 97 // gather parameter values 92 98 int n = 0; 93 if ( LengthParameter.Value != null) {99 if (HasFixedLengthParameter) { 94 100 length = LengthParameter.Value.Value; 95 101 } else { … … 98 104 } 99 105 100 if ( ScaleParameter.Value != null) {106 if (HasFixedScaleParameter) { 101 107 scale = ScaleParameter.Value.Value; 102 108 } else { … … 111 117 int v = VParameter.Value.Value; 112 118 GetParameterValues(p, out length, out scale); 119 var fixedLength = HasFixedLengthParameter; 120 var fixedScale = HasFixedScaleParameter; 113 121 int exp = (int)Math.Floor(columnIndices.Count() / 2.0) + v + 1; 114 122 … … 147 155 return scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k); 148 156 }; 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); 150 158 return cov; 151 159 } 152 160 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) { 154 163 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); 157 166 } 158 167 }
Note: See TracChangeset
for help on using the changeset viewer.