Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Tests/TestUtils.cs @ 9725

Last change on this file since 9725 was 6475, checked in by jhelm, 13 years ago

#1329: Added DirectSchedule-Classes for optimization with the direct-schedule encoding.

File size: 2.8 KB
Line 
1using HeuristicLab.Core;
2using HeuristicLab.Encodings.IntegerVectorEncoding;
3using HeuristicLab.Encodings.PermutationEncoding;
4using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
5using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;
6
7namespace HeuristicLab.Encodings.ScheduleEncoding.Tests {
8  public class TestUtils {
9    public static JSMEncoding CreateTestJSM1() {
10      JSMEncoding result = new JSMEncoding();
11      ItemList<Permutation> jsm = new ItemList<Permutation>();
12      for (int i = 0; i < 6; i++)
13        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 0, 1, 2, 3, 4, 5 }));
14      result.JobSequenceMatrix = jsm;
15      return result;
16    }
17
18    public static JSMEncoding CreateTestJSM2() {
19      JSMEncoding result = new JSMEncoding();
20      ItemList<Permutation> jsm = new ItemList<Permutation>();
21      for (int i = 0; i < 6; i++)
22        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 5, 4, 3, 2, 1, 0 }));
23      result.JobSequenceMatrix = jsm;
24      return result;
25    }
26
27
28    public static PWREncoding CreateTestPWR1() {
29      PWREncoding result = new PWREncoding();
30      IntegerVector pwr = new IntegerVector(new int[] { 1, 0, 1, 1, 2, 0, 2, 2, 0 });
31      result.PermutationWithRepetition = pwr;
32      return result;
33    }
34
35    public static PWREncoding CreateTestPWR2() {
36      PWREncoding result = new PWREncoding();
37      IntegerVector pwr = new IntegerVector(new int[] { 0, 1, 1, 0, 2, 0, 1, 2, 2 });
38      result.PermutationWithRepetition = pwr;
39      return result;
40    }
41
42
43    public static ItemList<Job> CreateJobData() {
44      Job j1 = new Job(0, 0);
45      j1.Tasks = new ItemList<Task> {
46        new Task (0, 0, j1.Index, 1),
47        new Task (1, 1, j1.Index, 2),
48        new Task (2, 2, j1.Index, 1)
49      };
50
51      Job j2 = new Job(1, 0);
52      j2.Tasks = new ItemList<Task> {
53        new Task (3, 2, j2.Index, 2),
54        new Task (4, 1, j2.Index, 1),
55        new Task (5, 0, j2.Index, 2)
56      };
57
58      Job j3 = new Job(2, 0);
59      j3.Tasks = new ItemList<Task> {
60        new Task (6, 0, j3.Index, 1),
61        new Task (7, 2, j3.Index, 2),
62        new Task (8, 1, j3.Index, 1)
63      };
64
65      return new ItemList<Job> { j1, j2, j3 };
66    }
67
68    public static Schedule CreateTestSchedule1() {
69      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());
70      return result;
71    }
72
73    public static Schedule CreateTestSchedule2() {
74      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());
75      return result;
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.