Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include "globals.mzn";
- int: num_tasks = 20;
- int: num_resources = 3;
- set of int: TASKS = 1..num_tasks;
- set of int: RESOURCES = 1..num_resources;
- array[TASKS] of int: duration =
- [6, 5, 4, 3, 3, 6, 5, 2, 8, 2, 8, 2, 3, 7, 3, 8, 7, 5, 6, 2];
- array[TASKS, RESOURCES] of int: demand = [|
- 1, 1, 2 | 1, 2, 1 | 2, 0, 2 | 2, 0, 2 | 2, 1, 2 |
- 1, 0, 1 | 1, 0, 1 | 0, 2, 2 | 1, 2, 0 | 2, 0, 2 |
- 1, 2, 2 | 2, 0, 0 | 1, 0, 2 | 2, 0, 2 | 1, 1, 0 |
- 0, 1, 1 | 0, 0, 1 | 1, 0, 2 | 1, 0, 2 | 0, 0, 2 |];
- array[RESOURCES] of int: capacity = [4, 4, 4];
- array[TASKS] of var 0..100: start;
- array[TASKS] of var int: end = [start[t] + duration[t] | t in TASKS];
- constraint
- forall(r in RESOURCES) (
- let { array[TASKS] of int: demand_r = [demand[t,r] | t in TASKS] } in
- cumulative(start, duration, demand_r, capacity[r])
- );
- constraint start[5] >= max([end[t] | t in 1..4]);
- constraint start[10] >= max([end[t] | t in 6..9]);
- constraint start[15] >= max([end[t] | t in 11..14]);
- constraint start[20] >= max([end[t] | t in 16..19]);
- var int: makespan = max([end[t] | t in TASKS]);
- solve minimize makespan;
- output [
- "Начало: ", show(start), "\n",
- "Конец ", show(end), "\n",
- "Итог: ", show(makespan)
- ];
Advertisement
Add Comment
Please, Sign In to add comment