[11450] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[17181] | 3 | * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[11450] | 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.IO;
|
---|
| 23 | using System.Linq;
|
---|
[17105] | 24 | using HEAL.Attic;
|
---|
[11450] | 25 | using HeuristicLab.Algorithms.RAPGA;
|
---|
| 26 | using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
|
---|
| 27 | using HeuristicLab.Problems.Scheduling;
|
---|
| 28 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 29 |
|
---|
| 30 | namespace HeuristicLab.Tests {
|
---|
| 31 | [TestClass]
|
---|
| 32 | public class RAPGASchedulingSampleTest {
|
---|
[11907] | 33 | private const string SampleFileName = "RAPGA_JSSP";
|
---|
[17105] | 34 | private static readonly ProtoBufSerializer serializer = new ProtoBufSerializer();
|
---|
[11450] | 35 |
|
---|
| 36 | [TestMethod]
|
---|
| 37 | [TestCategory("Samples.Create")]
|
---|
| 38 | [TestProperty("Time", "medium")]
|
---|
| 39 | public void CreateRAPGASchedulingSampleTest() {
|
---|
| 40 | var ss = CreateRAPGASchedulingSample();
|
---|
[11907] | 41 | string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
|
---|
[17105] | 42 | serializer.Serialize(ss, path);
|
---|
[11450] | 43 | }
|
---|
| 44 |
|
---|
| 45 | [TestMethod]
|
---|
| 46 | [TestCategory("Samples.Execute")]
|
---|
| 47 | [TestProperty("Time", "long")]
|
---|
| 48 | public void RunRAPGASchedulingSampleTest() {
|
---|
| 49 | var rapga = CreateRAPGASchedulingSample();
|
---|
| 50 | rapga.SetSeedRandomly.Value = false;
|
---|
| 51 | SamplesUtils.RunAlgorithm(rapga);
|
---|
| 52 | Assert.AreEqual(988.00, SamplesUtils.GetDoubleResult(rapga, "BestQuality"));
|
---|
| 53 | Assert.AreEqual(988.00, SamplesUtils.GetDoubleResult(rapga, "CurrentAverageQuality"));
|
---|
| 54 | Assert.AreEqual(988.00, SamplesUtils.GetDoubleResult(rapga, "CurrentWorstQuality"));
|
---|
| 55 | Assert.AreEqual(27100, SamplesUtils.GetIntResult(rapga, "EvaluatedSolutions"));
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | private RAPGA CreateRAPGASchedulingSample() {
|
---|
| 59 | #region Problem Configuration
|
---|
| 60 | JobShopSchedulingProblem problem = new JobShopSchedulingProblem();
|
---|
| 61 | #endregion
|
---|
| 62 |
|
---|
| 63 | #region Algorithm Configuration
|
---|
| 64 | RAPGA rapga = new RAPGA();
|
---|
| 65 | rapga.Engine = new SequentialEngine.SequentialEngine();
|
---|
| 66 | rapga.Name = "RAPGA - Job Shop Scheduling";
|
---|
| 67 | rapga.Description = "A relevant alleles preserving genetic algorithm which solves a job shop scheduling problem";
|
---|
| 68 | rapga.Problem = problem;
|
---|
| 69 | rapga.Mutator = rapga.MutatorParameter.ValidValues.OfType<JSMSwapManipulator>().First();
|
---|
| 70 | rapga.Seed.Value = 0;
|
---|
| 71 | return rapga;
|
---|
| 72 | #endregion
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
| 75 | }
|
---|