Debian Codegraph @

tests/spec/unit/regression/github_674.mzn

raw
1 /***
2 !Test
3 solvers: [gecode, chuffed, highs]
4 expected: !Result
5 solution: !Solution
6 arr: [true, false]
7 ns: [false, false, false, false, false, false, false, false, false, true, false]
8 es: [false, false, false, false, false, false, false, false, false, false, false]
9 ***/
10 include "fzn_dtree_enum.mzn";
11
12 array[1..11] of int: from = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10];
13 array[1..11] of int: to = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0];
14
15 array[1..2] of var bool: arr;
16 array[0..10] of var bool: ns;
17 array[1..11] of var bool: es;
18
19 constraint not ns[0];
20 constraint count([ns[1]]) = 0;
21 constraint ns[1] <-> not arr[1];
22 constraint ns[9] <-> not arr[2];
23 constraint es[3] <-> ns[1] /\ ns[9];
24
25 tuple(int, array[int] of var bool, array[int] of var bool): t = (0, ns, es);
26
27 constraint fzn_tree2(from, to, 9, t.2, t.3);
28
29 predicate fzn_tree2(array[int] of int: from, array[int] of int: to,
30 var int: r, array[int] of var bool: ns, array[int] of var bool: es) =
31 let {
32 int: E = length(es);
33 array[1..2*E] of int: dfrom = from ++ to;
34 array[1..2*E] of int: dto = to ++ from;
35 array[1..2*E] of var bool: des;
36 var bool: x;
37 } in
38 /* ensure that the directed edges selected agree with undirected edges */
39 % forall(e in 1..E)(es[e-1+min(index_set(es))] <-> (des[e] \/ des[e+E])) /\
40 (x = forall(e in 1..E)(es[e-1+min(index_set(es))] <-> (des[e] \/ des[e+E]))) /\ x /\
41 /* duplicate the edges so that the we can use directed graph reachability */
42 fzn_dtree(dfrom,dto,r,ns,des);
43
44 solve satisfy;