13 lines
370 B
MiniZinc
13 lines
370 B
MiniZinc
include "all_different.mzn";
|
|
|
|
int: n; % size
|
|
array[1..n,1..n] of 0..n: s; % 0 = unfixed 1..n = fixed
|
|
array[1..n,1..n] of var 1..n: q; % qcp array;
|
|
|
|
constraint forall(i,j in 1..n where s[i,j] > 0)(
|
|
q[i,j] = s[i,j]
|
|
);
|
|
|
|
solve maximize sum(i in 1..n)(all_different([q[i,j] | j in 1..n]))
|
|
+ sum(j in 1..n)(all_different([q[i,j] | i in 1..n]));
|