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.
Jip J. Dekker f2a1c4e389 Squashed 'software/mza/' content from commit f970a59b17
git-subtree-dir: software/mza
git-subtree-split: f970a59b177c13ca3dd8aaef8cc6681d83b7e813
2021-07-11 16:34:30 +10:00

43 lines
712 B
MiniZinc

% RUNS ON mzn20_fd
% RUNS ON mzn-fzn_fd
% RUNS ON mzn20_fd_linear
% RUNS ON mzn20_mip
% n-queens example in Zinc using CP techniques
% By Reza Rafeh July 2005
% MiniZinc version
% Peter Stuckey September 30 2006
int: n = 8;
array [1..n] of var 1..n: q;
constraint
alldifferent(q) % rows
/\
alldifferent(i in 1..n)(q[i] + i-1) % diagonals
/\
alldifferent(i in 1..n)(q[i] + n-i);
constraint q[1] = 2;
%constraint q[2] = 1;
include "alldifferent.mzn";
solve ::
int_search(
q,
first_fail,
indomain_min,
complete
)
satisfy;
output ["8 queens, CP version:\n"] ++
[ if fix(q[i]) = j then "Q " else ". " endif ++
if j = n then "\n" else "" endif
| i, j in 1..n
];