62 int xy(
int x,
int y)
const {
76 for (
int i=0;
i<
n;
i++)
77 for (
int j=0; j<
n; j++)
91 for (
int i=0;
i<
n*
n;
i++)
104 dom(*
this,
q, (
n+1)/2, (
n+1)/2 + 1);
132 os <<
"\tNumber of Queens: " <<
q << std::endl;
133 os <<
"\tBoard: " <<
b << std::endl;
136 bool* placed =
new bool[
n*
n];
137 for (
int i=0;
i<
n*
n;
i++)
139 for (
int i=0;
i<
n*
n;
i++)
140 placed[
b[
i].val()] =
true;
141 for (
int j=0; j<
n; j++) {
143 for (
int i=0;
i<
n;
i++)
144 std::cout << (placed[
xy(
i,j)] ?
'Q' :
'.') <<
' ';
145 std::cout << std::endl;
162 IntMinimizeScript::run<DominatingQueens,BAB,SizeOptions>(
opt);
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Example: Dominating Queens
IntVar q
Number of queens.
virtual Space * copy(void)
Perform copying during cloning.
int main(int argc, char *argv[])
Main-function.
int y(int xy) const
Compute y coordinate from pair xy.
DominatingQueens(const SizeOptions &opt)
The actual problem.
IntVarArray b
Fields on the board.
const int n
Size of the board.
int x(int xy) const
Compute x coordinate from pair xy.
DominatingQueens(DominatingQueens &s)
Constructor for cloning s.
virtual void print(std::ostream &os) const
Print solution.
int xy(int x, int y) const
Compute coordinate pair from x and y.
virtual IntVar cost(void) const
Return cost.
IntSet attacked(int xy)
Compute set of fields that can be attacked by xy.
Parametric base-class for scripts.
Passing integer arguments.
Options for scripts with additional size parameter
bool assigned(void) const
Test if all variables are assigned.
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
void parse(int argc, char *argv[])
Parse commandline arguments.
@ IRT_LQ
Less or equal ( )
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Gecode toplevel namespace
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
IntValBranch INT_VAL_MAX(void)
Select largest value.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
void nvalues(Home home, const IntVarArgs &x, IntRelType irt, int y, IntPropLevel ipl=IPL_DEF)
Post propagator for .
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl=nullptr)
Select variable with smallest domain size.
Gecode::IntArgs i({1, 2, 3, 4})