1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 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;
|
---|
24 | using System.Collections.Generic;
|
---|
25 | using System.Linq;
|
---|
26 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Problems.VarProMRGP {
|
---|
29 | [TestClass]
|
---|
30 | public class ProblemTest {
|
---|
31 | private TestContext testContextInstance;
|
---|
32 | /// <summary>
|
---|
33 | ///Gets or sets the test context which provides
|
---|
34 | ///information about and functionality for the current test run.
|
---|
35 | ///</summary>
|
---|
36 | public TestContext TestContext {
|
---|
37 | get { return testContextInstance; }
|
---|
38 | set { testContextInstance = value; }
|
---|
39 | }
|
---|
40 |
|
---|
41 | [TestMethod]
|
---|
42 | [TestCategory("Problems.DataAnalysis")]
|
---|
43 | [TestProperty("Time", "long")]
|
---|
44 | public void TestOptimization() {
|
---|
45 | var ga = new Algorithms.GeneticAlgorithm.GeneticAlgorithm();
|
---|
46 | ga.PopulationSize.Value = 100;
|
---|
47 | ga.MaximumGenerations.Value = 100;
|
---|
48 | ga.MutationProbability.Value = 0.15;
|
---|
49 |
|
---|
50 | var prov = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider();
|
---|
51 | var poly10Desc = prov.GetDataDescriptors().Single(dd => dd.Name.Contains("Poly-10"));
|
---|
52 | var varProProblem = new VarProMRGP.Problem();
|
---|
53 | varProProblem.Load(prov.LoadData(poly10Desc));
|
---|
54 | varProProblem.MaxSize = 10;
|
---|
55 | varProProblem.MaxDepth = 6;
|
---|
56 | ga.SetSeedRandomly.Value = false;
|
---|
57 | ga.Seed.Value = 31415;
|
---|
58 | ga.Problem = varProProblem;
|
---|
59 | ga.ExceptionOccurred += (sender, e) => throw e.Value;
|
---|
60 | ga.Stopped += (sender, e) => Console.WriteLine("Stopped");
|
---|
61 |
|
---|
62 | ga.Prepare();
|
---|
63 | ga.Start();
|
---|
64 |
|
---|
65 | }
|
---|
66 | }
|
---|
67 | }
|
---|