1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.

24 lines
624 B
Plaintext

% QCP max problem.
include "globals.mzn";
var 0..2*n : obj;
int: n; % size
array[1..n*n] of 0..n: s; % 0 = unfixed 1..n = fixed
array[1..n,1..n] of 0..n: s2 = array2d(1..n, 1..n, s);
array[1..n,1..n] of var 1..n: q; % qcp array;
constraint forall(i,j in 1..n where s2[i,j] > 0)(q[i,j] = s2[i,j]);
constraint obj <= sum(i in 1..n)(bool2int(alldifferent([q[j,i] | j in 1..n])) +
bool2int(alldifferent([q[i,j] | j in 1..n])));
solve ::int_search([obj] ++ [q[i, j] | i in 1..n, j in 1..n], input_order,
indomain_max, complete ) maximize obj;
output [
"obj = " ++ show(obj) ++ "\n",
"q = " ++ show(q) ++ "\n",
];