1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using HeuristicLab.Algorithms.DataAnalysis;
|
---|
26 | using HeuristicLab.Data;
|
---|
27 | using HeuristicLab.Random;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Problems.Instances.DataAnalysis {
|
---|
30 | public class GaussianProcess2dPeriodic : ArtificialRegressionDataDescriptor {
|
---|
31 |
|
---|
32 | public override string Name {
|
---|
33 | get {
|
---|
34 | return "Gaussian Process 2d periodic";
|
---|
35 | }
|
---|
36 | }
|
---|
37 | public override string Description {
|
---|
38 | get { return ""; }
|
---|
39 | }
|
---|
40 | protected override string TargetVariable { get { return "Y"; } }
|
---|
41 | protected override string[] VariableNames { get { return new string[] { "X1", "X2", "Y" }; } }
|
---|
42 | protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2" }; } }
|
---|
43 | protected override int TrainingPartitionStart { get { return 0; } }
|
---|
44 | protected override int TrainingPartitionEnd { get { return 20 * 20; } }
|
---|
45 | protected override int TestPartitionStart { get { return 20 * 20; } }
|
---|
46 | protected override int TestPartitionEnd { get { return 2 * (20 * 20); } }
|
---|
47 |
|
---|
48 | protected override List<List<double>> GenerateValues() {
|
---|
49 | List<List<double>> independentTrainingData = new List<List<double>>();
|
---|
50 | List<List<double>> independentTestData = new List<List<double>>();
|
---|
51 | for (int i = 0; i < AllowedInputVariables.Count(); i++) {
|
---|
52 | independentTrainingData.Add(ValueGenerator.GenerateSteps(0, 0.99, 1.0 / 20).ToList());
|
---|
53 | independentTestData.Add(ValueGenerator.GenerateSteps(0.005, 1, 1.0 / 20).ToList());
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | var trainingData = ValueGenerator.GenerateAllCombinationsOfValuesInLists(independentTrainingData);
|
---|
58 | var testData = ValueGenerator.GenerateAllCombinationsOfValuesInLists(independentTestData);
|
---|
59 | List<List<double>> data = new List<List<double>>();
|
---|
60 | foreach (var e in trainingData) {
|
---|
61 | data.Add(e.ToList());
|
---|
62 | }
|
---|
63 | int j = 0;
|
---|
64 | foreach (var e in testData) {
|
---|
65 | data[j].AddRange(e);
|
---|
66 | j++;
|
---|
67 | }
|
---|
68 |
|
---|
69 | var covarianceFunction = new CovarianceSum();
|
---|
70 | var m1 = new CovarianceMask();
|
---|
71 | m1.SelectedDimensionsParameter.Value = new IntArray(new int[] { 0 });
|
---|
72 | m1.CovarianceFunctionParameter.Value = new CovariancePeriodic();
|
---|
73 | var m2 = new CovarianceMask();
|
---|
74 | m2.SelectedDimensionsParameter.Value = new IntArray(new int[] { 1 });
|
---|
75 | m2.CovarianceFunctionParameter.Value = new CovariancePeriodic();
|
---|
76 |
|
---|
77 | covarianceFunction.Terms.Add(m1);
|
---|
78 | covarianceFunction.Terms.Add(m2);
|
---|
79 | covarianceFunction.Terms.Add(new CovarianceNoise());
|
---|
80 | var cov =
|
---|
81 | covarianceFunction.GetParameterizedCovarianceFunction(
|
---|
82 | Enumerable.Repeat(0.0, covarianceFunction.GetNumberOfParameters(2) - 1)
|
---|
83 | .Concat(new double[] { Math.Log(Math.Sqrt(0.01)) })
|
---|
84 | .ToArray(),
|
---|
85 | null);
|
---|
86 |
|
---|
87 | var mt = new MersenneTwister(31415);
|
---|
88 | var target = Util.SampleGaussianProcess(mt, cov, data);
|
---|
89 | data.Add(target);
|
---|
90 |
|
---|
91 | return data;
|
---|
92 | }
|
---|
93 | }
|
---|
94 | }
|
---|