The Constraint Programming Solver (Experimental)

ALLDIFF Predicate

The ALLDIFF predicate defines an all-different constraint, which defines a unique global constraint on a set of variables that requires all of them to be different from each other. A global constraint is equivalent to a conjunction of elementary constraints.

The syntax of the all-different constraint consists of one part, a variable-list, which is defined in the section Common Syntax Components. For example, the statements

var X{1..3} integer, A integer, B integer;
con AD1: alldiff({j in 1..3} X[j]);
con AD2: alldiff(A B);

are equivalent to

\[  \begin{array}{rcl} X[1] &  \ne &  X[2] \mr{~ ~ AND}\\ X[2] &  \ne &  X[3] \mr{~ ~ AND}\\ X[1] &  \ne &  X[3] \mr{~ ~ AND}\\ A &  \ne &  B \end{array}  \]

To apply the all-different constraint to all the variables, use the problem symbol _VAR_ as follows:

con alldiff(_VAR_);

For a description of problem symbols, see the section Problem Symbols in ChapterĀ 5: The OPTMODEL Procedure.