Example: Crossword puzzle More...
Public Types | |
enum | { BRANCH_WORDS, BRANCH_LETTERS, BRANCH_LETTERS_ALL } |
Branching to use for model. More... | |
Public Member Functions | |
Crossword (const SizeOptions &opt) | |
Actual model. | |
Crossword (bool share, Crossword &s) | |
Constructor for cloning s. | |
virtual Space * | copy (bool share) |
Copy during cloning. | |
virtual void | print (std::ostream &os) const |
Print solution. | |
Static Public Member Functions | |
static void | printletters (const Space &home, const BrancherHandle &bh, unsigned int a, IntVar, int i, const int &n, std::ostream &o) |
Print brancher information when branching on letters. | |
static void | printwords (const Space &, const BrancherHandle &bh, unsigned int a, IntVar, int i, const int &n, std::ostream &o) |
Print brancher information when branching on words. | |
Protected Attributes | |
const int | h |
Height of crossword grid. | |
IntVarArray | letters |
Letters for grid. | |
Static Protected Attributes | |
const int | w |
Width of crossword grid. |
Example: Crossword puzzle
Fill crossword grids with words, that is construct a crossword puzzle. For a recent paper on this classical problem, see: Crossword Puzzles as a Constraint Problem, Anbulagan and Adi Botea, CP 2008, pages 550-554, Springer Verlag.
Note that "Modeling and Programming with Gecode" uses this example as a case study.
Definition at line 70 of file crossword.cpp.
anonymous enum |
Branching to use for model.
BRANCH_WORDS |
Branch on the words. |
BRANCH_LETTERS |
Branch on the letters. |
BRANCH_LETTERS_ALL |
Branch on the letters (try all values) |
Definition at line 80 of file crossword.cpp.
Crossword::Crossword | ( | const SizeOptions & | opt | ) | [inline] |
Actual model.
Definition at line 86 of file crossword.cpp.
Crossword::Crossword | ( | bool | share, |
Crossword & | s | ||
) | [inline] |
Constructor for cloning s.
Definition at line 186 of file crossword.cpp.
static void Crossword::printletters | ( | const Space & | home, |
const BrancherHandle & | bh, | ||
unsigned int | a, | ||
IntVar | , | ||
int | i, | ||
const int & | n, | ||
std::ostream & | o | ||
) | [inline, static] |
Print brancher information when branching on letters.
Definition at line 166 of file crossword.cpp.
static void Crossword::printwords | ( | const Space & | , |
const BrancherHandle & | bh, | ||
unsigned int | a, | ||
IntVar | , | ||
int | i, | ||
const int & | n, | ||
std::ostream & | o | ||
) | [inline, static] |
Print brancher information when branching on words.
Definition at line 177 of file crossword.cpp.
virtual Space* Crossword::copy | ( | bool | share | ) | [inline, virtual] |
Copy during cloning.
Definition at line 192 of file crossword.cpp.
virtual void Crossword::print | ( | std::ostream & | os | ) | const [inline, virtual] |
Print solution.
Reimplemented from Gecode::Driver::ScriptBase< BaseSpace >.
Definition at line 197 of file crossword.cpp.
const int Crossword::w [static, protected] |
Width of crossword grid.
Definition at line 73 of file crossword.cpp.
const int Crossword::h [protected] |
Height of crossword grid.
Definition at line 75 of file crossword.cpp.
IntVarArray Crossword::letters [protected] |
Letters for grid.
Definition at line 77 of file crossword.cpp.