this repo has no description
1include "disjunctive.mzn";
2
3int: jobs; % no of jobs
4set of int: JOB = 1..jobs;
5int: tasks; % no of tasks per job
6set of int: TASK = 1..tasks;
7array [JOB,TASK] of int: d; % task durations
8int: total = sum(i in JOB, j in TASK)(d[i,j]);% total duration
9int: digs = ceil(log(10.0,total)); % digits for output
10array [JOB,TASK] of var 0..total: s; % start times
11var 0..total: end; % total end time
12
13constraint %% ensure the tasks occur in sequence
14 forall(i in JOB) (
15 forall(j in 1..tasks-1)
16 (s[i,j] + d[i,j] <= s[i,j+1]) /\
17 s[i,tasks] + d[i,tasks] <= end
18 );
19
20constraint %% ensure no overlap of tasks
21 forall(j in TASK) (
22 disjunctive([s[i,j] | i in JOB], [d[i,j] | i in JOB])
23 );
24
25solve minimize end;
26
27output ["end = \(end)\n"] ++
28 [ show_int(digs,s[i,j]) ++ " " ++
29 if j == tasks then "\n" else "" endif |
30 i in JOB, j in TASK ];