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.

31 lines
1.0 KiB
MiniZinc

include "disjunctive.mzn";
int: jobs; % no of jobs
set of int: JOB = 1..jobs;
int: tasks; % no of tasks per job
set of int: TASK = 1..tasks;
array [JOB,TASK] of int: d; % task durations
int: total = sum(i in JOB, j in TASK)(d[i,j]);% total duration
int: digs = ceil(log(10.0,total)); % digits for output
array [JOB,TASK] of var 0..total: s; % start times
var 0..total: end; % total end time
constraint %% ensure the tasks occur in sequence
forall(i in JOB) (
forall(j in 1..tasks-1)
(s[i,j] + d[i,j] <= s[i,j+1]) /\
s[i,tasks] + d[i,tasks] <= end
);
constraint %% ensure no overlap of tasks
forall(j in TASK) (
disjunctive([s[i,j] | i in JOB], [d[i,j] | i in JOB])
);
solve minimize end;
output ["end = \(end)\n"] ++
[ show_int(digs,s[i,j]) ++ " " ++
if j == tasks then "\n" else "" endif |
i in JOB, j in TASK ];