this repo has no description
1% latin_squares.mzn
2include "globals.mzn";
3
4int: n = 3;
5set of int: N = 1..n;
6array[N, N] of var N: X;
7
8constraint :: "ADRows"
9 forall (i in N)
10 (alldifferent(row(X, i)) :: "AD(row \(i))");
11constraint :: "ADCols"
12 forall (j in N)
13 (alldifferent(col(X, j)) :: "AD(col \(j))");
14
15constraint :: "LLRows"
16 forall (i in 1..n-1)
17 (lex_less(row(X, i), row(X, i+1)) :: "LL(rows \(i) \(i+1))");
18constraint :: "LGCols"
19 forall (j in 1..n-1)
20 (lex_greater(col(X, j), col(X, j+1)) :: "LG(cols \(j) \(j+1)");
21
22solve satisfy;
23
24output [ show2d(X) ];