1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
on-restart-benchmarks/share/minizinc/std/fzn_alldifferent_except.mzn
Jip J. Dekker fad1b07018 Squashed 'software/minizinc/' content from commit 4f10c8205
git-subtree-dir: software/minizinc
git-subtree-split: 4f10c82056ffcb1041d7ffef29d77a7eef92cf76
2021-06-16 14:06:46 +10:00

12 lines
548 B
MiniZinc

include "global_cardinality_low_up.mzn";
predicate fzn_alldifferent_except(array[int] of var int: vs, set of int: S) =
%% if the variables in vs are bounded then use the gcc decomposition
if forall(i in index_set(vs))(has_bounds(vs[i])) then
let { set of int: A = dom_array(vs) diff S; } in
global_cardinality_low_up(vs, A, [0 | i in A], [1 | i in A])
else
%% otherwise use the neq decomposition
forall(i, j in index_set(vs) where i < j)
((vs[i] in S /\ vs[j] in S) \/ vs[i] != vs[j])
endif;