Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0

Example: Crossword puzzle More...

Public Types

enum  { MODEL_ELEMENT , MODEL_TUPLESET }
 Which model to use. More...
 
enum  {
  BRANCH_WORDS_AFC , BRANCH_LETTERS_AFC , BRANCH_LETTERS_AFC_ALL , BRANCH_WORDS_ACTION ,
  BRANCH_LETTERS_ACTION , BRANCH_LETTERS_ACTION_ALL , BRANCH_WORDS_CHB , BRANCH_LETTERS_CHB ,
  BRANCH_LETTERS_CHB_ALL
}
 Branching to use for model. More...
 

Public Member Functions

 Crossword (const SizeOptions &opt)
 Actual model.
 
bool master (const MetaInfo &mi)
 Do not perform a restart when a solution is found.
 
 Crossword (Crossword &s)
 Constructor for cloning s.
 
virtual Spacecopy (void)
 Copy during cloning.
 
virtual void print (std::ostream &os) const
 Print solution.
 
- Public Member Functions inherited from Gecode::Driver::ScriptBase< BaseSpace >
 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.
 

Static Public Member Functions

static void printletters (const Space &home, const Brancher &, unsigned int a, IntVar, int i, const int &n, std::ostream &os)
 Print brancher information when branching on letters.
 
static void printwords (const Space &, const Brancher &, unsigned int a, IntVar, int i, const int &n, std::ostream &os)
 Print brancher information when branching on words.
 
- Static Public Member Functions inherited from Gecode::Driver::ScriptBase< BaseSpace >
static std::ostream & select_ostream (const char *sn, std::ofstream &ofs)
 Choose output stream according to sn.
 
template<class Script , template< class > class Engine, class Options >
static void run (const Options &opt, Script *s=NULL)
 

Protected Attributes

const int w
 Width of crossword grid.
 
const int h
 Height of crossword grid.
 
IntVarArray letters
 Letters for grid.
 

Related Symbols

(Note that these are not member symbols.)

int main (int argc, char *argv[])
 Main-function.
 

Detailed Description

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 66 of file crossword.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Which model to use.

Enumerator
MODEL_ELEMENT 

Use element constraints per letter.

MODEL_TUPLESET 

Use one tuple-set per word.

Definition at line 76 of file crossword.cpp.

◆ anonymous enum

anonymous enum

Branching to use for model.

Enumerator
BRANCH_WORDS_AFC 

Branch on the words.

BRANCH_LETTERS_AFC 

Branch on the letters.

BRANCH_LETTERS_AFC_ALL 

Branch on the letters (try all values)

BRANCH_WORDS_ACTION 

Branch on the words.

BRANCH_LETTERS_ACTION 

Branch on the letters.

BRANCH_LETTERS_ACTION_ALL 

Branch on the letters (try all values)

BRANCH_WORDS_CHB 

Branch on the words.

BRANCH_LETTERS_CHB 

Branch on the letters.

BRANCH_LETTERS_CHB_ALL 

Branch on the letters (try all values)

Definition at line 81 of file crossword.cpp.

Constructor & Destructor Documentation

◆ Crossword() [1/2]

Crossword::Crossword ( const SizeOptions & opt)
inline

Actual model.

Definition at line 93 of file crossword.cpp.

◆ Crossword() [2/2]

Crossword::Crossword ( Crossword & s)
inline

Constructor for cloning s.

Definition at line 294 of file crossword.cpp.

Member Function Documentation

◆ printletters()

static void Crossword::printletters ( const Space & home,
const Brancher & ,
unsigned int a,
IntVar ,
int i,
const int & n,
std::ostream & os )
inlinestatic

Print brancher information when branching on letters.

Definition at line 265 of file crossword.cpp.

◆ printwords()

static void Crossword::printwords ( const Space & ,
const Brancher & ,
unsigned int a,
IntVar ,
int i,
const int & n,
std::ostream & os )
inlinestatic

Print brancher information when branching on words.

Definition at line 276 of file crossword.cpp.

◆ master()

bool Crossword::master ( const MetaInfo & mi)
inline

Do not perform a restart when a solution is found.

Definition at line 285 of file crossword.cpp.

◆ copy()

virtual Space * Crossword::copy ( void )
inlinevirtual

Copy during cloning.

Definition at line 300 of file crossword.cpp.

◆ print()

virtual void Crossword::print ( std::ostream & os) const
inlinevirtual

Print solution.

Reimplemented from Gecode::Driver::ScriptBase< BaseSpace >.

Definition at line 305 of file crossword.cpp.

Friends And Related Symbol Documentation

◆ main()

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

Main-function.

Definition at line 329 of file crossword.cpp.

Member Data Documentation

◆ w

const int Crossword::w
protected

Width of crossword grid.

Definition at line 69 of file crossword.cpp.

◆ h

const int Crossword::h
protected

Height of crossword grid.

Definition at line 71 of file crossword.cpp.

◆ letters

IntVarArray Crossword::letters
protected

Letters for grid.

Definition at line 73 of file crossword.cpp.


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