Example: Peaceable co-existing armies of queens More...
Classes | |
class | QueenBranch |
Custom brancher for Peacable queens. More... | |
Public Types | |
enum | { BRANCH_NAIVE, BRANCH_SPECIFIC } |
Branching to use for model. More... | |
Public Member Functions | |
QueenArmies (const SizeOptions &opt) | |
Constructor. | |
QueenArmies (bool share, QueenArmies &s) | |
Constructor for cloning. | |
virtual Space * | copy (bool share) |
Return copy during cloning. | |
virtual IntVar | cost (void) const |
Return solution cost. | |
virtual void | print (std::ostream &os) const |
Print solution. | |
Public Attributes | |
const int | n |
SetVar | U |
Set of un-attacked squares. | |
SetVar | W |
Set of squares occupied by white queens. | |
BoolVarArray | w |
The placement of the white queens. | |
BoolVarArray | b |
The placement of the black queens. | |
IntVar | q |
The number of white queens placed. | |
Constant sets for attacking queens. | |
IntSet * | A |
Position of a piece in a square board. | |
int | pos (int i, int j, int n) |
Position of a piece in a square board. | |
int | main (int argc, char *argv[]) |
Main-function. |
Example: Peaceable co-existing armies of queens
The goal of this problem is to place as many white and black queens on a chess-board without any two queens of different color attacking each other. The number of black queens should be greater than or equal to the number of white queens.
This model is based on the one presented in "Models and Symmetry Breaking for 'Peaceable Armies of Queens'", by Barbara M. Smith, Karen E. Petrie, and Ian P. Gent.
The smart version uses a custom brancher implementing a heuristic from the above paper, that helps speeding up the proof of optimality.
Definition at line 71 of file queen-armies.cpp.
anonymous enum |
Branching to use for model.
BRANCH_NAIVE |
Choose variables left to right. |
BRANCH_SPECIFIC |
Choose variable with problem specific strategy. |
Definition at line 81 of file queen-armies.cpp.
QueenArmies::QueenArmies | ( | const SizeOptions & | opt | ) | [inline] |
Constructor.
Definition at line 87 of file queen-armies.cpp.
QueenArmies::QueenArmies | ( | bool | share, |
QueenArmies & | s | ||
) | [inline] |
Constructor for cloning.
Definition at line 123 of file queen-armies.cpp.
virtual Space* QueenArmies::copy | ( | bool | share | ) | [inline, virtual] |
Return copy during cloning.
Definition at line 133 of file queen-armies.cpp.
virtual IntVar QueenArmies::cost | ( | void | ) | const [inline, virtual] |
Return solution cost.
Definition at line 137 of file queen-armies.cpp.
virtual void QueenArmies::print | ( | std::ostream & | os | ) | const [inline, virtual] |
Print solution.
Reimplemented from Gecode::Driver::ScriptBase< BaseSpace >.
Definition at line 142 of file queen-armies.cpp.
Position of a piece in a square board.
Definition at line 50 of file queen-armies.cpp.
int pos | ( | int | i, |
int | j, | ||
int | n | ||
) | [related] |
Position of a piece in a square board.
Definition at line 273 of file queen-armies.cpp.
int main | ( | int | argc, |
char * | argv[] | ||
) | [related] |
Main-function.
Definition at line 281 of file queen-armies.cpp.
const int QueenArmies::n |
Definition at line 73 of file queen-armies.cpp.
Set of un-attacked squares.
Definition at line 74 of file queen-armies.cpp.
Set of squares occupied by white queens.
Definition at line 74 of file queen-armies.cpp.
The placement of the white queens.
Definition at line 76 of file queen-armies.cpp.
The placement of the black queens.
Definition at line 76 of file queen-armies.cpp.
The number of white queens placed.
Definition at line 78 of file queen-armies.cpp.