Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GaussianProcessRegressionTest.cs @ 10331

Last change on this file since 10331 was 9979, checked in by ascheibe, 11 years ago

#2108 Merged r9955-r9956, r9958-r9959, r9978 into stable branch

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