,

Syntax

F = alldifferent(X)

Examples

The following example finds an integer vector with all numbers between 1 and 5.

x = intvar(5,1);
F = [alldifferent(x), 1<=x<=5];
solvesdp(F)
double(x)

Comments

Since alldifferent is implemented using a big-M approach, it is crucial that all involved variables have explicit bound constraints. Additionally, it only makes sense to apply the operator on integer valued variables.

Applying alldifferent on a variable with n variables will introduce n(n-1)/2 binary variables.