QueenArmies Class Reference
Example scripts (models)

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 (QueenArmies &s)
| Constructor for cloning.
virtual Space * | copy (void)
| Return copy during cloning.
virtual IntVar | cost (void) const
| Return solution cost.
virtual void | print (std::ostream &os) const
| Print solution.
Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< IntMaximizeSpace > >
| ScriptBase (const Options &opt)
| Constructor.
| ScriptBase (ScriptBase &e)
| Constructor used for cloning.
virtual void | compare (const Space &home, std::ostream &os) const
| Compare with s.
Public Member Functions inherited from Gecode::Driver::IgnoreStepOption< BaseSpace >
| IgnoreStepOption (const Options &)
| Constructor.
| IgnoreStepOption (BaseSpace &e)
| Constructor used for cloning.

## 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.

## Additional Inherited Members

Static Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< IntMaximizeSpace > >
static std::ostream & | select_ostream (const char *sn, std::ofstream &ofs)
| Choose output stream according to sn.
static void | run (const Options &opt, Script *s=NULL)

## Detailed Description

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 67 of file queen-armies.cpp.

## Member Enumeration Documentation

## anonymous enum

anonymous enum

Branching to use for model.

Enumerator
BRANCH_NAIVE | Choose variables left to right.
BRANCH_SPECIFIC | Choose variable with problem specific strategy.

Definition at line 77 of file queen-armies.cpp.

## Constructor & Destructor Documentation

## QueenArmies() [1/2]

QueenArmies::QueenArmies | ( | const SizeOptions & | opt | ) |

inline

Constructor.

Definition at line 83 of file queen-armies.cpp.

## QueenArmies() [2/2]

QueenArmies::QueenArmies | ( | QueenArmies & | s | ) |

inline

Constructor for cloning.

Definition at line 120 of file queen-armies.cpp.

## Member Function Documentation

## copy()

virtual Space * QueenArmies::copy | ( | void |  | ) |

inline virtual

Return copy during cloning.

Definition at line 130 of file queen-armies.cpp.

## cost()

virtual IntVar QueenArmies::cost | ( | void |  | ) | const

inline virtual

Return solution cost.

Definition at line 134 of file queen-armies.cpp.

## print()

virtual void QueenArmies::print | ( | std::ostream & | os | ) | const

inline virtual

Print solution.

Reimplemented from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< IntMaximizeSpace > >.

Definition at line 139 of file queen-armies.cpp.

## Friends And Related Symbol Documentation

## A

IntSet* A

related

Position of a piece in a square board.

Definition at line 46 of file queen-armies.cpp.

## pos()

int pos | ( | int | i,
|  | int | j,
|  | int | n )

related

Position of a piece in a square board.

Definition at line 266 of file queen-armies.cpp.

## main()

int main | ( | int | argc,
|  | char * | argv[] )

related

Main-function.

Definition at line 274 of file queen-armies.cpp.

## Member Data Documentation

## n

const int QueenArmies::n

Definition at line 69 of file queen-armies.cpp.

## U

SetVar QueenArmies::U

Set of un-attacked squares.

Definition at line 70 of file queen-armies.cpp.

## W

SetVar QueenArmies::W

Set of squares occupied by white queens.

Definition at line 71 of file queen-armies.cpp.

## w

BoolVarArray QueenArmies::w

The placement of the white queens.

Definition at line 72 of file queen-armies.cpp.

## b

BoolVarArray QueenArmies::b

The placement of the black queens.

Definition at line 73 of file queen-armies.cpp.

## q

IntVar QueenArmies::q

The number of white queens placed.

Definition at line 74 of file queen-armies.cpp.

The documentation for this class was generated from the following file:

- examples/queen-armies.cpp