Gecode::IntVar Class Reference
Functionality by programming task » Programming models » Using integer variables and constraints » Integer variables

Integer variables. More...

`#include <int.hh>`

## Related Symbols

(Note that these are not member symbols.)
template<class Char, class Traits>
std::basic_ostream< Char, Traits > & | operator<< (std::basic_ostream< Char, Traits > &os, const IntVar &x)
| Print integer variable x.

## Constructors and initialization

| IntVar (void)
| Default constructor.
| IntVar (const IntVar &y)
| Initialize from integer variable y.
| IntVar (const Int::IntView &y)
| Initialize from integer view y.
| IntVar (Space &home, int min, int max)
| Initialize variable with range domain.
| IntVar (Space &home, const IntSet &d)
| Initialize variable with arbitrary domain.

## Value access

int | min (void) const
| Return minimum of domain.
int | max (void) const
| Return maximum of domain.
int | med (void) const
| Return median of domain (greatest element not greater than the median).
int | val (void) const
| Return assigned value.
unsigned int | size (void) const
| Return size (cardinality) of domain.
unsigned int | width (void) const
| Return width of domain (distance between maximum and minimum).
unsigned int | regret_min (void) const
| Return regret of domain minimum (distance to next larger value).
unsigned int | regret_max (void) const
| Return regret of domain maximum (distance to next smaller value).

## Domain tests

bool | range (void) const
| Test whether domain is a range.
bool | in (int n) const
| Test whether n is contained in domain.

## Additional Inherited Members

Public Types inherited from Gecode::VarImpVar< Int::IntVarImp >
typedef Int::IntVarImp | VarImpType
| The variable implementation type corresponding to the variable.
Int::IntVarImp * | varimp (void) const
| Return variable implementation of variable.
unsigned int | degree (void) const
| Return degree (number of subscribed propagators and advisors).
double | afc (void) const
| Return accumulated failure count.
bool | assigned (void) const
| Test whether view is assigned.
void | update (Space &home, VarImpVar< Int::IntVarImp > &y)
| Update this variable to be a clone of variable y.
Protected Member Functions inherited from Gecode::VarImpVar< Int::IntVarImp >
| VarImpVar (void)
| Default constructor.
Protected Attributes inherited from Gecode::VarImpVar< Int::IntVarImp >
Int::IntVarImp * | x
| Pointer to variable implementation.

## Detailed Description

Integer variables.

Definition at line 371 of file int.hh.

## Constructor & Destructor Documentation

## IntVar() [1/5]

Gecode::IntVar::IntVar | ( | void |  | ) |

inline

Default constructor.

Definition at line 47 of file int.hpp.

## IntVar() [2/5]

Gecode::IntVar::IntVar | ( | const IntVar & | y | ) |

inline

Initialize from integer variable y.

Definition at line 49 of file int.hpp.

## IntVar() [3/5]

Gecode::IntVar::IntVar | ( | const Int::IntView & | y | ) |

inline

Initialize from integer view y.

Definition at line 52 of file int.hpp.

## IntVar() [4/5]

Gecode::IntVar::IntVar | ( | Space & | home,
|  | int | min,
|  | int | max )

Initialize variable with range domain.

The variable is created with a domain ranging from min to max. The following exceptions might be thrown:

- If min is greater than max, an exception of type Gecode::Int::VariableEmptyDomain is thrown.
- If min or max exceed the limits for integers as defined in Gecode::Int::Limits, an exception of type Gecode::Int::OutOfLimits is thrown.

Definition at line 38 of file int.cpp.

## IntVar() [5/5]

Gecode::IntVar::IntVar | ( | Space & | home,
|  | const IntSet & | d )

Initialize variable with arbitrary domain.

The variable is created with a domain described by d. The following exceptions might be thrown:

- If d is empty, an exception of type Gecode::Int::VariableEmptyDomain is thrown.
- If d contains values that exceed the limits for integers as defined in Gecode::Int::Limits, an exception of type Gecode::Int::OutOfLimits is thrown.

Definition at line 46 of file int.cpp.

## Member Function Documentation

## min()

int Gecode::IntVar::min | ( | void |  | ) | const

inline

Return minimum of domain.

Definition at line 62 of file int.hpp.

## max()

int Gecode::IntVar::max | ( | void |  | ) | const

inline

Return maximum of domain.

Definition at line 70 of file int.hpp.

## med()

int Gecode::IntVar::med | ( | void |  | ) | const

inline

Return median of domain (greatest element not greater than the median).

Definition at line 66 of file int.hpp.

## val()

int Gecode::IntVar::val | ( | void |  | ) | const

inline

Return assigned value.

Throws an exception of type Int::ValOfUnassignedVar if variable is not yet assigned.

Definition at line 56 of file int.hpp.

## size()

unsigned int Gecode::IntVar::size | ( | void |  | ) | const

inline

Return size (cardinality) of domain.

Definition at line 80 of file int.hpp.

## width()

unsigned int Gecode::IntVar::width | ( | void |  | ) | const

inline

Return width of domain (distance between maximum and minimum).

Definition at line 76 of file int.hpp.

## regret_min()

unsigned int Gecode::IntVar::regret_min | ( | void |  | ) | const

inline

Return regret of domain minimum (distance to next larger value).

Definition at line 84 of file int.hpp.

## regret_max()

unsigned int Gecode::IntVar::regret_max | ( | void |  | ) | const

inline

Return regret of domain maximum (distance to next smaller value).

Definition at line 88 of file int.hpp.

## range()

bool Gecode::IntVar::range | ( | void |  | ) | const

inline

Test whether domain is a range.

Definition at line 93 of file int.hpp.

## in()

bool Gecode::IntVar::in | ( | int | n | ) | const

inline

Test whether n is contained in domain.

Definition at line 97 of file int.hpp.

## Friends And Related Symbol Documentation

## operator<<()

template<class Char, class Traits>

std::basic_ostream< Char, Traits > & operator<< | ( | std::basic_ostream< Char, Traits > & | os,
|  | const IntVar & | x )

related

Print integer variable x.

Definition at line 1 of file print.hpp.

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

- gecode/int.hh
- gecode/int/var/int.cpp
- gecode/int/var/int.hpp