Debian Codegraph @

tests/spec/unit/optional/test-opt-if-then-else.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: 1
10 y: null
11 p: false
12 a: 1
13 b: null
14 c: null
15 - !Solution
16 x: null
17 y: 1
18 p: false
19 a: 1
20 b: 1
21 c: null
22 - !Solution
23 x: null
24 y: 1
25 p: true
26 a: null
27 b: null
28 c: null
29 - !Solution
30 x: 1
31 y: null
32 p: true
33 a: null
34 b: 1
35 c: null
36 status: ALL_SOLUTIONS
37 ***/
38
39 % Test various if-then-else cases with opt
40
41 var opt 1..1: x :: add_to_output;
42 var opt 1..1: y :: add_to_output;
43
44 var bool: p :: add_to_output;
45
46 var opt int: a :: add_to_output = if p then <> else 1 endif;
47 var opt int: b :: add_to_output = if p then x else y endif;
48
49 bool: q = true;
50 opt int: c :: add_to_output = if q then <> else 1 endif;
51
52 constraint not (x = y);