Debian Codegraph @

tests/spec/unit/general/test_let_complex.mzn

raw
1 /***
2 !Test
3 expected: !Result
4 status: SATISFIED
5 solution: !Solution
6 x: [1, 3, 5, 7, 9]
7 y: [1, 3, 5, 8, 9]
8 ***/
9
10 array[1..5] of var int: x :: add_to_output = [1,3,5,7,9];
11 array[4..8] of var int: y :: add_to_output = array1d(4..8, [1,3,5,8,9]);
12
13 constraint
14 let { int: lx = min(index_set(x)),
15 int: ux = max(index_set(x)),
16 int: ly = min(index_set(y)),
17 int: uy = max(index_set(y)),
18 int: size = max(ux - lx, uy - ly),
19 array[0..size+1] of var bool: b }
20 in
21 b[size+1] = (ux - lx < uy - ly) /\
22 forall (i in 0..size) (
23 b[i] = ((x[lx+i] < y[ly+i])
24 \/ ((x[lx+i] == y[ly+i]) /\ b[i+1]))
25 ) /\ b[0];
26 solve satisfy;
27 output [
28 "x = ", show(x), ";\n",
29 "y = ", show(y), ";\n"
30 ];