Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPRobocodeSampleTest.cs @ 14509

Last change on this file since 14509 was 13266, checked in by gkronber, 9 years ago

#2069: added a unit test to create a robocode sample.

File size: 2.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.IO;
23using System.Linq;
24using HeuristicLab.Algorithms.GeneticAlgorithm;
25using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
26using HeuristicLab.Persistence.Default.Xml;
27using HeuristicLab.Problems.GeneticProgramming.Robocode;
28using HeuristicLab.Selection;
29using Microsoft.VisualStudio.TestTools.UnitTesting;
30
31namespace HeuristicLab.Tests {
32  [TestClass]
33  public class GPRobocodeSampleTest {
34    private const string SampleFileName = "SGP_Robocode";
35
36    [TestMethod]
37    [TestCategory("Samples.Create")]
38    [TestProperty("Time", "medium")]
39    public void CreateGpRobocodeSampleTest() {
40      var ga = CreateGpRobocodeSample();
41      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
42      XmlGenerator.Serialize(ga, path);
43    }
44
45    // there is no unit test for running the sample because a JDK installation would be necessary (and this is not the case on our build server)
46
47    public GeneticAlgorithm CreateGpRobocodeSample() {
48      GeneticAlgorithm ga = new GeneticAlgorithm();
49
50      #region Problem Configuration
51      Problem antProblem = new Problem();
52      #endregion
53      #region Algorithm Configuration
54      ga.Name = "Genetic Programming - Robocode Java Source";
55      ga.Description = "A standard genetic programming algorithm to evolve the java source code for a robocode bot (see http://robocode.sourceforge.net/). An installation of Java SE Developmen Kit (JDK) >= 1.6 is necessary to run this sample.";
56      ga.Problem = antProblem;
57      SamplesUtils.ConfigureGeneticAlgorithmParameters<TournamentSelector, SubtreeCrossover, MultiSymbolicExpressionTreeArchitectureManipulator>(
58        ga, 50, 1, 50, 0.15, 2);
59
60      ga.Engine = new SequentialEngine.SequentialEngine();
61      #endregion
62
63      return ga;
64    }
65  }
66}
Note: See TracBrowser for help on using the repository browser.