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

Example: Magic sequence More...

Public Types

enum  { PROP_COUNT , PROP_GCC }
 Propagation to use for model. More...
 

Public Member Functions

 MagicSequence (const SizeOptions &opt)
 The actual model.
 
 MagicSequence (MagicSequence &e)
 Constructor for cloning e.
 
virtual Spacecopy (void)
 Copy during cloning.
 
virtual void print (std::ostream &os) const
 Print sequence.
 
- 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.
 

Related Symbols

(Note that these are not member symbols.)

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

Additional Inherited Members

- 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)
 

Detailed Description

Example: Magic sequence

Find a magic sequence of length $n$. A magic sequence of length $n$ is a sequence

\[x_0,x_1, \ldots, x_{n-1}\]

of integers such that for every $i=0,\ldots,n-1$:

  • $x_i$ is an integer between $0$ and $n-1$.
  • the number $i$ occurs exactly $x_i$ times in the sequence.

See problem 19 at http://www.csplib.org/.

Note that "Modeling and Programming with Gecode" uses this example as a case study.

Definition at line 59 of file magic-sequence.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Propagation to use for model.

Enumerator
PROP_COUNT 

Use count constraints.

PROP_GCC 

Use single global cardinality constraint.

Definition at line 67 of file magic-sequence.cpp.

Constructor & Destructor Documentation

◆ MagicSequence() [1/2]

MagicSequence::MagicSequence ( const SizeOptions & opt)
inline

The actual model.

Definition at line 72 of file magic-sequence.cpp.

◆ MagicSequence() [2/2]

MagicSequence::MagicSequence ( MagicSequence & e)
inline

Constructor for cloning e.

Definition at line 89 of file magic-sequence.cpp.

Member Function Documentation

◆ copy()

virtual Space * MagicSequence::copy ( void )
inlinevirtual

Copy during cloning.

Definition at line 94 of file magic-sequence.cpp.

◆ print()

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

Print sequence.

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

Definition at line 99 of file magic-sequence.cpp.

Friends And Related Symbol Documentation

◆ main()

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

Main-function.

Definition at line 115 of file magic-sequence.cpp.


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