| 1 |
/*** |
| 2 |
!Test |
| 3 |
check_against: [] |
| 4 |
expected: |
| 5 |
- !Result |
| 6 |
solution: !Solution |
| 7 |
makespan: 1168 |
| 8 |
objective: 1168 |
| 9 |
start: |
| 10 |
- - 507 |
| 11 |
- 0 |
| 12 |
- 6 |
| 13 |
- - 0 |
| 14 |
- 168 |
| 15 |
- 663 |
| 16 |
- - 168 |
| 17 |
- 663 |
| 18 |
- 339 |
| 19 |
- !Result |
| 20 |
solution: !Solution |
| 21 |
makespan: 1168 |
| 22 |
objective: 1168 |
| 23 |
start: |
| 24 |
- - 333 |
| 25 |
- 1162 |
| 26 |
- 0 |
| 27 |
- - 1000 |
| 28 |
- 0 |
| 29 |
- 657 |
| 30 |
- - 0 |
| 31 |
- 657 |
| 32 |
- 333 |
| 33 |
- !Result |
| 34 |
solution: !Solution |
| 35 |
makespan: 1168 |
| 36 |
objective: 1168 |
| 37 |
start: |
| 38 |
- - 339 |
| 39 |
- 0 |
| 40 |
- 6 |
| 41 |
- - 0 |
| 42 |
- 168 |
| 43 |
- 663 |
| 44 |
- - 168 |
| 45 |
- 663 |
| 46 |
- 339 |
| 47 |
- !Result |
| 48 |
solution: !Solution |
| 49 |
makespan: 1168 |
| 50 |
objective: 1168 |
| 51 |
start: |
| 52 |
- - 0 |
| 53 |
- 1162 |
| 54 |
- 829 |
| 55 |
- - 1000 |
| 56 |
- 505 |
| 57 |
- 0 |
| 58 |
- - 829 |
| 59 |
- 0 |
| 60 |
- 505 |
| 61 |
- !Result |
| 62 |
solution: !Solution |
| 63 |
makespan: 1168 |
| 64 |
objective: 1168 |
| 65 |
start: |
| 66 |
- - 339 |
| 67 |
- 1162 |
| 68 |
- 0 |
| 69 |
- - 1000 |
| 70 |
- 168 |
| 71 |
- 657 |
| 72 |
- - 161 |
| 73 |
- 657 |
| 74 |
- 333 |
| 75 |
- !Result |
| 76 |
solution: !Solution |
| 77 |
makespan: 1168 |
| 78 |
objective: 1168 |
| 79 |
start: |
| 80 |
- - 503 |
| 81 |
- 0 |
| 82 |
- 6 |
| 83 |
- - 0 |
| 84 |
- 169 |
| 85 |
- 820 |
| 86 |
- - 168 |
| 87 |
- 663 |
| 88 |
- 339 |
| 89 |
- !Result |
| 90 |
solution: !Solution |
| 91 |
makespan: 1168 |
| 92 |
objective: 1168 |
| 93 |
start: |
| 94 |
- - 507 |
| 95 |
- 0 |
| 96 |
- 6 |
| 97 |
- - 0 |
| 98 |
- 174 |
| 99 |
- 825 |
| 100 |
- - 168 |
| 101 |
- 663 |
| 102 |
- 339 |
| 103 |
extra_files: [] |
| 104 |
markers: [] |
| 105 |
options: |
| 106 |
all_solutions: false |
| 107 |
solvers: |
| 108 |
- gecode |
| 109 |
- cbc |
| 110 |
- chuffed |
| 111 |
type: solve |
| 112 |
|
| 113 |
***/ |
| 114 |
|
| 115 |
int: Endtime; |
| 116 |
int: NMachines; |
| 117 |
int: NJobs; |
| 118 |
|
| 119 |
set of int: Machines = 1..NMachines; |
| 120 |
set of int: Jobs = 1..NJobs; |
| 121 |
|
| 122 |
array[Machines,Jobs] of int: duration; |
| 123 |
|
| 124 |
array[Machines,Jobs] of var 0..Endtime: start; |
| 125 |
var 0..Endtime: makespan; |
| 126 |
|
| 127 |
predicate not_at_same_time(Machines: m1, Jobs: j1, Machines: m2, Jobs: j2) = |
| 128 |
start[m1,j1] + duration[m1,j1] <= start[m2,j2] |
| 129 |
\/ start[m2,j2] + duration[m2,j2] <= start[m1,j1]; |
| 130 |
|
| 131 |
|
| 132 |
constraint |
| 133 |
forall(m in Machines)( |
| 134 |
forall(j1,j2 in Jobs where j1 < j2)( |
| 135 |
not_at_same_time(m,j1,m,j2) |
| 136 |
) |
| 137 |
); |
| 138 |
|
| 139 |
constraint |
| 140 |
forall(j in Jobs)( |
| 141 |
forall(m1,m2 in Machines where m1 < m2)( |
| 142 |
not_at_same_time(m1,j,m2,j) |
| 143 |
) |
| 144 |
); |
| 145 |
|
| 146 |
constraint |
| 147 |
forall(m in Machines)( |
| 148 |
forall(j in Jobs)( |
| 149 |
start[m,j] + duration[m,j] <= makespan |
| 150 |
) |
| 151 |
); |
| 152 |
|
| 153 |
solve minimize makespan; |
| 154 |
|
| 155 |
output [ "oss:\nmakespan = ", show(makespan), "\nstart = ", show(start), "\n" ]; |
| 156 |
|
| 157 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 158 |
|
| 159 |
Endtime = 1509; |
| 160 |
NMachines = 3; |
| 161 |
NJobs = 3; |
| 162 |
|
| 163 |
duration = [|661,6,333|168,489,343|171,505,324|]; |