this repo has no description
at develop 1.5 kB view raw
1% RUNS ON mzn20_fd 2% RUNS ON mzn-fzn_fd 3% RUNS ON mzn20_fd_linear 4% RUNS ON mzn20_mip 5%-----------------------------------------------------------------------------% 6% Example from the MiniZinc paper: 7% (square) job shop scheduling in MiniZinc 8%-----------------------------------------------------------------------------% 9 10%-----------------------------------------------------------------------------% 11% Instance 12 13size = 2; 14d = [| 2,5 15 | 3,4 |]; 16 17%-----------------------------------------------------------------------------% 18% Model 19 20int: size; % size of problem 21array [1..size,1..size] of int: d; % task durations 22int: Total = sum(i,j in 1..size) (d[i,j]); % total duration 23array [1..size,1..size] of var 0..Total: s; % start times 24var 0..Total: end; % total end time 25 26predicate no_overlap(var int:s1, int:d1, var int:s2, int:d2) = 27 s1 + d1 <= s2 \/ s2 + d2 <= s1; 28 29constraint 30 forall(i in 1..size) ( 31 forall(j in 1..size-1) (s[i,j] + d[i,j] <= s[i,j+1]) /\ 32 s[i,size] + d[i,size] <= end /\ 33 forall(j,k in 1..size where j < k) ( 34 no_overlap(s[j,i], d[j,i], s[k,i], d[k,i]) 35 ) 36 ); 37 38solve minimize end; 39 40output [ 41 "jobshop2x2\n", 42 "s[1..2, 1..2] = [", show(s[1, 1]), " ", show(s[1, 2]), "\n", 43 " ", show(s[2, 1]), " ", show(s[2, 2]), "]\n" 44]; 45 46%-----------------------------------------------------------------------------%