Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/TestUtils.cs @ 9201

Last change on this file since 9201 was 8924, checked in by bburlacu, 12 years ago

#1890: Added License Information to files that didn't include it.

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