44 using namespace Gecode;
102 for (
int i = n*n;
i--; ) {
104 rel(*
this, w[
i] == (U || A[
i]));
106 rel(*
this, !w[i] || !
b[i]);
117 rel(*
this, q <= unknowns);
131 U.update(*
this, share, s.
U);
132 W.update(*
this, share, s.
W);
133 w.update(*
this, share, s.
w);
135 q.update(*
this, share, s.
q);
150 for (
int i = 0;
i < n*n; ++
i) {
155 if ((
i+1)%n == 0) os << std::endl << (
i!=(n*n-1)?
"\t":
"");
157 os <<
"Number of white queens: " << q << std::endl << std::endl;
181 Choice(
const Brancher&
b,
int pos0,
bool val0)
184 virtual size_t size(
void)
const {
185 return sizeof(Choice);
188 virtual void archive(
Archive& e)
const {
199 :
Brancher(home, share, b), start(b.start) {}
205 for (
int i = start;
i < q.
n*q.
n; ++
i)
219 for (
int i = start;
i < q.
n*q.
n; ++
i) {
225 if (size > maxsize) {
232 return new Choice(*
this, pos,
true);
238 return new Choice(*
this, pos, val);
246 const Choice&
c =
static_cast<const Choice&
>(
_c);
247 bool val = (a == 0) ? c.val : !c.val;
262 return sizeof(*this);
289 opt.
parse(argc,argv);
295 int *p =
new int[
std::max(n*n, 25)];
297 for (
int i = n;
i--; ) {
298 for (
int j = n; j--; ) {
309 p[pn++] =
pos(
i, j, n);
310 for (
int k = 8; k--; ) {
311 for (
int l = 0; l < n
312 && 0 <= (
i+l*dir[k][0]) && (
i+l*dir[k][0]) < n
313 && 0 <= (j+l*dir[k][1]) && (j+l*dir[k][1]) < n; ++l) {
314 p[pn++] =
pos(
i+l*dir[k][0], j+l*dir[k][1], n);
328 MaximizeScript::run<QueenArmies,BAB,SizeOptions>(
opt);
break;
330 MaximizeScript::run<QueenArmies,Restart,SizeOptions>(
opt);
break;