Debian Codegraph @

tests/spec/unit/general/test_to_enum.mzn

raw
1 /***
2 !Test
3 solvers: [gecode]
4 expected: !Result
5 solution: !Solution
6 par_int: b
7 var_int: c
8 array_of_int: [a, b, c]
9 array_of_var_int: [a, b, c]
10 array_of_set_of_int: [!!set {a}, !!set {a, b}, !!set {a, b, c}]
11 array_of_var_set_of_int: [!!set {a}, !!set {a, b}, !!set {a, b, c}]
12 set_of_int: !!set {a, b, c}
13 var_set_of_int: !!set {a, b, c}
14 ***/
15
16 enum X = {a, b, c};
17
18 var 1..3: i;
19 array [1..3] of var 1..3: j;
20 var set of 1..3: k;
21 array [1..3] of var set of 1..3: l;
22
23 constraint j[1] < j[2] /\ j[2] < j[3];
24 constraint card(k) = 3;
25 constraint forall (x in 1..3) (card(l[x]) = x);
26 constraint 1 in l[1] /\ not (3 in l[2]);
27
28 X: par_int :: add_to_output = to_enum(X, 2);
29 var X: var_int :: add_to_output = to_enum(X, i);
30 array [1..3] of X: array_of_int :: add_to_output = to_enum(X, [1, 2, 3]);
31 array [1..3] of var X: array_of_var_int :: add_to_output = to_enum(X, j);
32 set of X: set_of_int :: add_to_output = to_enum(X, {1, 2, 3});
33 var set of X: var_set_of_int :: add_to_output = to_enum(X, k);
34 array [1..3] of set of X: array_of_set_of_int :: add_to_output = to_enum(X, [{1}, {1, 2}, {1, 2, 3}]);
35 array [1..3] of var set of X: array_of_var_set_of_int :: add_to_output = to_enum(X, l);
36
37 solve maximize i;