Changeset 9212
- Timestamp:
- 02/08/13 21:56:11 (12 years ago)
- Location:
- branches/HeuristicLab.Problems.GaussianProcessTuning
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GaussianProcessTuning/GaussianProcessDemo/Form1.cs
r9124 r9212 27 27 28 28 var sum = new CovarianceSum(); 29 sum.Terms.Add(new CovarianceSquaredExponentialIso());30 29 sum.Terms.Add(new CovariancePeriodic()); 31 30 sum.Terms.Add(new CovarianceNoise()); … … 50 49 51 50 private void InitData() { 52 int n = 100;51 int n = 20; 53 52 data = new List<List<double>>(); 54 53 data.Add(ValueGenerator.GenerateSteps(0, 1, 1.0 / n).ToList()); -
branches/HeuristicLab.Problems.GaussianProcessTuning/GaussianProcessDemo/GaussianProcessDemo.csproj
r9124 r9212 31 31 <ErrorReport>prompt</ErrorReport> 32 32 <WarningLevel>4</WarningLevel> 33 </PropertyGroup> 34 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> 35 <DebugSymbols>true</DebugSymbols> 36 <OutputPath>bin\x86\Debug\</OutputPath> 37 <DefineConstants>DEBUG;TRACE</DefineConstants> 38 <DebugType>full</DebugType> 39 <PlatformTarget>x86</PlatformTarget> 40 <ErrorReport>prompt</ErrorReport> 41 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 42 <Prefer32Bit>true</Prefer32Bit> 43 </PropertyGroup> 44 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> 45 <OutputPath>bin\x86\Release\</OutputPath> 46 <DefineConstants>TRACE</DefineConstants> 47 <Optimize>true</Optimize> 48 <DebugType>pdbonly</DebugType> 49 <PlatformTarget>x86</PlatformTarget> 50 <ErrorReport>prompt</ErrorReport> 51 <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> 52 <Prefer32Bit>true</Prefer32Bit> 33 53 </PropertyGroup> 34 54 <ItemGroup> -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.GaussianProcessTuning.sln
r9124 r9212 173 173 {D18AE898-F600-4754-B3B4-C0C7A364F973}.Release|Mixed Platforms.Build.0 = Release|Any CPU 174 174 {D18AE898-F600-4754-B3B4-C0C7A364F973}.Release|x64.ActiveCfg = Release|Any CPU 175 {D18AE898-F600-4754-B3B4-C0C7A364F973}.Release|x86.ActiveCfg = Release|Any CPU 175 {D18AE898-F600-4754-B3B4-C0C7A364F973}.Release|x86.ActiveCfg = Release|x86 176 {D18AE898-F600-4754-B3B4-C0C7A364F973}.Release|x86.Build.0 = Release|x86 176 177 {D18AE898-F600-4754-B3B4-C0C7A364F973}.ReleaseBuild|Any CPU.ActiveCfg = Release|Any CPU 177 178 {D18AE898-F600-4754-B3B4-C0C7A364F973}.ReleaseBuild|Any CPU.Build.0 = Release|Any CPU -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.GaussianProcessTuning/GaussianProcessTuning.csproj
r9112 r9212 71 71 </PropertyGroup> 72 72 <ItemGroup> 73 <Reference Include="HeuristicLab.ALGLIB-3.6.0">74 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.ALGLIB-3.6.0.dll</HintPath>75 <Private>False</Private>76 </Reference>77 73 <Reference Include="HeuristicLab.Algorithms.DataAnalysis-3.4"> 78 74 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.DataAnalysis-3.4.dll</HintPath> … … 91 87 <Private>False</Private> 92 88 </Reference> 93 <Reference Include="HeuristicLab.Common.Resources-3.3">94 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>95 <Private>False</Private>96 </Reference>97 89 <Reference Include="HeuristicLab.Core-3.3"> 98 90 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath> 99 <Private>False</Private>100 </Reference>101 <Reference Include="HeuristicLab.Core.Views-3.3">102 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core.Views-3.3.dll</HintPath>103 91 <Private>False</Private> 104 92 </Reference> … … 111 99 <Private>False</Private> 112 100 </Reference> 113 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4">114 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.dll</HintPath>115 <Private>False</Private>116 </Reference>117 <Reference Include="HeuristicLab.MainForm-3.3">118 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.MainForm-3.3.dll</HintPath>119 <Private>False</Private>120 </Reference>121 <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3">122 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath>123 <Private>False</Private>124 </Reference>125 101 <Reference Include="HeuristicLab.Operators-3.3"> 126 102 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath> … … 129 105 <Reference Include="HeuristicLab.Optimization-3.3"> 130 106 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath> 131 <Private>False</Private>132 </Reference>133 <Reference Include="HeuristicLab.Optimization.Operators-3.3">134 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath>135 107 <Private>False</Private> 136 108 </Reference> … … 151 123 <Private>False</Private> 152 124 </Reference> 153 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4">154 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll</HintPath>155 <Private>False</Private>156 </Reference>157 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4">158 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll</HintPath>159 <Private>False</Private>160 </Reference>161 125 <Reference Include="HeuristicLab.Random-3.3"> 162 126 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath> … … 174 138 <Reference Include="System.Core" /> 175 139 <Reference Include="System.Drawing" /> 176 <Reference Include="System.Windows.Forms" />177 <Reference Include="System.Xml.Linq" />178 <Reference Include="System.Data.DataSetExtensions" />179 <Reference Include="Microsoft.CSharp" />180 <Reference Include="System.Data" />181 <Reference Include="System.Xml" />182 140 </ItemGroup> 183 141 <ItemGroup> 184 142 <Compile Include="BestSolutionAnalyzer.cs" /> 185 143 <Compile Include="GaussianProcessRegressionModel.cs" /> 186 <Compile Include="GaussianProcessModelView.designer.cs" />187 144 <Compile Include="Interpreter.cs"> 188 145 <SubType>Code</SubType> … … 196 153 <Compile Include="Plugin.cs" /> 197 154 <Compile Include="Properties\AssemblyInfo.cs" /> 198 <Compile Include="GaussianProcessModelView.cs">199 <SubType>UserControl</SubType>200 </Compile>201 155 <Compile Include="Symbols.cs" /> 202 156 <Compile Include="TreeNodes.cs" /> 203 </ItemGroup>204 <ItemGroup>205 <ProjectReference Include="..\HeuristicLab.Algorithms.DataAnalysis.Experimental\HeuristicLab.Algorithms.DataAnalysis.Experimental.csproj">206 <Project>{6142b24e-9c86-410b-a65a-1de65c8c2349}</Project>207 <Name>HeuristicLab.Algorithms.DataAnalysis.Experimental</Name>208 </ProjectReference>209 157 </ItemGroup> 210 158 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.GaussianProcessTuning/Grammar.cs
r8753 r9212 65 65 covMatern5.Name = "CovMatern5"; 66 66 var covPeriodic = new CovPeriodic(); 67 var covPeriodic1 = new CovPeriodic(1.0); 68 covPeriodic1.Name = "CovPeriodic(1.0)"; 69 var covPeriodicCO = new CovPeriodic(0.021817864467425927); 70 covPeriodicCO.Name = "CovPeriodicCO"; 67 71 var covNoise = new CovNoise(); 68 72 var covScale = new CovScale(); … … 97 101 covMatern5, 98 102 covPeriodic, 103 covPeriodic1, 104 covPeriodicCO, 99 105 covNoise, 100 106 covScale, … … 133 139 } 134 140 135 foreach (var covFunctionSymbol in new ISymbol[] { covSum, covProd, cov Mask, covScale }) {141 foreach (var covFunctionSymbol in new ISymbol[] { covSum, covProd, covScale }) { 136 142 foreach (var covSymbol in covSymbols) { 137 143 for (int i = 0; i < covFunctionSymbol.MaximumArity; i++) { … … 140 146 } 141 147 } 148 149 // mask 150 foreach (var covSymbol in new List<ISymbol>() 151 { 152 covConst, 153 covLin, 154 covLinArd, 155 covSeArd, 156 covSeIso, 157 covRQiso, 158 covRQard, 159 covMatern1, 160 covMatern3, 161 covMatern5, 162 covPeriodic, 163 covPeriodic1, 164 covPeriodicCO, 165 }) { 166 for (int i = 0; i < covMask.MaximumArity; i++) { 167 AddAllowedChildSymbol(covMask, covSymbol, i); 168 } 169 } 170 142 171 } 143 172 -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.GaussianProcessTuning/Interpreter.cs
r9112 r9212 36 36 gprAlg.GaussianProcessModelCreatorParameter.Value = 37 37 gprAlg.GaussianProcessModelCreatorParameter.ValidValues.First( 38 v => v is TunedGaussianProcessRegressionModelCreator);38 v => v is GaussianProcessRegressionModelCreator); 39 39 gprAlg.MinimizationIterations = 50; 40 40 … … 68 68 } 69 69 70 /*71 public void EvaluateGaussianProcessConfiguration(ISymbolicExpressionTree tree, IRegressionProblemData trainingData, Dataset testData, IEnumerable<int> testRows,72 out double[] means, out double[] variances) {73 string meanExpression, meanHyperParameter;74 string covExpression, covHyperParameter;75 string likFunction, likHyperParameter;76 GetMeanFunction(tree, trainingData.AllowedInputVariables.Count(), out meanExpression, out meanHyperParameter);77 GetCovFunction(tree, trainingData.AllowedInputVariables.Count(), out covExpression, out covHyperParameter);78 GetLikelihoodFunction(tree, out likFunction, out likHyperParameter);79 80 double[,] y = new double[trainingData.TrainingIndices.Count(), 1];81 double[,] yImg = new double[trainingData.TrainingIndices.Count(), 1];82 83 int r, c;84 r = 0;85 foreach (var e in trainingData.Dataset.GetDoubleValues(trainingData.TargetVariable, trainingData.TrainingIndices)) {86 y[r++, 0] = e;87 }88 double[,] x = new double[y.Length, trainingData.AllowedInputVariables.Count()];89 double[,] xImg = new double[y.Length, trainingData.AllowedInputVariables.Count()];90 c = 0;91 foreach (var allowedInput in trainingData.AllowedInputVariables) {92 r = 0;93 foreach (var e in trainingData.Dataset.GetDoubleValues(allowedInput, trainingData.TrainingIndices)) {94 x[r++, c] = e;95 }96 c++;97 }98 99 double[,] xTest = new double[testRows.Count(), trainingData.AllowedInputVariables.Count()];100 double[,] xTestImg = new double[testRows.Count(), trainingData.AllowedInputVariables.Count()];101 c = 0;102 foreach (var allowedInput in trainingData.AllowedInputVariables) {103 r = 0;104 foreach (var e in testData.GetDoubleValues(allowedInput, testRows)) {105 xTest[r++, c] = e;106 }107 c++;108 }109 110 object oldX = null;111 try {112 oldX = MLApp.GetVariable("x", "base");113 }114 catch {115 }116 if (oldX == null || oldX is Missing || ((double[,])oldX).Length != x.Length) {117 MLApp.PutFullMatrix("y", "base", y, yImg);118 MLApp.PutFullMatrix("x", "base", x, xImg);119 }120 MLApp.PutFullMatrix("xTest", "base", xTest, xTestImg);121 ExecuteMatlab("hyp0 = " + GetHyperParameterString(meanHyperParameter, covHyperParameter, likHyperParameter) + ";");122 ExecuteMatlab("infFun = " + GetInferenceMethodString(tree) + ";");123 ExecuteMatlab("meanExpr = " + meanExpression + ";");124 ExecuteMatlab("covExpr = " + covExpression + ";");125 ExecuteMatlab("likExp = " + likFunction + ";");126 ExecuteMatlab(127 "try " +128 " hyp = minimize(hyp0,'gp', -50, infFun, meanExpr, covExpr, likExp, x, y);" +129 " [ymu, ys2, fmu, fs2] = gp(hyp, infFun, meanExpr, covExpr, likExp, x, y, xTest); " +130 "catch " +131 " ymu = zeros(size(xTest, 1), 1); " +132 " ys2 = ones(size(xTest, 1), 1); " +133 "end");134 var meansMat = (double[,])MLApp.GetVariable("ymu", "base");135 var variancesMat = (double[,])MLApp.GetVariable("ys2", "base");136 means = new double[meansMat.GetLength(0)];137 for (int i = 0; i < means.Length; i++)138 means[i] = meansMat[i, 0];139 variances = new double[variancesMat.GetLength(0)];140 for (int i = 0; i < variances.Length; i++)141 variances[i] = variancesMat[i, 0];142 }143 */144 private string GetInferenceMethodString(ISymbolicExpressionTree tree) {145 return "'infEP'";146 }147 148 70 private IMeanFunction GetMeanFunction(ISymbolicExpressionTree tree) { 149 71 return GetMeanFunction(tree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(0)); … … 153 75 return GetCovFunction(tree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(1)); 154 76 } 155 156 157 private void GetLikelihoodFunction(ISymbolicExpressionTree tree, out string expression, out string hyperParameter) {158 var expressionBuilder = new StringBuilder();159 var hyperParameterBuilder = new StringBuilder();160 hyperParameterBuilder.Append("[");161 GetLikelihoodFunction(tree.Root.GetSubtree(0).GetSubtree(0).GetSubtree(2), expressionBuilder,162 hyperParameterBuilder);163 hyperParameterBuilder.Append("]");164 expression = expressionBuilder.ToString();165 hyperParameter = hyperParameterBuilder.ToString();166 }167 168 private void GetLikelihoodFunction(ISymbolicExpressionTreeNode node, StringBuilder expressionBuilder, StringBuilder hyperParameterBuilder) {169 if (node.Symbol is LikGauss) {170 var likNode = node as LikGaussTreeNode;171 expressionBuilder.Append("'likGauss'");172 hyperParameterBuilder.Append(likNode.Sigma);173 } else {174 throw new ArgumentException("unknown likelihood function " + node.Symbol);175 }176 }177 178 private string GetHyperParameterString(string meanHyp, string covHyp, string likHyp) {179 return "struct('mean', " + meanHyp +180 ", 'cov', " + covHyp +181 ", 'lik', " + likHyp +182 ")";183 ;184 }185 186 77 187 78 private ICovarianceFunction GetCovFunction(ISymbolicExpressionTreeNode node) { … … 189 80 return new CovarianceConst(); 190 81 } else if (node.Symbol is CovScale) { 191 return new CovarianceScale(); 82 var cov = new CovarianceScale(); 83 cov.CovarianceFunctionParameter.Value = GetCovFunction(node.GetSubtree(0)); 84 return cov; 192 85 } else if (node.Symbol is CovMask) { 193 86 var maskNode = node as CovMaskTreeNode; … … 197 90 where maskNode.Mask[i] 198 91 select i).ToArray()); 92 cov.CovarianceFunctionParameter.Value = GetCovFunction(node.GetSubtree(0)); 199 93 return cov; 200 94 } else if (node.Symbol is CovLin) { … … 312 206 //} 313 207 314 private string ToVectorString(bool[] b) {315 var strBuilder = new StringBuilder();316 strBuilder.Append("[");317 if (b.Length == 1) // workaround for bug in GPML318 {319 if (!b[0]) strBuilder.Append("1");320 } else {321 for (int i = 0; i < b.Length; i++) {322 if (i > 0) strBuilder.Append(", ");323 strBuilder.Append(b[i] ? "0" : "1");324 }325 }326 strBuilder.Append("]");327 return strBuilder.ToString();328 }329 private string ToVectorString(double[] xs, bool[] mask) {330 if (xs.Length != mask.Length) throw new ArgumentException();331 var strBuilder = new StringBuilder();332 strBuilder.Append("[");333 for (int i = 0; i < xs.Length; i++)334 if (!mask[i]) {335 if (i > 0) strBuilder.Append("; ");336 strBuilder.Append(xs[i]);337 }338 strBuilder.Append("]");339 return strBuilder.ToString();340 }341 208 } 342 209 } -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.GaussianProcessTuning/Plugin.cs
r8879 r9212 5 5 [Plugin("HeuristicLab.Problems.GaussianProcessTuning", "Gaussian process configuration problem for genetic programming", "1.0.0")] 6 6 [PluginFile("HeuristicLab.Problems.GaussianProcessTuning-1.0.dll", PluginFileType.Assembly)] 7 [PluginDependency("HeuristicLab.ALGLIB", "3.6.0")]8 7 [PluginDependency("HeuristicLab.Algorithms.DataAnalysis", "3.4")] 9 8 [PluginDependency("HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm", "3.3")] 10 9 [PluginDependency("HeuristicLab.Collections", "3.3")] 11 10 [PluginDependency("HeuristicLab.Common", "3.3")] 12 [PluginDependency("HeuristicLab.Common.Resources", "3.3")]13 11 [PluginDependency("HeuristicLab.Core", "3.3")] 14 [PluginDependency("HeuristicLab.Core.Views", "3.3")]15 12 [PluginDependency("HeuristicLab.Data", "3.3")] 16 13 [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")] 17 [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views", "3.4")]18 [PluginDependency("HeuristicLab.MainForm", "3.3")]19 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]20 14 [PluginDependency("HeuristicLab.Operators", "3.3")] 21 15 [PluginDependency("HeuristicLab.Optimization", "3.3")] 22 [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]23 16 [PluginDependency("HeuristicLab.Parameters", "3.3")] 24 17 [PluginDependency("HeuristicLab.Persistence", "3.3")] 25 18 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] 26 [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")]27 [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")]28 19 [PluginDependency("HeuristicLab.Random", "3.3")] 29 20 [PluginDependency("HeuristicLab.Selection", "3.3")] -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.GaussianProcessTuning/Symbols.cs
r8753 r9212 98 98 [StorableClass] 99 99 public sealed class MeanConst : Symbol { 100 [Storable]101 public double MinValue { get; set; }102 [Storable]103 public double MaxValue { get; set; }104 [Storable]105 public double ValueShakingMu { get; set; }106 [Storable]107 public double ValueShakingSigma { get; set; }108 109 100 public override int MinimumArity { 110 101 get { return 0; } … … 117 108 private MeanConst(MeanConst original, Cloner cloner) 118 109 : base(original, cloner) { 119 MinValue = original.MinValue;120 MaxValue = original.MaxValue;121 ValueShakingMu = original.ValueShakingMu;122 ValueShakingSigma = original.ValueShakingSigma;123 110 } 124 111 125 112 public MeanConst() 126 113 : base("MeanConst", "Constant mean function") { 127 MinValue = -100.0;128 MaxValue = 100.0;129 ValueShakingMu = 1.0;130 ValueShakingSigma = 1.0;131 114 } 132 115 [StorableHook(HookType.AfterDeserialization)] … … 144 127 [StorableClass] 145 128 public sealed class MeanLinear : Symbol, IDimensionSymbol { 146 [Storable]147 public double AlphaMu { get; set; }148 [Storable]149 public double AlphaSigma { get; set; }150 [Storable]151 public double AlphaShakingMu { get; set; }152 [Storable]153 public double AlphaShakingSigma { get; set; }154 155 129 public override int MinimumArity { 156 130 get { return 0; } … … 167 141 : base(original, cloner) { 168 142 Dimension = original.Dimension; 169 AlphaMu = original.AlphaMu;170 AlphaSigma = original.AlphaSigma;171 AlphaShakingMu = original.AlphaShakingMu;172 AlphaShakingSigma = original.AlphaShakingSigma;173 143 } 174 144 … … 176 146 : base("MeanLinear", "Linear mean function") { 177 147 this.Dimension = dimension; 178 AlphaMu = 0.0;179 AlphaSigma = 1.0;180 AlphaShakingMu = 1.0;181 AlphaShakingSigma = 0.1;182 148 } 183 149 [StorableHook(HookType.AfterDeserialization)] … … 197 163 [StorableClass] 198 164 public sealed class MeanScale : Symbol { 199 [Storable]200 public double AlphaMu { get; set; }201 [Storable]202 public double AlphaSigma { get; set; }203 [Storable]204 public double AlphaShakingMu { get; set; }205 [Storable]206 public double AlphaShakingSigma { get; set; }207 208 165 public override int MinimumArity { 209 166 get { return 1; } … … 217 174 private MeanScale(MeanScale original, Cloner cloner) 218 175 : base(original, cloner) { 219 AlphaMu = original.AlphaMu;220 AlphaSigma = original.AlphaSigma;221 AlphaShakingMu = original.AlphaShakingMu;222 AlphaShakingSigma = original.AlphaShakingSigma;223 176 } 224 177 225 178 public MeanScale() 226 179 : base("MeanScale", "Scaled version of a mean function") { 227 AlphaMu = 0.0;228 AlphaSigma = 1.0;229 AlphaShakingMu = 1.0;230 AlphaShakingSigma = 1.0;231 180 } 232 181 [StorableHook(HookType.AfterDeserialization)] … … 372 321 [StorableClass] 373 322 public sealed class CovConst : Symbol { 374 [Storable]375 public double MinSigma { get; set; }376 [Storable]377 public double MaxSigma { get; set; }378 [Storable]379 public double SigmaShakingMu { get; set; }380 [Storable]381 public double SigmaShakingSigma { get; set; }382 383 323 public override int MinimumArity { 384 324 get { return 0; } … … 391 331 private CovConst(CovConst original, Cloner cloner) 392 332 : base(original, cloner) { 393 this.MaxSigma = original.MaxSigma;394 this.MinSigma = original.MinSigma;395 this.SigmaShakingMu = original.SigmaShakingMu;396 this.SigmaShakingSigma = original.SigmaShakingSigma;397 333 } 398 334 399 335 public CovConst() 400 336 : base("CovConst", "Covariance for constant functions") { 401 MinSigma = 0.0;402 MaxSigma = 100;403 SigmaShakingMu = 1;404 SigmaShakingSigma = 1;405 337 } 406 338 [StorableHook(HookType.AfterDeserialization)] … … 418 350 [StorableClass] 419 351 public sealed class CovNoise : Symbol { 420 [Storable]421 public double MinSigma { get; set; }422 [Storable]423 public double MaxSigma { get; set; }424 [Storable]425 public double SigmaShakingMu { get; set; }426 [Storable]427 public double SigmaShakingSigma { get; set; }428 429 352 public override int MinimumArity { 430 353 get { return 0; } … … 437 360 private CovNoise(CovNoise original, Cloner cloner) 438 361 : base(original, cloner) { 439 this.MaxSigma = original.MaxSigma;440 this.MinSigma = original.MinSigma;441 this.SigmaShakingMu = original.SigmaShakingMu;442 this.SigmaShakingSigma = original.SigmaShakingSigma;443 362 } 444 363 445 364 public CovNoise() 446 365 : base("CovNoise", "Noise covariance function") { 447 MinSigma = 0.0;448 MaxSigma = 100;449 SigmaShakingMu = 1;450 SigmaShakingSigma = 1;451 366 } 452 367 [StorableHook(HookType.AfterDeserialization)] … … 492 407 [StorableClass] 493 408 public sealed class CovLinArd : Symbol, IDimensionSymbol { 494 [Storable]495 public double LambdaMu { get; set; }496 [Storable]497 public double LambdaSigma { get; set; }498 [Storable]499 public double LambdaShakingMu { get; set; }500 [Storable]501 public double LambdaShakingSigma { get; set; }502 409 public override int MinimumArity { 503 410 get { return 0; } … … 515 422 : base(original, cloner) { 516 423 Dimension = original.Dimension; 517 LambdaMu = original.LambdaMu;518 LambdaSigma = original.LambdaSigma;519 LambdaShakingMu = original.LambdaShakingMu;520 LambdaShakingSigma = original.LambdaShakingSigma;521 424 } 522 425 … … 524 427 : base("CovLinArd", "linear covariance function with ARD") { 525 428 this.Dimension = dimension; 526 LambdaMu = 0.0;527 LambdaSigma = 1.0;528 LambdaShakingMu = 1.0;529 LambdaShakingSigma = 0.1;530 429 } 531 430 [StorableHook(HookType.AfterDeserialization)] … … 542 441 [StorableClass] 543 442 public sealed class CovSeArd : Symbol, IDimensionSymbol { 544 [Storable]545 public double LambdaMu { get; set; }546 [Storable]547 public double LambdaSigma { get; set; }548 [Storable]549 public double LambdaShakingMu { get; set; }550 [Storable]551 public double LambdaShakingSigma { get; set; }552 [Storable]553 public double MinSigma { get; set; }554 [Storable]555 public double MaxSigma { get; set; }556 [Storable]557 public double SigmaShakingMu { get; set; }558 [Storable]559 public double SigmaShakingSigma { get; set; }560 561 443 public override int MinimumArity { 562 444 get { return 0; } … … 574 456 : base(original, cloner) { 575 457 Dimension = original.Dimension; 576 LambdaMu = original.LambdaMu;577 LambdaSigma = original.LambdaSigma;578 LambdaShakingMu = original.LambdaShakingMu;579 LambdaShakingSigma = original.LambdaShakingSigma;580 MinSigma = original.MinSigma;581 MaxSigma = original.MaxSigma;582 SigmaShakingMu = original.SigmaShakingMu;583 SigmaShakingSigma = original.SigmaShakingSigma;584 458 } 585 459 … … 587 461 : base("CovSeArd", "full squared exponential covariance function with ARD") { 588 462 this.Dimension = dimension; 589 LambdaMu = 0.0;590 LambdaSigma = 1.0;591 LambdaShakingMu = 1.0;592 LambdaShakingSigma = 0.1;593 MinSigma = 0.0;594 MaxSigma = 100.0;595 SigmaShakingMu = 1.0;596 SigmaShakingSigma = 1.0;597 463 } 598 464 [StorableHook(HookType.AfterDeserialization)] … … 609 475 [StorableClass] 610 476 public sealed class CovSeIso : Symbol { 611 [Storable]612 public double MinSigma { get; set; }613 [Storable]614 public double MaxSigma { get; set; }615 [Storable]616 public double SigmaShakingMu { get; set; }617 [Storable]618 public double SigmaShakingSigma { get; set; }619 [Storable]620 public double MinL { get; set; }621 [Storable]622 public double MaxL { get; set; }623 [Storable]624 public double LShakingMu { get; set; }625 [Storable]626 public double LShakingSigma { get; set; }627 628 477 public override int MinimumArity { 629 478 get { return 0; } … … 637 486 private CovSeIso(CovSeIso original, Cloner cloner) 638 487 : base(original, cloner) { 639 MinSigma = original.MinSigma;640 MaxSigma = original.MaxSigma;641 SigmaShakingMu = original.SigmaShakingMu;642 SigmaShakingSigma = original.SigmaShakingSigma;643 MinL = original.MinL;644 MaxL = original.MaxL;645 LShakingMu = original.LShakingMu;646 LShakingSigma = original.LShakingSigma;647 488 } 648 489 649 490 public CovSeIso() 650 491 : base("CovSeIso", "diagonal squared exponential covariance function") { 651 MinSigma = 1.0;652 MaxSigma = 100.0;653 SigmaShakingMu = 1.0;654 SigmaShakingSigma = 1.0;655 MinL = 1.0;656 MaxL = 100.0;657 LShakingMu = 1.0;658 LShakingSigma = 1.0;659 492 } 660 493 [StorableHook(HookType.AfterDeserialization)] … … 672 505 [StorableClass] 673 506 public sealed class CovMatern : Symbol { 674 [Storable]675 public double MinSigma { get; set; }676 [Storable]677 public double MaxSigma { get; set; }678 [Storable]679 public double SigmaShakingMu { get; set; }680 [Storable]681 public double SigmaShakingSigma { get; set; }682 [Storable]683 public double MinL { get; set; }684 [Storable]685 public double MaxL { get; set; }686 [Storable]687 public double LShakingMu { get; set; }688 [Storable]689 public double LShakingSigma { get; set; }690 691 507 [Storable] 692 508 public int D { get; set; } … … 703 519 private CovMatern(CovMatern original, Cloner cloner) 704 520 : base(original, cloner) { 705 MinSigma = original.MinSigma;706 MaxSigma = original.MaxSigma;707 SigmaShakingMu = original.SigmaShakingMu;708 SigmaShakingSigma = original.SigmaShakingSigma;709 MinL = original.MinL;710 MaxL = original.MaxL;711 LShakingMu = original.LShakingMu;712 LShakingSigma = original.LShakingSigma;713 521 D = original.D; 714 522 } … … 716 524 public CovMatern(int d) 717 525 : base("CovMatern", "Matern covariance function") { 718 MinSigma = 1.0;719 MaxSigma = 100.0;720 SigmaShakingMu = 1.0;721 SigmaShakingSigma = 1.0;722 MinL = 1.0;723 MaxL = 100.0;724 LShakingMu = 1.0;725 LShakingSigma = 1.0;726 526 this.D = d; 727 527 } … … 740 540 [StorableClass] 741 541 public sealed class CovPeriodic : Symbol { 742 [Storable] 743 public double MinSigma { get; set; } 744 [Storable] 745 public double MaxSigma { get; set; } 746 [Storable] 747 public double SigmaShakingMu { get; set; } 748 [Storable] 749 public double SigmaShakingSigma { get; set; } 750 [Storable] 751 public double MinL { get; set; } 752 [Storable] 753 public double MaxL { get; set; } 754 [Storable] 755 public double LShakingMu { get; set; } 756 [Storable] 757 public double LShakingSigma { get; set; } 758 [Storable] 759 public double MinPeriod { get; set; } 760 [Storable] 761 public double MaxPeriod { get; set; } 762 [Storable] 763 public double PeriodShakingMu { get; set; } 764 [Storable] 765 public double PeriodShakingSigma { get; set; } 766 767 public override int MinimumArity { 768 get { return 0; } 769 } 770 public override int MaximumArity { 771 get { return 0; } 772 } 542 public override int MinimumArity { 543 get { return 0; } 544 } 545 public override int MaximumArity { 546 get { return 0; } 547 } 548 549 [Storable] 550 private double? period; 551 public double? Period { 552 get { return period; } 553 } 554 773 555 774 556 [StorableConstructor] … … 776 558 private CovPeriodic(CovPeriodic original, Cloner cloner) 777 559 : base(original, cloner) { 778 MinSigma = original.MinSigma; 779 MaxSigma = original.MaxSigma; 780 SigmaShakingMu = original.SigmaShakingMu; 781 SigmaShakingSigma = original.SigmaShakingSigma; 782 MinL = original.MinL; 783 MaxL = original.MaxL; 784 LShakingMu = original.LShakingMu; 785 LShakingSigma = original.LShakingSigma; 786 MinPeriod = original.MinL; 787 MaxPeriod = original.MaxL; 788 PeriodShakingMu = original.PeriodShakingMu; 789 PeriodShakingSigma = original.PeriodShakingSigma; 790 } 791 792 public CovPeriodic() 560 period = original.period; 561 } 562 563 public CovPeriodic(double? period = null) 793 564 : base("CovPeriodic", "Periodic covariance function") { 794 MinSigma = 1.0; 795 MaxSigma = 100.0; 796 SigmaShakingMu = 1.0; 797 SigmaShakingSigma = 1.0; 798 MinL = 1.0; 799 MaxL = 100.0; 800 LShakingMu = 1.0; 801 LShakingSigma = 1.0; 802 MinPeriod = 1.0; 803 MaxPeriod = 100.0; 804 PeriodShakingMu = 1.0; 805 PeriodShakingSigma = 1.0; 565 this.period = period; 806 566 } 807 567 [StorableHook(HookType.AfterDeserialization)] … … 818 578 [StorableClass] 819 579 public sealed class CovRQArd : Symbol, IDimensionSymbol { 820 [Storable]821 public double LambdaMu { get; set; }822 [Storable]823 public double LambdaSigma { get; set; }824 [Storable]825 public double LambdaShakingMu { get; set; }826 [Storable]827 public double LambdaShakingSigma { get; set; }828 [Storable]829 public double MinSigma { get; set; }830 [Storable]831 public double MaxSigma { get; set; }832 [Storable]833 public double SigmaShakingMu { get; set; }834 [Storable]835 public double SigmaShakingSigma { get; set; }836 [Storable]837 public double MinShape { get; set; }838 [Storable]839 public double MaxShape { get; set; }840 [Storable]841 public double ShapeShakingMu { get; set; }842 [Storable]843 public double ShapeShakingSigma { get; set; }844 845 580 public override int MinimumArity { 846 581 get { return 0; } … … 858 593 : base(original, cloner) { 859 594 Dimension = original.Dimension; 860 LambdaMu = original.LambdaMu;861 LambdaSigma = original.LambdaSigma;862 LambdaShakingMu = original.LambdaShakingMu;863 LambdaShakingSigma = original.LambdaShakingSigma;864 MinSigma = original.MinSigma;865 MaxSigma = original.MaxSigma;866 SigmaShakingMu = original.SigmaShakingMu;867 SigmaShakingSigma = original.SigmaShakingSigma;868 MinShape = original.MinShape;869 MaxShape = original.MaxShape;870 ShapeShakingMu = original.ShapeShakingMu;871 ShapeShakingSigma = original.ShapeShakingSigma;872 595 } 873 596 … … 875 598 : base("CovRQArd", "full rational quadratic covariance function with ARD") { 876 599 this.Dimension = dimension; 877 LambdaMu = 0.0;878 LambdaSigma = 1.0;879 LambdaShakingMu = 1.0;880 LambdaShakingSigma = 0.1;881 MinSigma = 0.0;882 MaxSigma = 100.0;883 SigmaShakingMu = 1.0;884 SigmaShakingSigma = 1.0;885 MinShape = 1.0;886 MaxShape = 100.0;887 ShapeShakingMu = 1.0;888 ShapeShakingSigma = 1.0;889 600 } 890 601 [StorableHook(HookType.AfterDeserialization)] … … 901 612 [StorableClass] 902 613 public sealed class CovRQIso : Symbol { 903 [Storable]904 public double MinSigma { get; set; }905 [Storable]906 public double MaxSigma { get; set; }907 [Storable]908 public double SigmaShakingMu { get; set; }909 [Storable]910 public double SigmaShakingSigma { get; set; }911 [Storable]912 public double MinL { get; set; }913 [Storable]914 public double MaxL { get; set; }915 [Storable]916 public double LShakingMu { get; set; }917 [Storable]918 public double LShakingSigma { get; set; }919 [Storable]920 public double MinShape { get; set; }921 [Storable]922 public double MaxShape { get; set; }923 [Storable]924 public double ShapeShakingMu { get; set; }925 [Storable]926 public double ShapeShakingSigma { get; set; }927 928 614 public override int MinimumArity { 929 615 get { return 0; } … … 937 623 private CovRQIso(CovRQIso original, Cloner cloner) 938 624 : base(original, cloner) { 939 MinSigma = original.MinSigma;940 MaxSigma = original.MaxSigma;941 SigmaShakingMu = original.SigmaShakingMu;942 SigmaShakingSigma = original.SigmaShakingSigma;943 MinL = original.MinL;944 MaxL = original.MaxL;945 LShakingMu = original.LShakingMu;946 LShakingSigma = original.LShakingSigma;947 MinShape = original.MinShape;948 MaxShape = original.MaxShape;949 ShapeShakingMu = original.ShapeShakingMu;950 ShapeShakingSigma = original.ShapeShakingSigma;951 625 } 952 626 953 627 public CovRQIso() 954 628 : base("CovRQIso", "Rational quadratic covariance function") { 955 MinSigma = 1.0;956 MaxSigma = 100.0;957 SigmaShakingMu = 1.0;958 SigmaShakingSigma = 1.0;959 MinL = 1.0;960 MaxL = 100.0;961 LShakingMu = 1.0;962 LShakingSigma = 1.0;963 MinShape = 1.0;964 MaxShape = 100.0;965 ShapeShakingMu = 1.0;966 ShapeShakingSigma = 1.0;967 629 } 968 630 [StorableHook(HookType.AfterDeserialization)] … … 1034 696 [StorableClass] 1035 697 public sealed class CovScale : Symbol { 1036 [Storable]1037 public double AlphaMu { get; set; }1038 [Storable]1039 public double AlphaSigma { get; set; }1040 [Storable]1041 public double AlphaShakingMu { get; set; }1042 [Storable]1043 public double AlphaShakingSigma { get; set; }1044 698 1045 699 public override int MinimumArity { … … 1054 708 private CovScale(CovScale original, Cloner cloner) 1055 709 : base(original, cloner) { 1056 AlphaMu = original.AlphaMu;1057 AlphaSigma = original.AlphaSigma;1058 AlphaShakingMu = original.AlphaShakingMu;1059 AlphaShakingSigma = original.AlphaShakingSigma;1060 710 } 1061 711 1062 712 public CovScale() 1063 713 : base("CovScale", "Scale a covariance function") { 1064 AlphaMu = 0.0;1065 AlphaSigma = 1.0;1066 AlphaShakingMu = 1.0;1067 AlphaShakingSigma = 0.1;1068 714 } 1069 715 [StorableHook(HookType.AfterDeserialization)] … … 1122 768 [StorableClass] 1123 769 public sealed class LikGauss : Symbol { 1124 [Storable]1125 public double MinSigma { get; set; }1126 [Storable]1127 public double MaxSigma { get; set; }1128 [Storable]1129 public double SigmaShakingMu { get; set; }1130 [Storable]1131 public double SigmaShakingSigma { get; set; }1132 770 1133 771 public override int MinimumArity { … … 1142 780 private LikGauss(LikGauss original, Cloner cloner) 1143 781 : base(original, cloner) { 1144 this.MinSigma = original.MinSigma;1145 this.MaxSigma = original.MaxSigma;1146 this.SigmaShakingMu = original.SigmaShakingMu;1147 this.SigmaShakingSigma = original.SigmaShakingSigma;1148 782 } 1149 783 1150 784 public LikGauss() 1151 785 : base("LikGauss", "Gaussian likelihood function") { 1152 MinSigma = Math.Log(0.00001);1153 MaxSigma = Math.Log(100);1154 SigmaShakingMu = 1.0;1155 SigmaShakingSigma = 0.1;1156 786 } 1157 787 [StorableHook(HookType.AfterDeserialization)] -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.GaussianProcessTuning/TreeNodes.cs
r8753 r9212 30 30 public new MeanConst Symbol { get { return (MeanConst)base.Symbol; } } 31 31 32 public override bool HasLocalParameters {33 get { return true; }34 }35 36 private double value;37 [Storable]38 public double Value { get { return value; } private set { this.value = value; } }39 40 32 [StorableConstructor] 41 33 private MeanConstTreeNode(bool deserializing) : base(deserializing) { } 42 34 private MeanConstTreeNode(MeanConstTreeNode original, Cloner cloner) 43 35 : base(original, cloner) { 44 this.value = original.value;45 36 } 46 37 … … 52 43 public override IDeepCloneable Clone(Cloner cloner) { 53 44 return new MeanConstTreeNode(this, cloner); 54 }55 public override void ResetLocalParameters(IRandom random) {56 value = Symbol.MinValue + random.NextDouble() * (Symbol.MaxValue - Symbol.MinValue);57 }58 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {59 var normRandom = new NormalDistributedRandom(random, Symbol.ValueShakingMu, Symbol.ValueShakingSigma);60 value = Math.Max(Symbol.MinValue, Math.Min(Symbol.MaxValue, value + normRandom.NextDouble() * shakingFactor));61 45 } 62 46 } … … 65 49 public new MeanLinear Symbol { get { return (MeanLinear)base.Symbol; } } 66 50 67 public override bool HasLocalParameters {68 get { return true; }69 }70 71 [Storable]72 public double[] Alpha { get; set; }73 74 51 [StorableConstructor] 75 52 private MeanLinearTreeNode(bool deserializing) : base(deserializing) { } 76 53 private MeanLinearTreeNode(MeanLinearTreeNode original, Cloner cloner) 77 54 : base(original, cloner) { 78 Alpha = new double[original.Alpha.Length];79 Array.Copy(original.Alpha, Alpha, Alpha.Length);80 55 } 81 56 82 57 public MeanLinearTreeNode(MeanLinear symbol) 83 58 : base(symbol) { 84 Alpha = new double[symbol.Dimension];85 59 } 86 60 … … 90 64 public override IDeepCloneable Clone(Cloner cloner) { 91 65 return new MeanLinearTreeNode(this, cloner); 92 }93 public override void ResetLocalParameters(IRandom random) {94 var normRandom = new NormalDistributedRandom(random, Symbol.AlphaMu, Symbol.AlphaSigma);95 for (int i = 0; i < Alpha.Length; i++)96 Alpha[i] = normRandom.NextDouble();97 }98 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {99 var normRandom = new NormalDistributedRandom(random, Symbol.AlphaShakingMu, Symbol.AlphaShakingSigma);100 int index = random.Next(Alpha.Length);101 Alpha[index] += shakingFactor * normRandom.NextDouble();102 66 } 103 67 } … … 108 72 public new MeanScale Symbol { get { return (MeanScale)base.Symbol; } } 109 73 110 public override bool HasLocalParameters {111 get { return true; }112 }113 114 private double alpha;115 [Storable]116 public double Alpha { get { return alpha; } private set { this.alpha = value; } }117 118 74 [StorableConstructor] 119 75 private MeanScaleTreeNode(bool deserializing) : base(deserializing) { } 120 76 private MeanScaleTreeNode(MeanScaleTreeNode original, Cloner cloner) 121 77 : base(original, cloner) { 122 this.alpha = original.alpha;123 78 } 124 79 … … 130 85 public override IDeepCloneable Clone(Cloner cloner) { 131 86 return new MeanScaleTreeNode(this, cloner); 132 }133 public override void ResetLocalParameters(IRandom random) {134 var normRandom = new NormalDistributedRandom(random, Symbol.AlphaMu, Symbol.AlphaSigma);135 alpha = normRandom.NextDouble();136 }137 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {138 var normRandom = new NormalDistributedRandom(random, Symbol.AlphaShakingMu, Symbol.AlphaShakingSigma);139 alpha += shakingFactor * normRandom.NextDouble();140 87 } 141 88 } … … 184 131 public new CovConst Symbol { get { return (CovConst)base.Symbol; } } 185 132 186 public override bool HasLocalParameters {187 get { return true; }188 }189 190 private double sigma;191 [Storable]192 public double Sigma { get { return sigma; } private set { this.sigma = value; } }193 194 133 [StorableConstructor] 195 134 private CovConstTreeNode(bool deserializing) : base(deserializing) { } 196 135 private CovConstTreeNode(CovConstTreeNode original, Cloner cloner) 197 136 : base(original, cloner) { 198 this.sigma = original.sigma;199 137 } 200 138 … … 206 144 public override IDeepCloneable Clone(Cloner cloner) { 207 145 return new CovConstTreeNode(this, cloner); 208 }209 public override void ResetLocalParameters(IRandom random) {210 sigma = random.Next((int)Symbol.MinSigma, (int)Symbol.MaxSigma);211 }212 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {213 var normRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);214 sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, sigma + normRandom.NextDouble() * shakingFactor));215 146 } 216 147 } … … 219 150 public new CovNoise Symbol { get { return (CovNoise)base.Symbol; } } 220 151 221 public override bool HasLocalParameters {222 get { return true; }223 }224 225 private double sigma;226 [Storable]227 public double Sigma { get { return sigma; } private set { this.sigma = value; } }228 229 152 [StorableConstructor] 230 153 private CovNoiseTreeNode(bool deserializing) : base(deserializing) { } 231 154 private CovNoiseTreeNode(CovNoiseTreeNode original, Cloner cloner) 232 155 : base(original, cloner) { 233 this.sigma = original.sigma;234 156 } 235 157 … … 241 163 public override IDeepCloneable Clone(Cloner cloner) { 242 164 return new CovNoiseTreeNode(this, cloner); 243 }244 public override void ResetLocalParameters(IRandom random) {245 sigma = random.Next((int)Symbol.MinSigma, (int)Symbol.MaxSigma);246 }247 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {248 var normRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);249 sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, sigma + normRandom.NextDouble() * shakingFactor));250 165 } 251 166 } … … 254 169 public new CovLinArd Symbol { get { return (CovLinArd)base.Symbol; } } 255 170 256 public override bool HasLocalParameters {257 get { return true; }258 }259 260 [Storable]261 public double[] Lambda { get; set; }262 263 171 [StorableConstructor] 264 172 private CovLinArdTreeNode(bool deserializing) : base(deserializing) { } 265 173 private CovLinArdTreeNode(CovLinArdTreeNode original, Cloner cloner) 266 174 : base(original, cloner) { 267 Lambda = new double[original.Lambda.Length];268 Array.Copy(original.Lambda, Lambda, Lambda.Length);269 175 } 270 176 271 177 public CovLinArdTreeNode(CovLinArd symbol) 272 178 : base(symbol) { 273 Lambda = new double[symbol.Dimension];274 179 } 275 180 … … 279 184 public override IDeepCloneable Clone(Cloner cloner) { 280 185 return new CovLinArdTreeNode(this, cloner); 281 }282 public override void ResetLocalParameters(IRandom random) {283 var normRandom = new NormalDistributedRandom(random, Symbol.LambdaMu, Symbol.LambdaSigma);284 for (int i = 0; i < Lambda.Length; i++)285 Lambda[i] = normRandom.NextDouble();286 }287 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {288 int index = random.Next(Lambda.Length);289 var normRandom = new NormalDistributedRandom(random, Symbol.LambdaShakingMu, Symbol.LambdaShakingSigma);290 Lambda[index] += shakingFactor * normRandom.NextDouble();291 186 } 292 187 } … … 294 189 public sealed class CovSeArdTreeNode : SymbolicExpressionTreeTerminalNode { 295 190 public new CovSeArd Symbol { get { return (CovSeArd)base.Symbol; } } 296 297 public override bool HasLocalParameters {298 get { return true; }299 }300 301 [Storable]302 public double[] Lambda { get; set; }303 304 [Storable]305 public double Sigma { get; set; }306 307 191 [StorableConstructor] 308 192 private CovSeArdTreeNode(bool deserializing) : base(deserializing) { } 309 193 private CovSeArdTreeNode(CovSeArdTreeNode original, Cloner cloner) 310 194 : base(original, cloner) { 311 Lambda = new double[original.Lambda.Length];312 Array.Copy(original.Lambda, Lambda, Lambda.Length);313 Sigma = original.Sigma;314 195 } 315 196 316 197 public CovSeArdTreeNode(CovSeArd symbol) 317 198 : base(symbol) { 318 Lambda = new double[symbol.Dimension];319 199 } 320 200 … … 324 204 public override IDeepCloneable Clone(Cloner cloner) { 325 205 return new CovSeArdTreeNode(this, cloner); 326 }327 public override void ResetLocalParameters(IRandom random) {328 var normRandom = new NormalDistributedRandom(random, Symbol.LambdaMu, Symbol.LambdaSigma);329 for (int i = 0; i < Lambda.Length; i++)330 Lambda[i] = normRandom.NextDouble();331 332 Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);333 }334 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {335 int index = random.Next(Lambda.Length);336 var normRandom = new NormalDistributedRandom(random, Symbol.LambdaShakingMu, Symbol.LambdaShakingSigma);337 Lambda[index] += shakingFactor * normRandom.NextDouble();338 339 var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);340 Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));341 206 } 342 207 } … … 345 210 public new CovSeIso Symbol { get { return (CovSeIso)base.Symbol; } } 346 211 347 public override bool HasLocalParameters {348 get { return true; }349 }350 351 [Storable]352 public double L { get; set; }353 354 [Storable]355 public double Sigma { get; set; }356 357 212 [StorableConstructor] 358 213 private CovSeIsoTreeNode(bool deserializing) : base(deserializing) { } 359 214 private CovSeIsoTreeNode(CovSeIsoTreeNode original, Cloner cloner) 360 215 : base(original, cloner) { 361 L = original.L;362 Sigma = original.Sigma;363 216 } 364 217 … … 372 225 public override IDeepCloneable Clone(Cloner cloner) { 373 226 return new CovSeIsoTreeNode(this, cloner); 374 }375 public override void ResetLocalParameters(IRandom random) {376 Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);377 L = Symbol.MinL + random.NextDouble() * (Symbol.MaxL - Symbol.MinL);378 }379 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {380 var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);381 Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));382 383 var lRandom = new NormalDistributedRandom(random, Symbol.LShakingMu, Symbol.LShakingSigma);384 L = Math.Max(Symbol.MinL, Math.Min(Symbol.MaxL, L + shakingFactor * lRandom.NextDouble()));385 227 } 386 228 } … … 389 231 public new CovMatern Symbol { get { return (CovMatern)base.Symbol; } } 390 232 391 public override bool HasLocalParameters {392 get { return true; }393 }394 395 [Storable]396 public double L { get; set; }397 398 [Storable]399 public double Sigma { get; set; }400 401 233 [StorableConstructor] 402 234 private CovMaternTreeNode(bool deserializing) : base(deserializing) { } 403 235 private CovMaternTreeNode(CovMaternTreeNode original, Cloner cloner) 404 236 : base(original, cloner) { 405 L = original.L;406 Sigma = original.Sigma;407 237 } 408 238 … … 416 246 public override IDeepCloneable Clone(Cloner cloner) { 417 247 return new CovMaternTreeNode(this, cloner); 418 }419 public override void ResetLocalParameters(IRandom random) {420 Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);421 L = Symbol.MinL + random.NextDouble() * (Symbol.MaxL - Symbol.MinL);422 }423 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {424 var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);425 Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));426 427 var lRandom = new NormalDistributedRandom(random, Symbol.LShakingMu, Symbol.LShakingSigma);428 L = Math.Max(Symbol.MinL, Math.Min(Symbol.MaxL, L + shakingFactor * lRandom.NextDouble()));429 248 } 430 249 } … … 433 252 public new CovPeriodic Symbol { get { return (CovPeriodic)base.Symbol; } } 434 253 435 public override bool HasLocalParameters {436 get { return true; }437 }438 439 [Storable]440 public double L { get; set; }441 442 [Storable]443 public double Sigma { get; set; }444 445 [Storable]446 public double Period { get; set; }447 448 254 [StorableConstructor] 449 255 private CovPeriodicTreeNode(bool deserializing) : base(deserializing) { } 450 256 private CovPeriodicTreeNode(CovPeriodicTreeNode original, Cloner cloner) 451 257 : base(original, cloner) { 452 L = original.L;453 Sigma = original.Sigma;454 Period = original.Period;455 258 } 456 259 … … 464 267 public override IDeepCloneable Clone(Cloner cloner) { 465 268 return new CovPeriodicTreeNode(this, cloner); 466 }467 public override void ResetLocalParameters(IRandom random) {468 Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);469 L = Symbol.MinL + random.NextDouble() * (Symbol.MaxL - Symbol.MinL);470 Period = Symbol.MinPeriod + random.NextDouble() * (Symbol.MaxPeriod - Symbol.MinPeriod);471 }472 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {473 var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);474 Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));475 476 var lRandom = new NormalDistributedRandom(random, Symbol.LShakingMu, Symbol.LShakingSigma);477 L = Math.Max(Symbol.MinL, Math.Min(Symbol.MaxL, L + shakingFactor * lRandom.NextDouble()));478 479 var pRandom = new NormalDistributedRandom(random, Symbol.PeriodShakingMu, Symbol.PeriodShakingSigma);480 Period = Math.Max(Symbol.MinPeriod, Math.Min(Symbol.MaxPeriod, Period + shakingFactor * pRandom.NextDouble()));481 269 } 482 270 } … … 486 274 public new CovRQArd Symbol { get { return (CovRQArd)base.Symbol; } } 487 275 488 public override bool HasLocalParameters {489 get { return true; }490 }491 492 [Storable]493 public double[] Lambda { get; set; }494 495 [Storable]496 public double Sigma { get; set; }497 498 [Storable]499 public double Shape { get; set; }500 501 276 [StorableConstructor] 502 277 private CovRQArdTreeNode(bool deserializing) : base(deserializing) { } 503 278 private CovRQArdTreeNode(CovRQArdTreeNode original, Cloner cloner) 504 279 : base(original, cloner) { 505 Lambda = new double[original.Lambda.Length];506 Array.Copy(original.Lambda, Lambda, Lambda.Length);507 Sigma = original.Sigma;508 Shape = original.Shape;509 280 } 510 281 511 282 public CovRQArdTreeNode(CovRQArd symbol) 512 283 : base(symbol) { 513 Lambda = new double[symbol.Dimension];514 284 } 515 285 … … 519 289 public override IDeepCloneable Clone(Cloner cloner) { 520 290 return new CovRQArdTreeNode(this, cloner); 521 }522 public override void ResetLocalParameters(IRandom random) {523 var normRandom = new NormalDistributedRandom(random, Symbol.LambdaMu, Symbol.LambdaSigma);524 for (int i = 0; i < Lambda.Length; i++)525 Lambda[i] = normRandom.NextDouble();526 527 Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);528 Shape = Symbol.MinShape + random.NextDouble() * (Symbol.MaxShape - Symbol.MinShape);529 }530 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {531 int index = random.Next(Lambda.Length);532 var normRandom = new NormalDistributedRandom(random, Symbol.LambdaShakingMu, Symbol.LambdaShakingSigma);533 Lambda[index] += shakingFactor * normRandom.NextDouble();534 535 var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);536 Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));537 538 var shapeRandom = new NormalDistributedRandom(random, Symbol.ShapeShakingMu, Symbol.ShapeShakingSigma);539 Sigma = Math.Max(Symbol.MinShape, Math.Min(Symbol.MaxShape, Shape + shakingFactor * shapeRandom.NextDouble()));540 291 } 541 292 } … … 545 296 public new CovRQIso Symbol { get { return (CovRQIso)base.Symbol; } } 546 297 547 public override bool HasLocalParameters {548 get { return true; }549 }550 551 [Storable]552 public double L { get; set; }553 554 [Storable]555 public double Sigma { get; set; }556 557 [Storable]558 public double Shape { get; set; }559 560 298 [StorableConstructor] 561 299 private CovRQisoTreeNode(bool deserializing) : base(deserializing) { } 562 300 private CovRQisoTreeNode(CovRQisoTreeNode original, Cloner cloner) 563 301 : base(original, cloner) { 564 L = original.L;565 Sigma = original.Sigma;566 Shape = original.Shape;567 302 } 568 303 … … 576 311 public override IDeepCloneable Clone(Cloner cloner) { 577 312 return new CovRQisoTreeNode(this, cloner); 578 }579 public override void ResetLocalParameters(IRandom random) {580 Sigma = Symbol.MinSigma + random.NextDouble() * (Symbol.MaxSigma - Symbol.MinSigma);581 L = Symbol.MinL + random.NextDouble() * (Symbol.MaxL - Symbol.MinL);582 Shape = Symbol.MinShape + random.NextDouble() * (Symbol.MaxShape - Symbol.MinShape);583 }584 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {585 var sigmaRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);586 Sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, Sigma + shakingFactor * sigmaRandom.NextDouble()));587 588 var lRandom = new NormalDistributedRandom(random, Symbol.LShakingMu, Symbol.LShakingSigma);589 L = Math.Max(Symbol.MinL, Math.Min(Symbol.MaxL, L + shakingFactor * lRandom.NextDouble()));590 591 var shapeRandom = new NormalDistributedRandom(random, Symbol.ShapeShakingMu, Symbol.ShapeShakingSigma);592 Shape = Math.Max(Symbol.MinShape, Math.Min(Symbol.MaxShape, Shape + shakingFactor * shapeRandom.NextDouble()));593 313 } 594 314 } … … 597 317 public new CovScale Symbol { get { return (CovScale)base.Symbol; } } 598 318 599 public override bool HasLocalParameters {600 get { return true; }601 }602 603 private double alpha;604 [Storable]605 public double Alpha { get { return alpha; } private set { this.alpha = value; } }606 607 319 [StorableConstructor] 608 320 private CovScaleTreeNode(bool deserializing) : base(deserializing) { } 609 321 private CovScaleTreeNode(CovScaleTreeNode original, Cloner cloner) 610 322 : base(original, cloner) { 611 this.alpha = original.alpha;612 323 } 613 324 … … 619 330 public override IDeepCloneable Clone(Cloner cloner) { 620 331 return new CovScaleTreeNode(this, cloner); 621 }622 public override void ResetLocalParameters(IRandom random) {623 var normRandom = new NormalDistributedRandom(random, Symbol.AlphaMu, Symbol.AlphaSigma);624 alpha = normRandom.NextDouble();625 }626 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {627 var normRandom = new NormalDistributedRandom(random, Symbol.AlphaShakingMu, Symbol.AlphaShakingSigma);628 alpha += shakingFactor * normRandom.NextDouble();629 332 } 630 333 } … … 674 377 public new LikGauss Symbol { get { return (LikGauss)base.Symbol; } } 675 378 676 public override bool HasLocalParameters {677 get { return true; }678 }679 680 private double sigma;681 [Storable]682 public double Sigma { get { return sigma; } private set { this.sigma = value; } }683 684 379 [StorableConstructor] 685 380 private LikGaussTreeNode(bool deserializing) : base(deserializing) { } 686 381 private LikGaussTreeNode(LikGaussTreeNode original, Cloner cloner) 687 382 : base(original, cloner) { 688 this.sigma = original.sigma;689 383 } 690 384 … … 697 391 return new LikGaussTreeNode(this, cloner); 698 392 } 699 public override void ResetLocalParameters(IRandom random) {700 sigma = random.Next((int)Symbol.MinSigma, (int)Symbol.MaxSigma);701 }702 public override void ShakeLocalParameters(IRandom random, double shakingFactor) {703 var normRandom = new NormalDistributedRandom(random, Symbol.SigmaShakingMu, Symbol.SigmaShakingSigma);704 sigma = Math.Max(Symbol.MinSigma, Math.Min(Symbol.MaxSigma, sigma + normRandom.NextDouble() * shakingFactor));705 }706 393 } 707 394 } -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.Instances.DataAnalysis.GaussianProcessRegression/Instances.DataAnalysis.GaussianProcessRegression-3.3.csproj
r9124 r9212 178 178 </ItemGroup> 179 179 <ItemGroup> 180 <Compile Include="GaussianProcessRegressionInstance1D.cs" /> 181 <Compile Include="GaussianProcessRegressionInstance2D.cs" /> 180 182 <Compile Include="GaussianProcessSumOfRQIso.cs" /> 181 183 <Compile Include="GaussianProcessSumOfSEIso.cs" /> -
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.Instances.DataAnalysis.GaussianProcessRegression/VariousInstanceProvider.cs
r9124 r9212 24 24 using System.Linq; 25 25 using HeuristicLab.Algorithms.DataAnalysis; 26 using HeuristicLab.Data; 26 27 27 28 namespace HeuristicLab.Problems.Instances.DataAnalysis { … … 124 125 } 125 126 127 { 128 var cov = new CovarianceSum(); 129 cov.Terms.Add(new CovarianceSquaredExponentialIso()); 130 cov.Terms.Add(new CovarianceNoise()); 131 var hyp = new double[] { -2.5, 0, -7 }; 132 descriptorList.Add(new GaussianProcessRegressionInstance1D("1D: SE", cov, hyp)); 133 } 134 { 135 var cov = new CovarianceSum(); 136 cov.Terms.Add(new CovarianceRationalQuadraticIso()); 137 cov.Terms.Add(new CovarianceNoise()); 138 var hyp = new double[] { -2.5, 0, -2, -7 }; 139 descriptorList.Add(new GaussianProcessRegressionInstance1D("1D: RQ", cov, hyp)); 140 } 141 { 142 var cov = new CovarianceSum(); 143 cov.Terms.Add(new CovarianceMaternIso()); 144 cov.Terms.Add(new CovarianceNoise()); 145 var hyp = new double[] { -2, 0, -7 }; 146 descriptorList.Add(new GaussianProcessRegressionInstance1D("1D: Matern1", cov, hyp)); 147 } 148 { 149 var cov = new CovarianceSum(); 150 cov.Terms.Add(new CovariancePeriodic()); 151 cov.Terms.Add(new CovarianceNoise()); 152 var hyp = new double[] { 0, -1.3, 0, -7 }; 153 descriptorList.Add(new GaussianProcessRegressionInstance1D("1D: Periodic", cov, hyp)); 154 } 155 { 156 var cov = new CovarianceSum(); 157 cov.Terms.Add(new CovarianceSquaredExponentialIso()); 158 cov.Terms.Add(new CovarianceNoise()); 159 var hyp = new double[] { -2.5, 0, -7 }; 160 descriptorList.Add(new GaussianProcessRegressionInstance1D("1D: SE", cov, hyp)); 161 } 162 { 163 var cov = new CovarianceSum(); 164 var m1 = new CovarianceMask(); 165 m1.SelectedDimensionsParameter.Value = new IntArray(new int[] { 0 }); 166 m1.CovarianceFunctionParameter.Value = new CovarianceSquaredExponentialIso(); 167 168 var m2 = new CovarianceMask(); 169 m2.SelectedDimensionsParameter.Value = new IntArray(new int[] { 1 }); 170 m2.CovarianceFunctionParameter.Value = new CovarianceRationalQuadraticIso(); 171 172 cov.Terms.Add(m1); 173 cov.Terms.Add(m2); 174 cov.Terms.Add(new CovarianceNoise()); 175 var hyp = new double[] { -2.5, 0, -2.0, 0, -2, -7 }; 176 descriptorList.Add(new GaussianProcessRegressionInstance2D("2D: SE+RQ", cov, hyp)); 177 } 178 { 179 var cov = new CovarianceSum(); 180 var m1 = new CovarianceMask(); 181 m1.SelectedDimensionsParameter.Value = new IntArray(new int[] { 0 }); 182 m1.CovarianceFunctionParameter.Value = new CovarianceSquaredExponentialIso(); 183 184 var m2 = new CovarianceMask(); 185 m2.SelectedDimensionsParameter.Value = new IntArray(new int[] { 1 }); 186 m2.CovarianceFunctionParameter.Value = new CovarianceMaternIso(); 187 188 cov.Terms.Add(m1); 189 cov.Terms.Add(m2); 190 cov.Terms.Add(new CovarianceNoise()); 191 var hyp = new double[] { -2.5, 0, 2, 0, -7 }; 192 descriptorList.Add(new GaussianProcessRegressionInstance2D("2D: SE+Matern1", cov, hyp)); 193 } 194 { 195 var cov = new CovarianceSum(); 196 var m1 = new CovarianceMask(); 197 m1.SelectedDimensionsParameter.Value = new IntArray(new int[] { 0 }); 198 m1.CovarianceFunctionParameter.Value = new CovarianceSquaredExponentialIso(); 199 200 var m2 = new CovarianceMask(); 201 m2.SelectedDimensionsParameter.Value = new IntArray(new int[] { 1 }); 202 m2.CovarianceFunctionParameter.Value = new CovariancePeriodic(); 203 204 cov.Terms.Add(m1); 205 cov.Terms.Add(m2); 206 cov.Terms.Add(new CovarianceNoise()); 207 var hyp = new double[] { -2.5, 0, 0, -1.3, 0, -7 }; 208 descriptorList.Add(new GaussianProcessRegressionInstance2D("2D: SE+Periodic", cov, hyp)); 209 } 210 211 126 212 127 213 return descriptorList;
Note: See TracChangeset
for help on using the changeset viewer.