Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/TestUtils.cs @ 10074

Last change on this file since 10074 was 9885, checked in by mkommend, 11 years ago

#2088: Merged all changesets regarding the unit test restructuring in the stable branch.

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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 HeuristicLab.Core;
23using HeuristicLab.Encodings.IntegerVectorEncoding;
24using HeuristicLab.Encodings.PermutationEncoding;
25using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
26using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;
27using HeuristicLab.Tests;
28
29namespace HeuristicLab.Encodings.ScheduleEncoding.Tests {
30  public class TestUtils {
31    public static JSMEncoding CreateTestJSM1() {
32      JSMEncoding result = new JSMEncoding();
33      ItemList<Permutation> jsm = new ItemList<Permutation>();
34      for (int i = 0; i < 6; i++)
35        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 0, 1, 2, 3, 4, 5 }));
36      result.JobSequenceMatrix = jsm;
37      return result;
38    }
39
40    public static JSMEncoding CreateTestJSM2() {
41      JSMEncoding result = new JSMEncoding();
42      ItemList<Permutation> jsm = new ItemList<Permutation>();
43      for (int i = 0; i < 6; i++)
44        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 5, 4, 3, 2, 1, 0 }));
45      result.JobSequenceMatrix = jsm;
46      return result;
47    }
48
49
50    public static PWREncoding CreateTestPWR1() {
51      PWREncoding result = new PWREncoding();
52      IntegerVector pwr = new IntegerVector(new int[] { 1, 0, 1, 1, 2, 0, 2, 2, 0 });
53      result.PermutationWithRepetition = pwr;
54      return result;
55    }
56
57    public static PWREncoding CreateTestPWR2() {
58      PWREncoding result = new PWREncoding();
59      IntegerVector pwr = new IntegerVector(new int[] { 0, 1, 1, 0, 2, 0, 1, 2, 2 });
60      result.PermutationWithRepetition = pwr;
61      return result;
62    }
63
64
65    public static ItemList<Job> CreateJobData() {
66      Job j1 = new Job(0, 0);
67      j1.Tasks = new ItemList<Task> {
68        new Task (0, 0, j1.Index, 1),
69        new Task (1, 1, j1.Index, 2),
70        new Task (2, 2, j1.Index, 1)
71      };
72
73      Job j2 = new Job(1, 0);
74      j2.Tasks = new ItemList<Task> {
75        new Task (3, 2, j2.Index, 2),
76        new Task (4, 1, j2.Index, 1),
77        new Task (5, 0, j2.Index, 2)
78      };
79
80      Job j3 = new Job(2, 0);
81      j3.Tasks = new ItemList<Task> {
82        new Task (6, 0, j3.Index, 1),
83        new Task (7, 2, j3.Index, 2),
84        new Task (8, 1, j3.Index, 1)
85      };
86
87      return new ItemList<Job> { j1, j2, j3 };
88    }
89
90    public static Schedule CreateTestSchedule1() {
91      Schedule result = DirectScheduleRandomCreator.Apply(3, 3, new PWREncoding(3, 3, new TestRandom(new int[] { 1, 0, 1, 1, 2, 0, 2, 2, 0 }, null)), CreateJobData());
92      return result;
93    }
94
95    public static Schedule CreateTestSchedule2() {
96      Schedule result = DirectScheduleRandomCreator.Apply(3, 3, new PWREncoding(3, 3, new TestRandom(new int[] { 0, 1, 1, 0, 2, 0, 1, 2, 2 }, null)), CreateJobData());
97      return result;
98    }
99  }
100}
Note: See TracBrowser for help on using the repository browser.