1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
Jip J. Dekker f2a1c4e389 Squashed 'software/mza/' content from commit f970a59b17
git-subtree-dir: software/mza
git-subtree-split: f970a59b177c13ca3dd8aaef8cc6681d83b7e813
2021-07-11 16:34:30 +10:00

47 lines
1.4 KiB
MiniZinc

% RUNS ON mzn20_fd
% RUNS ON mzn-fzn_fd
% RUNS ON mzn20_fd_linear
% RUNS ON mzn20_mip
%-----------------------------------------------------------------------------%
% Example from the MiniZinc paper:
% (square) job shop scheduling in MiniZinc
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
% Instance
size = 2;
d = [| 2,5
| 3,4 |];
%-----------------------------------------------------------------------------%
% Model
int: size; % size of problem
array [1..size,1..size] of int: d; % task durations
int: Total = sum(i,j in 1..size) (d[i,j]); % total duration
array [1..size,1..size] of var 0..Total: s; % start times
var 0..Total: end; % total end time
predicate no_overlap(var int:s1, int:d1, var int:s2, int:d2) =
s1 + d1 <= s2 \/ s2 + d2 <= s1;
constraint
forall(i in 1..size) (
forall(j in 1..size-1) (s[i,j] + d[i,j] <= s[i,j+1]) /\
s[i,size] + d[i,size] <= end /\
forall(j,k in 1..size where j < k) (
no_overlap(s[j,i], d[j,i], s[k,i], d[k,i])
)
);
solve minimize end;
output [
"jobshop2x2\n",
"s[1..2, 1..2] = [", show(s[1, 1]), " ", show(s[1, 2]), "\n",
" ", show(s[2, 1]), " ", show(s[2, 2]), "]\n"
];
%-----------------------------------------------------------------------------%