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 consider the rows and columns together. The version uses alldifferent from lib(fd_global_gac), but the extra inferences performed between the rows and columns themselves not be fully domain consistent. 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.