| 1 |
/*** |
| 2 |
!Test |
| 3 |
solvers: |
| 4 |
- gecode |
| 5 |
- chuffed |
| 6 |
expected: |
| 7 |
- !Result |
| 8 |
status: SATISFIED |
| 9 |
solution: !Solution |
| 10 |
q: [9, 13, 2, 8, 11, 20, 10, 6, 19, 15, 18, 12, 7, 16, 4, 17, 14, 5, 3, 1] |
| 11 |
- !Result |
| 12 |
status: SATISFIED |
| 13 |
solution: !Solution |
| 14 |
q: [9, 7, 10, 14, 11, 15, 4, 12, 5, 13, 1, 3, 6, 8, 2, 17, 19, 16, 18, 20] |
| 15 |
***/ |
| 16 |
|
| 17 |
% Copied from the queens.mzn benchmark. |
| 18 |
% |
| 19 |
% In some very rare cases some literals in MiniSAT are labeled during |
| 20 |
% backjumping but never actually propagated |
| 21 |
% (if invoke is never entered again), |
| 22 |
% which leads to the output of flatzinc showing unfixed int variables. |
| 23 |
% |
| 24 |
% |
| 25 |
|
| 26 |
int: n = 20; % The number of queens. |
| 27 |
|
| 28 |
array [1..n] of var 1..n: q; |
| 29 |
|
| 30 |
predicate |
| 31 |
noattack(int: i, int: j, var int: qi, var int: qj) = |
| 32 |
qi != qj /\ |
| 33 |
qi + i != qj + j /\ |
| 34 |
qi - i != qj - j; |
| 35 |
|
| 36 |
constraint |
| 37 |
forall (i in 1..n, j in i+1..n) ( |
| 38 |
noattack(i, j, q[i], q[j]) |
| 39 |
); |
| 40 |
|
| 41 |
solve satisfy; |
| 42 |
|
| 43 |
output ["% ", show(n), "-queens:\n"] ++ |
| 44 |
["% "] ++ [show(q[i]) ++ " " | i in 1..n] ++ |
| 45 |
["\n%\n"] ++ |
| 46 |
["q = ", show(q), ";\n"]; |