Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0

Example: Colored matrix example. More...

(Note that these are not member symbols.)

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

Problem variables

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...
IntVarArray x
 Array for matrix variables.
IntVar max_color
 Maximum color used.
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)
 ColoredMatrix (const ColoredMatrixOptions &opt0)
 Actual model.
virtual IntVar cost (void) const
 Return cost.
virtual void print (std::ostream &os) const
 Print solution.
 ColoredMatrix (ColoredMatrix &s)
 Constructor for cloning s.
virtual Spacecopy (void)
 Copy during cloning.

Instance specification

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

Constraint description constructors.

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

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

Additional Inherited Members

Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< IntMinimizeSpace > >
 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.
Public Member Functions inherited from Gecode::Driver::IgnoreStepOption< BaseSpace >
 IgnoreStepOption (const Options &)
 Constructor.
 IgnoreStepOption (BaseSpace &e)
 Constructor used for cloning.
Static Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< IntMinimizeSpace > >
static std::ostream & select_ostream (const char *sn, std::ofstream &ofs)
 Choose output stream according to sn.
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 164 of file colored-matrix.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Search modes.

Enumerator
SEARCH_DFS 

Find solution.

SEARCH_BAB 

Find optimal solution.

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

◆ anonymous enum

anonymous enum

SYmmetry breaking variants.

Enumerator
SYMMETRY_NONE 

No symmetry breaking.

SYMMETRY_MATRIX 

Order rows and columns of matrix.

SYMMETRY_VALUES 

Order value occurences.

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

◆ anonymous enum

anonymous enum

Model variants.

Enumerator
MODEL_CORNERS 

Use model on corner combinations.

MODEL_ROWS 

Use model on pairs of rows.

MODEL_COLUMNS 

Use model on pairs of columns.

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

◆ anonymous enum

anonymous enum

Not all equal variants.

Enumerator
NOT_ALL_EQUAL_NQ 

Use direct constraint for implemeting not all equals.

NOT_ALL_EQUAL_NAIVE 

Use naive reification for implemeting not all equals.

NOT_ALL_EQUAL_REIFIED 

Use reification for implemeting not all equals.

NOT_ALL_EQUAL_NVALUES 

Use nvalues for implementing not all equals.

NOT_ALL_EQUAL_COUNT 

Use count for implementing not all equals.

NOT_ALL_EQUAL_DFA 

Use dfa for implementing not all equals.

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

◆ anonymous enum

anonymous enum

Same or 0 variants.

Enumerator
SAME_OR_0_REIFIED 

Use reification for same or 0.

SAME_OR_0_DFA 

Use dfa for same or 0.

SAME_OR_0_TUPLE_SET 

Use tuple set for same or 0.

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

◆ anonymous enum

anonymous enum

Distinct except 0 variants.

Enumerator
DISTINCT_EXCEPT_0_REIFIED 

Use reification for distinct except 0.

DISTINCT_EXCEPT_0_DFA 

Use dfa for distinct except 0.

DISTINCT_EXCEPT_0_COUNT 

Use count for distinct except 0.

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

◆ anonymous enum

anonymous enum

No monochrome rectangle versions.

Enumerator
NO_MONOCHROME_DECOMPOSITION 

Use decomposition for no monochrome rectangle.

NO_MONOCHROME_DFA 

Use dfa for no monochrome rectangle.

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

Constructor & Destructor Documentation

◆ ColoredMatrix() [1/2]

ColoredMatrix::ColoredMatrix ( const ColoredMatrixOptions & opt0)
inline

Actual model.

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

◆ ColoredMatrix() [2/2]

ColoredMatrix::ColoredMatrix ( ColoredMatrix & s)
inline

Constructor for cloning s.

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

Member Function Documentation

◆ same_or_0()

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 186 of file colored-matrix.cpp.

◆ distinct_except_0()

void ColoredMatrix::distinct_except_0 ( const IntVarArgs & v)
inlineprotected

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

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

◆ not_all_equal()

void ColoredMatrix::not_all_equal ( const IntVarArgs & v)
inlineprotected

Post constraint that not all variables in v are equal.

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

◆ no_monochrome_rectangle()

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 287 of file colored-matrix.cpp.

◆ cost()

virtual IntVar ColoredMatrix::cost ( void ) const
inlinevirtual

Return cost.

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

◆ print()

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

Print solution.

Reimplemented from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< IntMinimizeSpace > >.

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

◆ copy()

virtual Space * ColoredMatrix::copy ( void )
inlinevirtual

Copy during cloning.

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

◆ same_or_0_dfa()

DFA same_or_0_dfa ( 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$.

◆ same_or_0_tuple_set()

TupleSet same_or_0_tuple_set ( 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$.

◆ distinct_except_0_dfa()

DFA distinct_except_0_dfa ( int colors)
related

Return DFA for the distinct_except_0 constraint.

◆ no_monochrome_rectangle_dfa()

DFA no_monochrome_rectangle_dfa ( int colors)
related

Return DFA for the no monochrome rectangle constraint.

◆ distinct_except_0_counts()

IntSetArgs distinct_except_0_counts ( int colors,
int size )
related

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

◆ not_all_equal_dfa()

DFA not_all_equal_dfa ( int colors)
related

Return DFA for the not all equals constraint.

◆ main()

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

Main-function.

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

Member Data Documentation

◆ opt

const ColoredMatrixOptions& ColoredMatrix::opt
protected

Options for model.

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

◆ height

const int ColoredMatrix::height
protected

Height of matrix.

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

◆ width

const int ColoredMatrix::width
protected

Width of matrix.

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

◆ colors

const int ColoredMatrix::colors
protected

Number of colors to use.

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

◆ x

IntVarArray ColoredMatrix::x
protected

Array for matrix variables.

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

◆ max_color

IntVar ColoredMatrix::max_color
protected

Maximum color used.

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


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