Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GaussianProcessRegressionTest.cs @ 16124

Last change on this file since 16124 was 15583, checked in by swagner, 7 years ago

#2640: Updated year of copyrights in license headers

File size: 3.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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
22using System;
23using System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.Problems.DataAnalysis;
26using HeuristicLab.Problems.Instances.DataAnalysis;
27using Microsoft.VisualStudio.TestTools.UnitTesting;
28
29namespace HeuristicLab.Algorithms.DataAnalysis.Tests {
30  [TestClass]
31  public class GaussianProcessRegressionTest {
32    public GaussianProcessRegressionTest() { }
33
34    private TestContext testContextInstance;
35    public TestContext TestContext {
36      get { return testContextInstance; }
37      set { testContextInstance = value; }
38    }
39
40    private Exception ex;
41
42    [TestMethod]
43    [TestCategory("Algorithms.DataAnalysis")]
44    [TestProperty("Time", "long")]
45    public void GaussianProcessRegressionPerformanceTest() {
46      ex = null;
47
48      var alg = new GaussianProcessRegression();
49      alg.Engine = new HeuristicLab.SequentialEngine.SequentialEngine();
50      alg.SetSeedRandomly = false;
51
52      alg.Problem = new RegressionProblem();
53      var provider = new RegressionCSVInstanceProvider();
54      var problemData = (RegressionProblemData)provider.ImportData(@"Test Resources\co2.txt");
55      problemData.TargetVariableParameter.ActualValue = problemData.TargetVariableParameter.ValidValues.First(x => x.Value == "interpolated");
56      problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "year"), false);
57      problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "month"), false);
58      problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "average"), false);
59      problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "interpolated"), false);
60      problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "trend"), false);
61      problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "#days"), false);
62
63      alg.Problem.ProblemDataParameter.Value = problemData;
64
65      alg.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(cv_ExceptionOccurred);
66
67      alg.Prepare();
68      alg.Start();
69      if (ex != null) throw ex;
70
71      TestContext.WriteLine("Runtime: {0}", alg.ExecutionTime.ToString());
72    }
73
74    private void cv_ExceptionOccurred(object sender, EventArgs<Exception> e) {
75      ex = e.Value;
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.