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