Generated on Tue May 22 09:40:48 2018 for Gecode by doxygen 1.6.3

MagicSequence Class Reference
[Example scripts (models)]

Example: Magic sequence More...

List of all members.

Public Types


Propagation to use for model.


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.

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

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

Propagation to use for model.


Use count constraints.


Use single global cardinality constraint.

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

Constructor & Destructor Documentation

MagicSequence::MagicSequence ( const SizeOptions opt  )  [inline]

The actual model.

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

MagicSequence::MagicSequence ( MagicSequence e  )  [inline]

Constructor for cloning e.

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

Member Function Documentation

virtual Space* MagicSequence::copy ( void   )  [inline, virtual]

Copy during cloning.

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

virtual void MagicSequence::print ( std::ostream &  os  )  const [inline, virtual]

Print sequence.

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

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

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