This constraint is a matrix version of alldifferent. Matrix is a two dimensional square (NxN) matrix, and the constraint ensures that the elements in each row and column of the matrix are different. The same value can occur in different rows and columns. It is logically equivalent to imposing 2N alldifferent constraints, on each row and column, but it allows more reasoning because it considers the rows and columns together. The alldifferent constraint used is the lib(fd_global) version. The maximum propagation occurs when the variables' domains also have N values
This is currently a prototype -- the constraint has not been tested very extensively and little effort has been spent to optimise performance. We welcome any feedback on using this constraint.
This constraint is described in J.-C. Regin and C. Gomes, 'The Cardinality Matrix Constraint', CP 2004.