- Timestamp:
- 11/27/14 11:23:37 (10 years ago)
- Location:
- branches/Breadcrumbs
- Files:
-
- 38 edited
- 1 copied
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/CovarianceConst.cs
r9456 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. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; … … 36 37 get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; } 37 38 } 38 39 private bool HasFixedScaleParameter { 40 get { return ScaleParameter.Value != null; } 41 } 39 42 [StorableConstructor] 40 43 private CovarianceConst(bool deserializing) … … 59 62 60 63 public int GetNumberOfParameters(int numberOfVariables) { 61 return ScaleParameter.Value != null? 0 : 1;64 return HasFixedScaleParameter ? 0 : 1; 62 65 } 63 66 … … 71 74 int c = 0; 72 75 // gather parameter values 73 if ( ScaleParameter.Value != null) {76 if (HasFixedScaleParameter) { 74 77 scale = ScaleParameter.Value.Value; 75 78 } else { … … 87 90 cov.Covariance = (x, i, j) => scale; 88 91 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 } 90 97 return cov; 91 98 } -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinear.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceLinearArd.cs
r9456 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. … … 37 37 get { return (IValueParameter<DoubleArray>)Parameters["InverseLength"]; } 38 38 } 39 private bool HasFixedInverseLengthParameter { 40 get { return InverseLengthParameter.Value != null; } 41 } 39 42 40 43 [StorableConstructor] … … 57 60 58 61 public int GetNumberOfParameters(int numberOfVariables) { 59 if (InverseLengthParameter.Value == null) 62 if (HasFixedInverseLengthParameter) 63 return 0; 64 else 60 65 return numberOfVariables; 61 else62 return 0;63 66 } 64 67 … … 71 74 private void GetParameterValues(double[] p, out double[] inverseLength) { 72 75 // gather parameter values 73 if ( InverseLengthParameter.Value != null) {76 if (HasFixedInverseLengthParameter) { 74 77 inverseLength = InverseLengthParameter.Value.ToArray(); 75 78 } else { … … 81 84 double[] inverseLength; 82 85 GetParameterValues(p, out inverseLength); 86 var fixedInverseLength = HasFixedInverseLengthParameter; 83 87 // create functions 84 88 var cov = new ParameterizedCovarianceFunction(); 85 89 cov.Covariance = (x, i, j) => Util.ScalarProd(x, i, j, inverseLength, columnIndices); 86 90 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); 88 95 return cov; 89 96 } -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMask.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceMaternIso.cs
r9456 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["D"]; } 46 46 } 47 47 private bool HasFixedScaleParameter { 48 get { return ScaleParameter.Value != null; } 49 } 50 private bool HasFixedInverseLengthParameter { 51 get { return InverseLengthParameter.Value != null; } 52 } 48 53 49 54 [StorableConstructor] … … 76 81 public int GetNumberOfParameters(int numberOfVariables) { 77 82 return 78 ( InverseLengthParameter.Value != null? 0 : 1) +79 ( ScaleParameter.Value != null? 0 : 1);83 (HasFixedInverseLengthParameter ? 0 : 1) + 84 (HasFixedScaleParameter ? 0 : 1); 80 85 } 81 86 … … 90 95 // gather parameter values 91 96 int c = 0; 92 if ( InverseLengthParameter.Value != null) {97 if (HasFixedInverseLengthParameter) { 93 98 inverseLength = InverseLengthParameter.Value.Value; 94 99 } else { … … 97 102 } 98 103 99 if ( ScaleParameter.Value != null) {104 if (HasFixedScaleParameter) { 100 105 scale = ScaleParameter.Value.Value; 101 106 } else { … … 110 115 int d = DParameter.Value.Value; 111 116 GetParameterValues(p, out scale, out inverseLength); 117 var fixedInverseLength = HasFixedInverseLengthParameter; 118 var fixedScale = HasFixedScaleParameter; 112 119 // create functions 113 120 var cov = new ParameterizedCovarianceFunction(); … … 122 129 return scale * m(d, dist); 123 130 }; 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); 125 132 return cov; 126 133 } … … 149 156 150 157 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) { 152 160 double dist = i == j 153 161 ? 0.0 154 162 : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength, columnIndices)); 155 163 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); 158 166 } 159 167 } -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNeuralNetwork.cs
r9542 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. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq;25 using System.Linq.Expressions;26 using AutoDiff;27 24 using HeuristicLab.Common; 28 25 using HeuristicLab.Core; … … 42 39 public IValueParameter<DoubleValue> LengthParameter { 43 40 get { return (IValueParameter<DoubleValue>)Parameters["Length"]; } 41 } 42 private bool HasFixedScaleParameter { 43 get { return ScaleParameter.Value != null; } 44 } 45 private bool HasFixedLengthParameter { 46 get { return LengthParameter.Value != null; } 44 47 } 45 48 … … 68 71 public int GetNumberOfParameters(int numberOfVariables) { 69 72 return 70 ( ScaleParameter.Value != null? 0 : 1) +71 ( LengthParameter.Value != null? 0 : 1);73 (HasFixedScaleParameter ? 0 : 1) + 74 (HasFixedLengthParameter ? 0 : 1); 72 75 } 73 76 … … 83 86 // gather parameter values 84 87 int c = 0; 85 if ( LengthParameter.Value != null) {88 if (HasFixedLengthParameter) { 86 89 length = LengthParameter.Value.Value; 87 90 } else { … … 90 93 } 91 94 92 if ( ScaleParameter.Value != null) {95 if (HasFixedScaleParameter) { 93 96 scale = ScaleParameter.Value.Value; 94 97 } else { … … 99 102 } 100 103 101 102 private static Func<Term, UnaryFunc> asin = UnaryFunc.Factory(103 x => Math.Asin(x), // evaluate104 x => 1 / Math.Sqrt(1 - x * x)); // derivative of atan105 private static Func<Term, UnaryFunc> sqrt = UnaryFunc.Factory(106 x => Math.Sqrt(x),107 x => 1 / (2 * Math.Sqrt(x)));108 109 104 public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, IEnumerable<int> columnIndices) { 110 105 double length, scale; 111 106 GetParameterValues(p, out scale, out length); 112 // create functions 113 AutoDiff.Variable p0 = new AutoDiff.Variable(); 114 AutoDiff.Variable p1 = new AutoDiff.Variable(); 115 var l = TermBuilder.Exp(2.0 * p0); 116 var s = TermBuilder.Exp(2.0 * p1); 117 AutoDiff.Variable[] x1 = new AutoDiff.Variable[columnIndices.Count()]; 118 AutoDiff.Variable[] x2 = new AutoDiff.Variable[columnIndices.Count()]; 119 AutoDiff.Term sx = 1; 120 AutoDiff.Term s1 = 1; 121 AutoDiff.Term s2 = 1; 122 for (int k = 0; k < columnIndices.Count(); k++) { 123 x1[k] = new AutoDiff.Variable(); 124 x2[k] = new AutoDiff.Variable(); 125 sx += x1[k] * x2[k]; 126 s1 += x1[k] * x1[k]; 127 s2 += x2[k] * x2[k]; 128 } 129 130 var parameter = x1.Concat(x2).Concat(new AutoDiff.Variable[] { p0, p1 }).ToArray(); 131 var values = new double[x1.Length + x2.Length + 2]; 132 var c = (s * asin(sx / (sqrt((l + s1) * (l + s2))))).Compile(parameter); 107 var fixedLength = HasFixedLengthParameter; 108 var fixedScale = HasFixedScaleParameter; 133 109 134 110 var cov = new ParameterizedCovarianceFunction(); 135 111 cov.Covariance = (x, i, j) => { 136 int k = 0; 112 double sx = 1.0; 113 double s1 = 1.0; 114 double s2 = 1.0; 137 115 foreach (var col in columnIndices) { 138 values[k] = x[i, col]; 139 k++; 116 sx += x[i, col] * x[j, col]; 117 s1 += x[i, col] * x[i, col]; 118 s2 += x[j, col] * x[j, col]; 140 119 } 141 foreach (var col in columnIndices) { 142 values[k] = x[j, col]; 143 k++; 144 } 145 values[k] = Math.Log(Math.Sqrt(length)); 146 values[k + 1] = Math.Log(Math.Sqrt(scale)); 147 return c.Evaluate(values); 120 121 return (scale * Math.Asin(sx / (Math.Sqrt((length + s1) * (length + s2))))); 148 122 }; 149 123 cov.CrossCovariance = (x, xt, i, j) => { 150 int k = 0; 124 double sx = 1.0; 125 double s1 = 1.0; 126 double s2 = 1.0; 151 127 foreach (var col in columnIndices) { 152 values[k] = x[i, col]; 153 k++; 128 sx += x[i, col] * xt[j, col]; 129 s1 += x[i, col] * x[i, col]; 130 s2 += xt[j, col] * xt[j, col]; 154 131 } 155 foreach (var col in columnIndices) { 156 values[k] = xt[j, col]; 157 k++; 158 } 159 values[k] = Math.Log(Math.Sqrt(length)); 160 values[k + 1] = Math.Log(Math.Sqrt(scale)); 161 return c.Evaluate(values); 132 133 return (scale * Math.Asin(sx / (Math.Sqrt((length + s1) * (length + s2))))); 162 134 }; 163 cov.CovarianceGradient = (x, i, j) => { 164 int k = 0; 165 foreach (var col in columnIndices) { 166 values[k] = x[i, col]; 167 k++; 168 } 169 foreach (var col in columnIndices) { 170 values[k] = x[j, col]; 171 k++; 172 } 173 values[k] = Math.Log(Math.Sqrt(length)); 174 values[k + 1] = Math.Log(Math.Sqrt(scale)); 175 return c.Differentiate(values).Item1.Skip(columnIndices.Count() * 2); 176 }; 135 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, length, scale, columnIndices, fixedLength, fixedScale); 177 136 return cov; 178 137 } 179 138 139 // order of returned gradients must match the order in GetParameterValues! 140 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double length, double scale, IEnumerable<int> columnIndices, 141 bool fixedLength, bool fixedScale) { 142 { 143 double sx = 1.0; 144 double s1 = 1.0; 145 double s2 = 1.0; 146 foreach (var col in columnIndices) { 147 sx += x[i, col] * x[j, col]; 148 s1 += x[i, col] * x[i, col]; 149 s2 += x[j, col] * x[j, col]; 150 } 151 var h = (length + s1) * (length + s2); 152 var f = sx / Math.Sqrt(h); 153 if (!fixedLength) { 154 yield return -scale / Math.Sqrt(1.0 - f * f) * ((length * sx * (2.0 * length + s1 + s2)) / Math.Pow(h, 3.0 / 2.0)); 155 } 156 if (!fixedScale) { 157 yield return 2.0 * scale * Math.Asin(f); 158 } 159 } 160 } 180 161 } 181 162 } -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNoise.cs
r9544 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. … … 37 37 get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; } 38 38 } 39 private bool HasFixedScaleParameter { 40 get { return ScaleParameter.Value != null; } 41 } 39 42 40 43 [StorableConstructor] … … 60 63 61 64 public int GetNumberOfParameters(int numberOfVariables) { 62 return ScaleParameter.Value != null? 0 : 1;65 return HasFixedScaleParameter ? 0 : 1; 63 66 } 64 67 … … 72 75 int c = 0; 73 76 // gather parameter values 74 if ( ScaleParameter.Value != null) {77 if (HasFixedScaleParameter) { 75 78 scale = ScaleParameter.Value.Value; 76 79 } else { … … 84 87 double scale; 85 88 GetParameterValues(p, out scale); 89 var fixedScale = HasFixedScaleParameter; 86 90 // create functions 87 91 var cov = new ParameterizedCovarianceFunction(); 88 92 cov.Covariance = (x, i, j) => i == j ? scale : 0.0; 89 93 cov.CrossCovariance = (x, xt, i, j) => Util.SqrDist(x, i, xt, j, 1.0, columnIndices) < 1e-9 ? scale : 0.0; 90 cov.CovarianceGradient = (x, i, j) => Enumerable.Repeat(i == j ? 2.0 * scale : 0.0, 1); 94 if (fixedScale) 95 cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>(); 96 else 97 cov.CovarianceGradient = (x, i, j) => Enumerable.Repeat(i == j ? 2.0 * scale : 0.0, 1); 91 98 return cov; 92 99 } -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePeriodic.cs
r9456 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. … … 46 46 } 47 47 48 private bool HasFixedScaleParameter { 49 get { return ScaleParameter.Value != null; } 50 } 51 private bool HasFixedInverseLengthParameter { 52 get { return InverseLengthParameter.Value != null; } 53 } 54 private bool HasFixedPeriodParameter { 55 get { return PeriodParameter.Value != null; } 56 } 57 48 58 49 59 [StorableConstructor] … … 68 78 69 79 public int GetNumberOfParameters(int numberOfVariables) { 70 return ( ScaleParameter.Value != null? 0 : 1) +71 ( PeriodParameter.Value != null? 0 : 1) +72 ( InverseLengthParameter.Value != null? 0 : 1);80 return (HasFixedScaleParameter ? 0 : 1) + 81 (HasFixedPeriodParameter ? 0 : 1) + 82 (HasFixedInverseLengthParameter ? 0 : 1); 73 83 } 74 84 … … 82 92 83 93 84 private void GetParameterValues(double[] 94 private void GetParameterValues(double[] 85 95 p, out double scale, out double period, out double inverseLength) { 86 96 // gather parameter values 87 97 int c = 0; 88 if ( InverseLengthParameter.Value != null) {98 if (HasFixedInverseLengthParameter) { 89 99 inverseLength = InverseLengthParameter.Value.Value; 90 100 } else { … … 92 102 c++; 93 103 } 94 if ( PeriodParameter.Value != null) {104 if (HasFixedPeriodParameter) { 95 105 period = PeriodParameter.Value.Value; 96 106 } else { … … 98 108 c++; 99 109 } 100 if ( ScaleParameter.Value != null) {110 if (HasFixedScaleParameter) { 101 111 scale = ScaleParameter.Value.Value; 102 112 } else { … … 110 120 double inverseLength, period, scale; 111 121 GetParameterValues(p, out scale, out period, out inverseLength); 122 var fixedInverseLength = HasFixedInverseLengthParameter; 123 var fixedPeriod = HasFixedPeriodParameter; 124 var fixedScale = HasFixedScaleParameter; 112 125 // create functions 113 126 var cov = new ParameterizedCovarianceFunction(); … … 128 141 return scale * Math.Exp(-2.0 * k); 129 142 }; 130 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, period, inverseLength );143 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, period, inverseLength, fixedInverseLength, fixedPeriod, fixedScale); 131 144 return cov; 132 145 } 133 146 134 147 135 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double period, double inverseLength) { 148 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double period, double inverseLength, 149 bool fixedInverseLength, bool fixedPeriod, bool fixedScale) { 136 150 double k = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period; 137 151 double gradient = Math.Sin(k) * inverseLength; 138 152 gradient *= gradient; 139 yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient; 140 double r = Math.Sin(k) * inverseLength; 141 yield return 2.0 * k * scale * Math.Exp(-2 * r * r) *Math.Sin(2*k) * inverseLength * inverseLength; 142 yield return 2.0 * scale * Math.Exp(-2 * gradient); 153 if (!fixedInverseLength) yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient; 154 if (!fixedPeriod) { 155 double r = Math.Sin(k) * inverseLength; 156 yield return 2.0 * k * scale * Math.Exp(-2 * r * r) * Math.Sin(2 * k) * inverseLength * inverseLength; 157 } 158 if (!fixedScale) 159 yield return 2.0 * scale * Math.Exp(-2 * gradient); 143 160 144 161 } -
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 } -
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 } -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceProduct.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticArd.cs
r9456 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<DoubleValue>)Parameters["Shape"]; } 46 46 } 47 private bool HasFixedScaleParameter { 48 get { return ScaleParameter.Value != null; } 49 } 50 private bool HasFixedInverseLengthParameter { 51 get { return InverseLengthParameter.Value != null; } 52 } 53 private bool HasFixedShapeParameter { 54 get { return ShapeParameter.Value != null; } 55 } 47 56 48 57 [StorableConstructor] … … 71 80 public int GetNumberOfParameters(int numberOfVariables) { 72 81 return 73 ( ScaleParameter.Value != null? 0 : 1) +74 ( ShapeParameter.Value != null? 0 : 1) +75 ( InverseLengthParameter.Value != null? 0 : numberOfVariables);82 (HasFixedScaleParameter ? 0 : 1) + 83 (HasFixedShapeParameter ? 0 : 1) + 84 (HasFixedInverseLengthParameter ? 0 : numberOfVariables); 76 85 } 77 86 … … 88 97 int c = 0; 89 98 // gather parameter values 90 if ( InverseLengthParameter.Value != null) {99 if (HasFixedInverseLengthParameter) { 91 100 inverseLength = InverseLengthParameter.Value.ToArray(); 92 101 } else { 93 102 int length = p.Length; 94 if ( ScaleParameter.Value == null) length--;95 if ( ShapeParameter.Value == null) length--;103 if (!HasFixedScaleParameter) length--; 104 if (!HasFixedShapeParameter) length--; 96 105 inverseLength = p.Select(e => 1.0 / Math.Exp(e)).Take(length).ToArray(); 97 106 c += inverseLength.Length; 98 107 } 99 if ( ScaleParameter.Value != null) {108 if (HasFixedScaleParameter) { 100 109 scale = ScaleParameter.Value.Value; 101 110 } else { … … 103 112 c++; 104 113 } 105 if ( ShapeParameter.Value != null) {114 if (HasFixedShapeParameter) { 106 115 shape = ShapeParameter.Value.Value; 107 116 } else { … … 116 125 double[] inverseLength; 117 126 GetParameterValues(p, out scale, out shape, out inverseLength); 127 var fixedInverseLength = HasFixedInverseLengthParameter; 128 var fixedScale = HasFixedScaleParameter; 129 var fixedShape = HasFixedShapeParameter; 118 130 // create functions 119 131 var cov = new ParameterizedCovarianceFunction(); … … 128 140 return scale * Math.Pow(1 + 0.5 * d / shape, -shape); 129 141 }; 130 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength );142 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength, fixedInverseLength, fixedScale, fixedShape); 131 143 return cov; 132 144 } 133 145 134 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double[] inverseLength) { 146 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double[] inverseLength, 147 bool fixedInverseLength, bool fixedScale, bool fixedShape) { 135 148 double d = i == j 136 149 ? 0.0 … … 138 151 double b = 1 + 0.5 * d / shape; 139 152 int k = 0; 140 foreach (var columnIndex in columnIndices) { 141 yield return scale * Math.Pow(b, -shape - 1) * Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]); 142 k++; 153 if (!fixedInverseLength) { 154 foreach (var columnIndex in columnIndices) { 155 yield return 156 scale * Math.Pow(b, -shape - 1) * 157 Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]); 158 k++; 159 } 143 160 } 144 yield return 2 * scale * Math.Pow(b, -shape);145 yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));161 if (!fixedScale) yield return 2 * scale * Math.Pow(b, -shape); 162 if (!fixedShape) yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b)); 146 163 } 147 164 } -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticIso.cs
r9456 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. … … 44 44 get { return (IValueParameter<DoubleValue>)Parameters["Shape"]; } 45 45 } 46 47 private bool HasFixedScaleParameter { 48 get { return ScaleParameter.Value != null; } 49 } 50 private bool HasFixedInverseLengthParameter { 51 get { return InverseLengthParameter.Value != null; } 52 } 53 private bool HasFixedShapeParameter { 54 get { return ShapeParameter.Value != null; } 55 } 56 57 46 58 [StorableConstructor] 47 59 private CovarianceRationalQuadraticIso(bool deserializing) … … 68 80 69 81 public int GetNumberOfParameters(int numberOfVariables) { 70 return ( ScaleParameter.Value != null? 0 : 1) +71 ( ShapeParameter.Value != null? 0 : 1) +72 ( InverseLengthParameter.Value != null? 0 : 1);82 return (HasFixedScaleParameter ? 0 : 1) + 83 (HasFixedShapeParameter ? 0 : 1) + 84 (HasFixedInverseLengthParameter ? 0 : 1); 73 85 } 74 86 … … 84 96 int c = 0; 85 97 // gather parameter values 86 if ( InverseLengthParameter.Value != null) {98 if (HasFixedInverseLengthParameter) { 87 99 inverseLength = InverseLengthParameter.Value.Value; 88 100 } else { … … 90 102 c++; 91 103 } 92 if ( ScaleParameter.Value != null) {104 if (HasFixedScaleParameter) { 93 105 scale = ScaleParameter.Value.Value; 94 106 } else { … … 96 108 c++; 97 109 } 98 if ( ShapeParameter.Value != null) {110 if (HasFixedShapeParameter) { 99 111 shape = ShapeParameter.Value.Value; 100 112 } else { … … 108 120 double scale, shape, inverseLength; 109 121 GetParameterValues(p, out scale, out shape, out inverseLength); 122 var fixedInverseLength = HasFixedInverseLengthParameter; 123 var fixedScale = HasFixedScaleParameter; 124 var fixedShape = HasFixedShapeParameter; 110 125 // create functions 111 126 var cov = new ParameterizedCovarianceFunction(); … … 120 135 return scale * Math.Pow(1 + 0.5 * d / shape, -shape); 121 136 }; 122 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength );137 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength, fixedInverseLength, fixedScale, fixedShape); 123 138 return cov; 124 139 } 125 140 126 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double inverseLength) { 141 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double inverseLength, 142 bool fixedInverseLength, bool fixedScale, bool fixedShape) { 127 143 double d = i == j 128 144 ? 0.0 … … 130 146 131 147 double b = 1 + 0.5 * d / shape; 132 yield return scale * Math.Pow(b, -shape - 1) * d;133 yield return 2 * scale * Math.Pow(b, -shape);134 yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));148 if (!fixedInverseLength) yield return scale * Math.Pow(b, -shape - 1) * d; 149 if (!fixedScale) yield return 2 * scale * Math.Pow(b, -shape); 150 if (!fixedShape) yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b)); 135 151 } 136 152 } -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceScale.cs
r9456 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. … … 37 37 get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; } 38 38 } 39 private bool HasFixedScaleParameter { 40 get { return ScaleParameter.Value != null; } 41 } 39 42 40 43 public IValueParameter<ICovarianceFunction> CovarianceFunctionParameter { … … 65 68 66 69 public int GetNumberOfParameters(int numberOfVariables) { 67 return ( ScaleParameter.Value != null? 0 : 1) + CovarianceFunctionParameter.Value.GetNumberOfParameters(numberOfVariables);70 return (HasFixedScaleParameter ? 0 : 1) + CovarianceFunctionParameter.Value.GetNumberOfParameters(numberOfVariables); 68 71 } 69 72 … … 77 80 private void GetParameterValues(double[] p, out double scale) { 78 81 // gather parameter values 79 if ( ScaleParameter.Value != null) {82 if (HasFixedScaleParameter) { 80 83 scale = ScaleParameter.Value.Value; 81 84 } else { … … 87 90 double scale; 88 91 GetParameterValues(p, out scale); 92 var fixedScale = HasFixedScaleParameter; 89 93 var subCov = CovarianceFunctionParameter.Value.GetParameterizedCovarianceFunction(p.Skip(1).ToArray(), columnIndices); 90 94 // create functions … … 92 96 cov.Covariance = (x, i, j) => scale * subCov.Covariance(x, i, j); 93 97 cov.CrossCovariance = (x, xt, i, j) => scale * subCov.CrossCovariance(x, xt, i, j); 94 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, subCov );98 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, subCov, fixedScale); 95 99 return cov; 96 100 } 97 101 98 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, ParameterizedCovarianceFunction cov) { 99 yield return 2 * scale * cov.Covariance(x, i, j); 102 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, ParameterizedCovarianceFunction cov, 103 bool fixedScale) { 104 if (!fixedScale) { 105 yield return 2 * scale * cov.Covariance(x, i, j); 106 } 100 107 foreach (var g in cov.CovarianceGradient(x, i, j)) 101 108 yield return scale * g; -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSpectralMixture.cs
r11170 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialArd.cs
r9456 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. … … 40 40 get { return (IValueParameter<DoubleArray>)Parameters["InverseLength"]; } 41 41 } 42 private bool HasFixedInverseLengthParameter { 43 get { return InverseLengthParameter.Value != null; } 44 } 45 private bool HasFixedScaleParameter { 46 get { return ScaleParameter.Value != null; } 47 } 42 48 43 49 [StorableConstructor] … … 61 67 public int GetNumberOfParameters(int numberOfVariables) { 62 68 return 63 ( ScaleParameter.Value != null? 0 : 1) +64 ( InverseLengthParameter.Value != null? 0 : numberOfVariables);69 (HasFixedScaleParameter ? 0 : 1) + 70 (HasFixedInverseLengthParameter ? 0 : numberOfVariables); 65 71 } 66 72 … … 76 82 int c = 0; 77 83 // gather parameter values 78 if ( InverseLengthParameter.Value != null) {84 if (HasFixedInverseLengthParameter) { 79 85 inverseLength = InverseLengthParameter.Value.ToArray(); 80 86 } else { 81 87 int length = p.Length; 82 if ( ScaleParameter.Value == null) length--;88 if (!HasFixedScaleParameter) length--; 83 89 inverseLength = p.Select(e => 1.0 / Math.Exp(e)).Take(length).ToArray(); 84 90 c += inverseLength.Length; 85 91 } 86 if ( ScaleParameter.Value != null) {92 if (HasFixedScaleParameter) { 87 93 scale = ScaleParameter.Value.Value; 88 94 } else { … … 97 103 double[] inverseLength; 98 104 GetParameterValues(p, out scale, out inverseLength); 105 var fixedInverseLength = HasFixedInverseLengthParameter; 106 var fixedScale = HasFixedScaleParameter; 99 107 // create functions 100 108 var cov = new ParameterizedCovarianceFunction(); … … 109 117 return scale * Math.Exp(-d / 2.0); 110 118 }; 111 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, inverseLength );119 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, inverseLength, fixedInverseLength, fixedScale); 112 120 return cov; 113 121 } 114 122 115 123 // order of returned gradients must match the order in GetParameterValues! 116 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double[] inverseLength) { 124 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double[] inverseLength, 125 bool fixedInverseLength, bool fixedScale) { 117 126 double d = i == j 118 127 ? 0.0 … … 120 129 121 130 int k = 0; 122 foreach (var columnIndex in columnIndices) { 123 double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]); 124 yield return scale * Math.Exp(-d / 2.0) * sqrDist; 125 k++; 131 if (!fixedInverseLength) { 132 foreach (var columnIndex in columnIndices) { 133 double sqrDist = Util.SqrDist(x[i, columnIndex] * inverseLength[k], x[j, columnIndex] * inverseLength[k]); 134 yield return scale * Math.Exp(-d / 2.0) * sqrDist; 135 k++; 136 } 126 137 } 127 yield return 2.0 * scale * Math.Exp(-d / 2.0);138 if (!fixedScale) yield return 2.0 * scale * Math.Exp(-d / 2.0); 128 139 } 129 140 } -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialIso.cs
r9456 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. … … 42 42 } 43 43 44 private bool HasFixedInverseLengthParameter { 45 get { return InverseLengthParameter.Value != null; } 46 } 47 private bool HasFixedScaleParameter { 48 get { return ScaleParameter.Value != null; } 49 } 50 44 51 [StorableConstructor] 45 52 private CovarianceSquaredExponentialIso(bool deserializing) … … 66 73 public int GetNumberOfParameters(int numberOfVariables) { 67 74 return 68 ( ScaleParameter.Value != null? 0 : 1) +69 ( InverseLengthParameter.Value != null? 0 : 1);75 (HasFixedScaleParameter ? 0 : 1) + 76 (HasFixedInverseLengthParameter ? 0 : 1); 70 77 } 71 78 … … 81 88 // gather parameter values 82 89 int c = 0; 83 if ( InverseLengthParameter.Value != null) {90 if (HasFixedInverseLengthParameter) { 84 91 inverseLength = InverseLengthParameter.Value.Value; 85 92 } else { … … 88 95 } 89 96 90 if ( ScaleParameter.Value != null) {97 if (HasFixedScaleParameter) { 91 98 scale = ScaleParameter.Value.Value; 92 99 } else { … … 100 107 double inverseLength, scale; 101 108 GetParameterValues(p, out scale, out inverseLength); 109 var fixedInverseLength = HasFixedInverseLengthParameter; 110 var fixedScale = HasFixedScaleParameter; 102 111 // create functions 103 112 var cov = new ParameterizedCovarianceFunction(); … … 112 121 return scale * Math.Exp(-d / 2.0); 113 122 }; 114 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, inverseLength, columnIndices); 123 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, scale, inverseLength, columnIndices, 124 fixedInverseLength, fixedScale); 115 125 return cov; 116 126 } 117 127 118 128 // order of returned gradients must match the order in GetParameterValues! 119 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double sf2, double inverseLength, IEnumerable<int> columnIndices) { 129 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double sf2, double inverseLength, IEnumerable<int> columnIndices, 130 bool fixedInverseLength, bool fixedScale) { 120 131 double d = i == j 121 132 ? 0.0 122 133 : Util.SqrDist(x, i, j, inverseLength, columnIndices); 123 134 double g = Math.Exp(-d / 2.0); 124 yield return sf2 * g * d;125 yield return 2.0 * sf2 * g;135 if (!fixedInverseLength) yield return sf2 * g * d; 136 if (!fixedScale) yield return 2.0 * sf2 * g; 126 137 } 127 138 } -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSum.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessBase.cs
r9456 r11594 2 2 #region License Information 3 3 /* HeuristicLab 4 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassification.cs
r9456 r11594 2 2 #region License Information 3 3 /* HeuristicLab 4 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassificationModelCreator.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassificationSolutionCreator.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessHyperparameterInitializer.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModelCreator.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegression.cs
r9456 r11594 2 2 #region License Information 3 3 /* HeuristicLab 4 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionModelCreator.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolution.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolutionCreator.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/ICovarianceFunction.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/IMeanFunction.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanConst.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanLinear.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanProduct.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanSum.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanFunctions/MeanZero.cs
r9456 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. -
branches/Breadcrumbs/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/Util.cs
r9456 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.
Note: See TracChangeset
for help on using the changeset viewer.