forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptimalJobSchedulingTest.java
More file actions
128 lines (94 loc) · 2.92 KB
/
OptimalJobSchedulingTest.java
File metadata and controls
128 lines (94 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.thealgorithms.dynamicprogramming;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author georgioct@csd.auth.gr
*/
public class OptimalJobSchedulingTest {
@Test
public void testOptimalJobScheduling1(){
int numberProcesses = 5;
int numberMachines = 4;
int[][] Run = {
{5, 1, 3, 2},
{4, 2, 1, 3},
{1, 5, 2, 1},
{2, 3, 4, 2},
{1, 1, 3, 1}};
int[][] Transfer = {
{0, 1, 2, 4},
{1, 0, 2, 3},
{2, 2, 0, 1},
{4, 3, 1, 0}};
OptimalJobScheduling opt = new OptimalJobScheduling(numberProcesses,numberMachines,Run,Transfer);
opt.execute();
int[][] costs = {
{5, 1, 3, 2},
{6, 3, 4, 5},
{5, 8, 6, 6},
{7, 9, 10, 8},
{8, 9, 12, 9}};
for (int i=0; i < numberProcesses; i++){
for (int j=0; j < numberMachines; j++){
assertEquals(costs[i][j],opt.getCost(i,j));
}
}
}
@Test
public void testOptimalJobScheduling2(){
int numberProcesses = 3;
int numberMachines = 3;
int[][] Run = {
{5, 1, 3},
{4, 2, 1},
{1, 5, 2}};
int[][] Transfer = {
{0, 1, 2},
{1, 0, 2},
{2, 2, 0}};
OptimalJobScheduling opt = new OptimalJobScheduling(numberProcesses,numberMachines,Run,Transfer);
opt.execute();
int[][] costs = {
{5, 1, 3},
{6, 3, 4},
{5, 8, 6}};
for (int i=0; i < numberProcesses; i++){
for (int j=0; j < numberMachines; j++){
assertEquals(costs[i][j],opt.getCost(i,j));
}
}
}
@Test
public void testOptimalJobScheduling3(){
int numberProcesses = 6;
int numberMachines = 4;
int[][] Run = {
{5, 1, 3, 2},
{4, 2, 1, 1},
{1, 5, 2, 6},
{1, 1, 2, 3},
{2, 1, 4, 6},
{3, 2, 2, 3},
};
int[][] Transfer = {
{0, 1, 2, 1},
{1, 0, 2, 3},
{2, 2, 0, 2},
{1, 3, 2, 0},
};
OptimalJobScheduling opt = new OptimalJobScheduling(numberProcesses,numberMachines,Run,Transfer);
opt.execute();
int[][] costs = {
{5, 1, 3, 2},
{6, 3, 4, 3},
{5, 8, 6, 9},
{6, 7, 8, 9},
{8, 8, 12, 13},
{11, 10, 12, 12}};
for (int i=0; i < numberProcesses; i++){
for (int j=0; j < numberMachines; j++){
assertEquals(costs[i][j],opt.getCost(i,j));
}
}
}
}