this repo has no description
at develop 1.7 kB view raw
1/*** 2!Test 3expected: 4- !Result 5 solution: !Solution 6 end: 11 7 objective: 11 8 s: 9 - [0, 2] 10 - [2, 7] 11- !Result 12 solution: !Solution 13 end: 11 14 objective: 11 15 s: 16 - [0, 2] 17 - [3, 7] 18- !Result 19 solution: !Solution 20 end: 11 21 objective: 11 22 s: 23 - [0, 2] 24 - [4, 7] 25***/ 26 27%-----------------------------------------------------------------------------% 28% Example from the MiniZinc paper: 29% (square) job shop scheduling in MiniZinc 30%-----------------------------------------------------------------------------% 31 32%-----------------------------------------------------------------------------% 33% Instance 34 35size = 2; 36d = [| 2,5 37 | 3,4 |]; 38 39%-----------------------------------------------------------------------------% 40% Model 41 42int: size; % size of problem 43array [1..size,1..size] of int: d; % task durations 44int: Total = sum(i,j in 1..size) (d[i,j]); % total duration 45array [1..size,1..size] of var 0..Total: s; % start times 46var 0..Total: end; % total end time 47 48predicate no_overlap(var int:s1, int:d1, var int:s2, int:d2) = 49 s1 + d1 <= s2 \/ s2 + d2 <= s1; 50 51constraint 52 forall(i in 1..size) ( 53 forall(j in 1..size-1) (s[i,j] + d[i,j] <= s[i,j+1]) /\ 54 s[i,size] + d[i,size] <= end /\ 55 forall(j,k in 1..size where j < k) ( 56 no_overlap(s[j,i], d[j,i], s[k,i], d[k,i]) 57 ) 58 ); 59 60solve minimize end; 61 62output [ 63 "jobshop2x2\n", 64 "s[1..2, 1..2] = [", show(s[1, 1]), " ", show(s[1, 2]), "\n", 65 " ", show(s[2, 1]), " ", show(s[2, 2]), "]\n" 66]; 67 68%-----------------------------------------------------------------------------%