this repo has no description
1/** @group globals.alldifferent
2 Constrain the array of integers \a vs to be all different except those
3 elements that are assigned the value 0.
4*/
5predicate fzn_alldifferent_except_0(array[int] of var int: vs) =
6% forall(i, j in index_set(vs) where i < j) (
7% (vs[i] != 0 /\ vs[j] != 0) -> vs[i] != vs[j]
8% );
9 if length(vs)<=1 then true
10 else
11 let {
12 array[int,int] of var 0..1: x_eq_d = eq_encode(vs)
13 } in (
14% my_trace(" alldifferent_except_0: x[" ++ show(index_set(vs)) ++ "]\n") /\
15 forall(d in index_set_2of2(x_eq_d) diff {0})( sum(i in index_set_1of2(x_eq_d))( x_eq_d[i,d] ) <= 1 )
16 )
17 endif;