44 using namespace Gecode;
96 for (
int i =
n*
n;
i--; ) {
98 rel(*
this, w[
i] == (U || A[
i]));
100 rel(*
this, !w[i] || !
b[i]);
111 rel(*
this, q <= unknowns);
125 U.update(*
this, share, s.
U);
126 W.update(*
this, share, s.
W);
127 w.update(*
this, share, s.
w);
128 b.update(*
this, share, s.
b);
129 q.update(*
this, share, s.
q);
144 for (
int i = 0;
i <
n*
n; ++
i) {
149 if ((
i+1)%n == 0) os << std::endl << (
i!=(n*n-1)?
"\t":
"");
151 os <<
"Number of white queens: " << q << std::endl << std::endl;
175 Choice(
const Brancher&
b,
int pos0,
bool val0)
178 virtual size_t size(
void)
const {
179 return sizeof(Choice);
182 virtual void archive(
Archive& e)
const {
193 :
Brancher(home, share, b), start(b.start) {}
199 for (
int i = start;
i < q.
n*q.
n; ++
i)
213 for (
int i = start;
i < q.
n*q.
n; ++
i) {
219 if (size > maxsize) {
226 return new Choice(*
this, pos,
true);
232 return new Choice(*
this, pos, val);
240 const Choice&
c =
static_cast<const Choice&
>(
_c);
241 bool val = (a == 0) ? c.val : !c.val;
249 std::ostream& o)
const {
250 const Choice&
c =
static_cast<const Choice&
>(
_c);
251 bool val = (a == 0) ? c.val : !c.val;
252 o <<
"w[" << c.pos <<
"] = " << val;
264 return sizeof(*this);
288 opt.
parse(argc,argv);
296 for (
int i = n;
i--; ) {
297 for (
int j = n; j--; ) {
308 p[pn++] =
pos(
i, j, n);
309 for (
int k = 8; k--; ) {
310 for (
int l = 0;
l < n
311 && 0 <= (
i+
l*dir[k][0]) && (
i+
l*dir[k][0]) < n
312 && 0 <= (j+
l*dir[k][1]) && (j+
l*dir[k][1]) <
n; ++
l) {
313 p[pn++] =
pos(
i+
l*dir[k][0], j+
l*dir[k][1], n);
324 IntMaximizeScript::run<QueenArmies,BAB,SizeOptions>(
opt);