Debian Codegraph @

tests/spec/unit/globals/cumulatives/globals_cumulatives.mzn

raw
1 /***
2 --- !Test
3 solvers: [gecode]
4 expected: !Result
5 solution: !Solution
6 makespan: 11
7 --- !Test
8 solvers: [gecode, chuffed]
9 options:
10 -G: std
11 expected: !Result
12 solution: !Solution
13 makespan: 11
14 ***/
15
16 include "cumulatives.mzn";
17
18 set of int: TIME = 1..20;
19 enum TASK = T(1..5);
20 enum MACHINE = M(1..2);
21
22 array [TASK, MACHINE] of TIME: d =
23 [| M(1): M(2):
24 | T(1): 5, 7,
25 | T(2): 3, 3,
26 | T(3): 4, 3,
27 | T(4): 9, 7,
28 | T(5): 3, 5,
29 |];
30
31 array [TASK, MACHINE] of TIME: r =
32 [| M(1): M(2):
33 | T(1): 2, 7,
34 | T(2): 6, 4,
35 | T(3): 4, 2,
36 | T(4): 5, 6,
37 | T(5): 2, 1,
38 |];
39
40 array [MACHINE] of int: bound = [M(1): 6, M(2): 6];
41
42 array [TASK] of var TIME: start;
43 array [TASK] of var TIME: duration :: output = [t: d[t, machine[t]] | t in TASK];
44 array [TASK] of var int: resource :: output = [t: r[t, machine[t]] | t in TASK];
45 array [TASK] of var MACHINE: machine;
46
47 array [MACHINE, TIME] of int: used :: output_only :: output = [
48 (m, t): sum (
49 i in TASK where
50 fix(start[i]) <= t /\
51 fix(start[i]) + fix(duration[i]) > t /\
52 fix(machine[i]) = m
53 ) (
54 fix(resource[i])
55 )
56 |
57 m in MACHINE,
58 t in TIME
59 ];
60
61 constraint cumulatives(
62 start,
63 duration,
64 resource,
65 machine,
66 bound,
67 true
68 );
69
70 var int: makespan :: output = max (t in TASK) (start[t] + duration[t]);
71 solve minimize makespan;
72