Generated on Sat Feb 7 2015 02:01:38 for Gecode by doxygen 1.8.9.1
ColoredMatrix Class Reference

Example: Colored matrix example. More...

Public Types

enum  { SEARCH_DFS, SEARCH_BAB }
 Search modes. More...
 
enum  { SYMMETRY_NONE = 0, SYMMETRY_MATRIX = 1, SYMMETRY_VALUES = 2 }
 SYmmetry breaking variants. More...
 
enum  { MODEL_CORNERS = 1, MODEL_ROWS = 2, MODEL_COLUMNS = 4 }
 Model variants. More...
 
enum  {
  NOT_ALL_EQUAL_NQ, NOT_ALL_EQUAL_NAIVE, NOT_ALL_EQUAL_REIFIED, NOT_ALL_EQUAL_NVALUES,
  NOT_ALL_EQUAL_COUNT, NOT_ALL_EQUAL_DFA
}
 Not all equal variants. More...
 
enum  { SAME_OR_0_REIFIED, SAME_OR_0_DFA, SAME_OR_0_TUPLE_SET }
 Same or 0 variants. More...
 
enum  { DISTINCT_EXCEPT_0_REIFIED, DISTINCT_EXCEPT_0_DFA, DISTINCT_EXCEPT_0_COUNT }
 Distinct except 0 variants. More...
 
enum  { NO_MONOCHROME_DECOMPOSITION, NO_MONOCHROME_DFA }
 No monochrome rectangle versions. More...
 

Public Member Functions

 ColoredMatrix (const ColoredMatrixOptions &opt0)
 Actual model. More...
 
virtual IntVar cost (void) const
 Return cost. More...
 
virtual void print (std::ostream &os) const
 Print solution. More...
 
 ColoredMatrix (bool share, ColoredMatrix &s)
 Constructor for cloning s. More...
 
virtual Spacecopy (bool share)
 Copy during cloning. More...
 
- Public Member Functions inherited from Gecode::Driver::ScriptBase< BaseSpace >
 ScriptBase (void)
 Default constructor. More...
 
 ScriptBase (bool share, ScriptBase &e)
 Constructor used for cloning. More...
 
virtual void compare (const Space &, std::ostream &os) const
 Compare with s. More...
 

Protected Member Functions

IntVar same_or_0 (const IntVar &a, const IntVar &b)
 
void distinct_except_0 (const IntVarArgs &v)
 
void not_all_equal (const IntVarArgs &v)
 
void no_monochrome_rectangle (IntVarArgs v1, IntVarArgs v2)
 

Related Functions

(Note that these are not member functions.)

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

Constraint description constructors.

These functions implement constructors for descriptions of constraints as extensional specifications.

DFA same_or_0_dfa (unsigned int colors)
 
TupleSet same_or_0_tuple_set (unsigned int colors)
 
DFA distinct_except_0_dfa (unsigned int colors)
 
DFA no_monochrome_rectangle_dfa (unsigned int colors)
 
IntSetArgs distinct_except_0_counts (unsigned int colors, unsigned int size)
 
DFA not_all_equal_dfa (unsigned int colors)
 

Instance specification

const ColoredMatrixOptionsopt
 Options for model. More...
 
const unsigned int height
 Height of matrix. More...
 
const unsigned int width
 Width of matrix. More...
 
const unsigned int colors
 Number of colors to use. More...
 

Problem variables

IntVarArray x
 Array for matrix variables. More...
 
IntVar max_color
 Maximum color used. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Gecode::Driver::ScriptBase< BaseSpace >
static std::ostream & select_ostream (const char *name, std::ofstream &ofs)
 Choose output stream according to name. More...
 
template<class Script , template< class > class Engine, class Options >
static void run (const Options &opt, Script *s=NULL)
 

Detailed Description

Example: Colored matrix example.

An n by m matrix is to be filled with k colors. It is a valid colored matrix iff the corners of each rectangle do not have the same color.

An example 5 by 4 matrix with three colors:

1 1 1 1 1
1 2 2 3 3
1 2 3 2 3
1 2 3 3 2

Definition at line 168 of file colored-matrix.cpp.

Constructor & Destructor Documentation

ColoredMatrix::ColoredMatrix ( const ColoredMatrixOptions opt0)
inline

Actual model.

Definition at line 363 of file colored-matrix.cpp.

ColoredMatrix::ColoredMatrix ( bool  share,
ColoredMatrix s 
)
inline

Constructor for cloning s.

Definition at line 447 of file colored-matrix.cpp.

Member Function Documentation

IntVar ColoredMatrix::same_or_0 ( const IntVar a,
const IntVar b 
)
inlineprotected

Return variable that is zero if a and b differ, or equal to their value if they agree.

Definition at line 190 of file colored-matrix.cpp.

void ColoredMatrix::distinct_except_0 ( const IntVarArgs v)
inlineprotected

Post constraint that all values in v different from 0 are distinct.

Definition at line 221 of file colored-matrix.cpp.

void ColoredMatrix::not_all_equal ( const IntVarArgs v)
inlineprotected

Post constraint that not all variables in v are equal.

Definition at line 247 of file colored-matrix.cpp.

void ColoredMatrix::no_monochrome_rectangle ( IntVarArgs  v1,
IntVarArgs  v2 
)
inlineprotected

Post constraint using same_or_0 and distinct_except_0 that enforces rows/columns v1 and v2 to have no monochrome rectangle.

Definition at line 291 of file colored-matrix.cpp.

virtual IntVar ColoredMatrix::cost ( void  ) const
inlinevirtual

Return cost.

Definition at line 426 of file colored-matrix.cpp.

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

Print solution.

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

Definition at line 432 of file colored-matrix.cpp.

virtual Space* ColoredMatrix::copy ( bool  share)
inlinevirtual

Copy during cloning.

Definition at line 455 of file colored-matrix.cpp.

Friends And Related Function Documentation

DFA same_or_0_dfa ( unsigned int  colors)
related

Return DFA for the same_or_0 constraint.

Constraint models the expression $(x = y \land z = y) \lor (x \neq y \land z = 0)$ for variables $\langle x, y, zq\rangle$.

TupleSet same_or_0_tuple_set ( unsigned int  colors)
related

Return tuple set for the same_or_0 constraint.

Constraint models the expression $(x = y \land z = y) \lor (x \neq y \land z = 0)$ for variables $\langle x, y, zq\rangle$.

DFA distinct_except_0_dfa ( unsigned int  colors)
related

Return DFA for the distinct_except_0 constraint.

DFA no_monochrome_rectangle_dfa ( unsigned int  colors)
related

Return DFA for the no monochrome rectangle constraint.

IntSetArgs distinct_except_0_counts ( unsigned int  colors,
unsigned int  size 
)
related

Return counts for using a global cardninality constraint for the distinct exept 0 constraint.

DFA not_all_equal_dfa ( unsigned int  colors)
related

Return DFA for the not all equals constraint.

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

Main-function.

Definition at line 538 of file colored-matrix.cpp.

Member Data Documentation

const ColoredMatrixOptions& ColoredMatrix::opt
protected

Options for model.

Definition at line 173 of file colored-matrix.cpp.

const unsigned int ColoredMatrix::height
protected

Height of matrix.

Definition at line 174 of file colored-matrix.cpp.

const unsigned int ColoredMatrix::width
protected

Width of matrix.

Definition at line 175 of file colored-matrix.cpp.

const unsigned int ColoredMatrix::colors
protected

Number of colors to use.

Definition at line 176 of file colored-matrix.cpp.

IntVarArray ColoredMatrix::x
protected

Array for matrix variables.

Definition at line 183 of file colored-matrix.cpp.

IntVar ColoredMatrix::max_color
protected

Maximum color used.

Definition at line 185 of file colored-matrix.cpp.


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