Debian Codegraph @

tests/spec/unit/globals/arg_max/globals_arg_max_opt.mzn

raw
1 /***
2 !Test
3 solvers: [gecode, chuffed]
4 options:
5 all_solutions: true
6 expected: !Result
7 solution: !SolutionSet
8 - !Solution
9 x: [3, null, 2, null, 1]
10 y: 1
11 - !Solution
12 x: [3, null, 1, null, 2]
13 y: 1
14 - !Solution
15 x: [2, null, 3, null, 1]
16 y: 3
17 - !Solution
18 x: [1, null, 3, null, 2]
19 y: 3
20 - !Solution
21 x: [1, null, 2, null, 3]
22 y: 5
23 - !Solution
24 x: [2, null, 1, null, 3]
25 y: 5
26 ***/
27
28 include "globals.mzn";
29
30 array [1..5] of var opt 1..3: x;
31 var 1..5: y;
32
33 constraint occurs(x[1]);
34 constraint forall (i in 1..4) (occurs(x[i]) = absent(x[i + 1]));
35 constraint y = arg_max(x);
36 constraint all_different(x);
37
38 solve satisfy;