Gecode::Int::IntVarImp Class Reference
Other available functionality

Integer variable implementation. More...

`#include <var-imp.hpp>`

## Classes

class | RangeList
| Lists of ranges (intervals). More...

## Public Member Functions

| IntVarImp (Space &home, int min, int max)
| Initialize with range domain.
| IntVarImp (Space &home, const IntSet &d)
| Initialize with domain specified by d.
Public Member Functions inherited from Gecode::Int::IntVarImpBase
| IntVarImpBase (void)
| Constructor for creating static instance of variable.
| IntVarImpBase (Gecode::Space &home)
| Constructor for creating variable.
void | subscribe (Gecode::Space &home, Gecode::Propagator &p, Gecode::PropCond pc, bool assigned, bool schedule)
| Subscribe propagator p with propagation condition pc.
void | subscribe (Gecode::Space &home, Gecode::Advisor &a, bool assigned, bool failed)
| Subscribe advisor a if assigned is false.
Gecode::ModEvent | notify (Gecode::Space &home, Gecode::ModEvent me, Gecode::Delta &d)
| Notify that variable implementation has been modified with modification event me and delta information d.
void | reschedule (Gecode::Space &home, Gecode::Propagator &p, Gecode::PropCond pc, bool assigned)
| Re-schedule propagator p.
Public Member Functions inherited from Gecode::VarImp< Gecode::Int::IntVarImpConf >
| VarImp (Space &home)
| Creation.
void | subscribe (Space &home, Propagator &p, PropCond pc, bool assigned, ModEvent me, bool schedule)
| Subscribe propagator p with propagation condition pc.
unsigned int | degree (void) const
| Return degree (number of subscribed propagators and advisors).
double | afc (void) const
| Return accumulated failure count (plus degree).
bool | copied (void) const
| Is variable already copied.
VarImp * | forward (void) const
| Use forward pointer if variable already copied.
unsigned int | bits (void) const
| Provide access to free bits.

## Protected Member Functions

RangeList * | fst (void) const
| Return first element of rangelist.
void | fst (RangeList *f)
| Set first element of rangelist.
RangeList * | lst (void) const
| Return last element of rangelist.
void | lst (RangeList *l)
| Set last element of rangelist.
| IntVarImp (Space &home, IntVarImp &x)
| Constructor for cloning x.
Protected Member Functions inherited from Gecode::Int::IntVarImpBase
| IntVarImpBase (Gecode::Space &home, IntVarImpBase &x)
| Constructor for cloning x.
Protected Member Functions inherited from Gecode::VarImp< Gecode::Int::IntVarImpConf >
void | cancel (Space &home)
| Cancel all subscriptions when variable implementation is assigned.
bool | advise (Space &home, ModEvent me, Delta &d)
| Run advisors when variable implementation has been modified with modification event me and domain change d.
ModEvent | fail (Space &home)
| Run advisors to be run on failure and returns ME_GEN_FAILED.

## Protected Attributes

RangeList | dom
| Domain information.
RangeList * | _lst
| Link the last element.
unsigned int | holes
| Size of holes in the domain.

## Range list access for iteration

const RangeList * | ranges_fwd (void) const
| Return range list for forward iteration.
const RangeList * | ranges_bwd (void) const
| Return range list for backward iteration.

## Value access

int | min (void) const
| Return minimum of domain.
int | max (void) const
| Return maximum of domain.
int | val (void) const
| Return assigned value (only if assigned).
int | med (void) const
| Return median of domain (greatest element not greater than the median).
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 | assigned (void) const
| Test whether variable is assigned.
bool | in (int n) const
| Test whether n is contained in domain.
bool | in (long long int n) const
| Test whether n is contained in domain.

## Domain update by value

ModEvent | lq (Space &home, int n)
| Restrict domain values to be less or equal than n.
ModEvent | lq (Space &home, long long int n)
| Restrict domain values to be less or equal than n.
ModEvent | gq (Space &home, int n)
| Restrict domain values to be greater or equal than n.
ModEvent | gq (Space &home, long long int n)
| Restrict domain values to be greater or equal than n.
ModEvent | nq (Space &home, int n)
| Restrict domain values to be different from n.
ModEvent | nq (Space &home, long long int n)
| Restrict domain values to be different from n.
ModEvent | eq (Space &home, int n)
| Restrict domain values to be equal to n.
ModEvent | eq (Space &home, long long int n)
| Restrict domain values to be equal to n.

## Domain update by iterator

Variable domains can be both updated by range and value iterators. Value iterators do not need to be strict in that the same value is allowed to occur more than once in the iterated sequence.

The argument depends must be true, if the iterator passed as argument depends on the variable implementation on which the operation is invoked. In this case, the variable implementation is only updated after the iterator has been consumed. Otherwise, the domain might be updated concurrently while following the iterator.

template<class I>
ModEvent | narrow_r (Space &home, I &i, bool depends=true)
| Replace domain by ranges described by i.
template<class I>
ModEvent | inter_r (Space &home, I &i, bool depends=true)
| Intersect domain with ranges described by i.
template<class I>
ModEvent | minus_r (Space &home, I &i, bool depends=true)
| Remove from domain the ranges described by i.
template<class I>
ModEvent | narrow_v (Space &home, I &i, bool depends=true)
| Replace domain by values described by i.
template<class I>
ModEvent | inter_v (Space &home, I &i, bool depends=true)
| Intersect domain with values described by i.
template<class I>
ModEvent | minus_v (Space &home, I &i, bool depends=true)
| Remove from domain the values described by i.

## Dependencies

void | subscribe (Space &home, Propagator &p, PropCond pc, bool schedule=true)
| Subscribe propagator p with propagation condition pc to variable.
void | reschedule (Space &home, Propagator &p, PropCond pc)
| Re-schedule propagator p.
void | subscribe (Space &home, Advisor &a, bool fail)
| Subscribe advisor a to variable.

## Cloning

IntVarImp * | copy (Space &home)
| Return copy of this variable.

## Variable implementation-dependent propagator support

static ModEventDelta | med (ModEvent me)
| Translate modification event me to modification event delta for view.

## Delta information for advisors

static int | min (const Delta &d)
| Return minimum value just pruned.
static int | max (const Delta &d)
| Return maximum value just pruned.
static unsigned int | width (const Delta &d)
| Return width of values just pruned.
static bool | any (const Delta &d)
| Test whether arbitrary values got pruned.

## Additional Inherited Members

static void | schedule (Gecode::Space &home, Gecode::Propagator &p, Gecode::ModEvent me)
| Schedule propagator p.
static void | schedule (Space &home, Propagator &p, ModEvent me, bool force=false)
| Schedule propagator p with modification event me.
static void | reschedule (Space &home, Propagator &p, PropCond pc, bool assigned, ModEvent me)
| Schedule propagator p.
static ModEvent | me (const ModEventDelta &med)
| Project modification event for this variable type from med.
static ModEventDelta | med (ModEvent me)
| Translate modification event me into modification event delta.
static ModEvent | me_combine (ModEvent me1, ModEvent me2)
| Combine modifications events me1 and me2.
static ModEvent | modevent (const Delta &d)
| Return modification event.
static void * | operator new (size_t, Space &)
| Allocate memory from space.
static void | operator delete (void *, Space &)
| Return memory to space.
Public Attributes inherited from Gecode::VarImp< Gecode::Int::IntVarImpConf >
ActorLink ** | base
| Subscribed actors.
VarImp< Gecode::Int::IntVarImpConf > * | fwd
| Forwarding pointer.
unsigned int | idx [pc_max+1]
| Indices of subscribed actors.
VarImp< Gecode::Int::IntVarImpConf > * | next
| During cloning, points to the next copied variable.

## Detailed Description

Integer variable implementation.

Definition at line 89 of file var-imp.hpp.

## Constructor & Destructor Documentation

## IntVarImp() [1/3]

Gecode::Int::IntVarImp::IntVarImp | ( | Space & | home,
|  | IntVarImp & | x )

inline protected

Constructor for cloning x.

Definition at line 317 of file int.cpp.

## IntVarImp() [2/3]

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

inline

Initialize with range domain.

Definition at line 188 of file int.hpp.

## IntVarImp() [3/3]

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

inline

Initialize with domain specified by d.

Definition at line 192 of file int.hpp.

## Member Function Documentation

## fst() [1/2]

IntVarImp::RangeList * Gecode::Int::IntVarImp::fst | ( | void |  | ) | const

inline protected

Return first element of rangelist.

Definition at line 163 of file int.hpp.

## fst() [2/2]

void Gecode::Int::IntVarImp::fst | ( | IntVarImp::RangeList * | f | ) |

inline protected

Set first element of rangelist.

Definition at line 168 of file int.hpp.

## lst() [1/2]

IntVarImp::RangeList * Gecode::Int::IntVarImp::lst | ( | void |  | ) | const

inline protected

Return last element of rangelist.

Definition at line 173 of file int.hpp.

## lst() [2/2]

void Gecode::Int::IntVarImp::lst | ( | IntVarImp::RangeList * | l | ) |

inline protected

Set last element of rangelist.

Definition at line 178 of file int.hpp.

## min() [1/2]

int Gecode::Int::IntVarImp::min | ( | void |  | ) | const

inline

Return minimum of domain.

Definition at line 224 of file int.hpp.

## max() [1/2]

int Gecode::Int::IntVarImp::max | ( | void |  | ) | const

inline

Return maximum of domain.

Definition at line 228 of file int.hpp.

## val()

int Gecode::Int::IntVarImp::val | ( | void |  | ) | const

inline

Return assigned value (only if assigned).

Definition at line 232 of file int.hpp.

## med() [1/2]

int Gecode::Int::IntVarImp::med | ( | void |  | ) | const

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

Definition at line 46 of file int.cpp.

## size()

unsigned int Gecode::Int::IntVarImp::size | ( | void |  | ) | const

inline

Return size (cardinality) of domain.

Definition at line 253 of file int.hpp.

## width() [1/2]

unsigned int Gecode::Int::IntVarImp::width | ( | void |  | ) | const

inline

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

Definition at line 248 of file int.hpp.

## regret_min()

unsigned int Gecode::Int::IntVarImp::regret_min | ( | void |  | ) | const

inline

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

Definition at line 258 of file int.hpp.

## regret_max()

unsigned int Gecode::Int::IntVarImp::regret_max | ( | void |  | ) | const

inline

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

Definition at line 268 of file int.hpp.

## range()

bool Gecode::Int::IntVarImp::range | ( | void |  | ) | const

inline

Test whether domain is a range.

Definition at line 238 of file int.hpp.

## assigned()

bool Gecode::Int::IntVarImp::assigned | ( | void |  | ) | const

inline

Test whether variable is assigned.

Definition at line 242 of file int.hpp.

## in() [1/2]

bool Gecode::Int::IntVarImp::in | ( | int | n | ) | const

inline

Test whether n is contained in domain.

Definition at line 286 of file int.hpp.

## in() [2/2]

bool Gecode::Int::IntVarImp::in | ( | long long int | n | ) | const

inline

Test whether n is contained in domain.

Definition at line 292 of file int.hpp.

## ranges_fwd()

const IntVarImp::RangeList * Gecode::Int::IntVarImp::ranges_fwd | ( | void |  | ) | const

inline protected

Return range list for forward iteration.

Definition at line 305 of file int.hpp.

## ranges_bwd()

const IntVarImp::RangeList * Gecode::Int::IntVarImp::ranges_bwd | ( | void |  | ) | const

inline protected

Return range list for backward iteration.

Definition at line 310 of file int.hpp.

## lq() [1/2]

ModEvent Gecode::Int::IntVarImp::lq | ( | Space & | home,
|  | int | n )

inline

Restrict domain values to be less or equal than n.

Definition at line 365 of file int.hpp.

## lq() [2/2]

ModEvent Gecode::Int::IntVarImp::lq | ( | Space & | home,
|  | long long int | n )

inline

Restrict domain values to be less or equal than n.

Definition at line 375 of file int.hpp.

## gq() [1/2]

ModEvent Gecode::Int::IntVarImp::gq | ( | Space & | home,
|  | int | n )

inline

Restrict domain values to be greater or equal than n.

Definition at line 344 of file int.hpp.

## gq() [2/2]

ModEvent Gecode::Int::IntVarImp::gq | ( | Space & | home,
|  | long long int | n )

inline

Restrict domain values to be greater or equal than n.

Definition at line 354 of file int.hpp.

## nq() [1/2]

ModEvent Gecode::Int::IntVarImp::nq | ( | Space & | home,
|  | int | n )

inline

Restrict domain values to be different from n.

Definition at line 408 of file int.hpp.

## nq() [2/2]

ModEvent Gecode::Int::IntVarImp::nq | ( | Space & | home,
|  | long long int | n )

inline

Restrict domain values to be different from n.

Definition at line 414 of file int.hpp.

## eq() [1/2]

ModEvent Gecode::Int::IntVarImp::eq | ( | Space & | home,
|  | int | n )

inline

Restrict domain values to be equal to n.

Definition at line 386 of file int.hpp.

## eq() [2/2]

ModEvent Gecode::Int::IntVarImp::eq | ( | Space & | home,
|  | long long int | n )

inline

Restrict domain values to be equal to n.

Definition at line 396 of file int.hpp.

## narrow_r()

template<class I>

ModEvent Gecode::Int::IntVarImp::narrow_r | ( | Space & | home,
|  | I & | i,
|  | bool | depends = true )

inline

Replace domain by ranges described by i.

Definition at line 503 of file int.hpp.

## inter_r()

template<class I>

ModEvent Gecode::Int::IntVarImp::inter_r | ( | Space & | home,
|  | I & | i,
|  | bool | depends = true )

inline

Intersect domain with ranges described by i.

Definition at line 670 of file int.hpp.

## minus_r()

template<class I>

ModEvent Gecode::Int::IntVarImp::minus_r | ( | Space & | home,
|  | I & | i,
|  | bool | depends = true )

inline

Remove from domain the ranges described by i.

Definition at line 678 of file int.hpp.

## narrow_v()

template<class I>

ModEvent Gecode::Int::IntVarImp::narrow_v | ( | Space & | home,
|  | I & | i,
|  | bool | depends = true )

inline

Replace domain by values described by i.

Definition at line 835 of file int.hpp.

## inter_v()

template<class I>

ModEvent Gecode::Int::IntVarImp::inter_v | ( | Space & | home,
|  | I & | i,
|  | bool | depends = true )

inline

Intersect domain with values described by i.

Definition at line 842 of file int.hpp.

## minus_v()

template<class I>

ModEvent Gecode::Int::IntVarImp::minus_v | ( | Space & | home,
|  | I & | i,
|  | bool | depends = true )

inline

Remove from domain the values described by i.

Definition at line 849 of file int.hpp.

## subscribe() [1/2]

void Gecode::Int::IntVarImp::subscribe | ( | Space & | home,
|  | Propagator & | p,
|  | PropCond | pc,
|  | bool | schedule = true )

Subscribe propagator p with propagation condition pc to variable.

In case schedule is false, the propagator is just subscribed but not scheduled for execution (this must be used when creating subscriptions during propagation).

Definition at line 362 of file int.cpp.

## reschedule()

void Gecode::Int::IntVarImp::reschedule | ( | Space & | home,
|  | Propagator & | p,
|  | PropCond | pc )

Re-schedule propagator p.

Definition at line 368 of file int.cpp.

## subscribe() [2/2]

void Gecode::Int::IntVarImp::subscribe | ( | Space & | home,
|  | Advisor & | a,
|  | bool | fail )

Subscribe advisor a to variable.

The advisor a is only subscribed if assigned is false.

If fail is true, the advisor a is also run when a variable operation triggers failure. This feature is undocumented.

Definition at line 373 of file int.cpp.

## med() [2/2]

ModEventDelta Gecode::Int::IntVarImp::med | ( | ModEvent | me | ) |

inline static

Translate modification event me to modification event delta for view.

Definition at line 998 of file int.hpp.

## copy()

IntVarImp * Gecode::Int::IntVarImp::copy | ( | Space & | home | ) |

inline

Return copy of this variable.

Definition at line 991 of file int.hpp.

## min() [2/2]

int Gecode::Int::IntVarImp::min | ( | const Delta & | d | ) |

inline static

Return minimum value just pruned.

Definition at line 321 of file int.hpp.

## max() [2/2]

int Gecode::Int::IntVarImp::max | ( | const Delta & | d | ) |

inline static

Return maximum value just pruned.

Definition at line 325 of file int.hpp.

## width() [2/2]

unsigned int Gecode::Int::IntVarImp::width | ( | const Delta & | d | ) |

inline static

Return width of values just pruned.

Definition at line 329 of file int.hpp.

## any()

bool Gecode::Int::IntVarImp::any | ( | const Delta & | d | ) |

inline static

Test whether arbitrary values got pruned.

Definition at line 333 of file int.hpp.

## Member Data Documentation

## dom

RangeList Gecode::Int::IntVarImp::dom

protected

Domain information.

Provides fast access to minimum and maximum of the entire domain and links to the first element of a RangeList defining the domain.

Definition at line 188 of file var-imp.hpp.

## _lst

RangeList* Gecode::Int::IntVarImp::_lst

protected

Link the last element.

Definition at line 190 of file var-imp.hpp.

## holes

unsigned int Gecode::Int::IntVarImp::holes

protected

Size of holes in the domain.

Definition at line 200 of file var-imp.hpp.

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

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