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

Boolean variable implementation. More...

#include <var-imp.hpp>

Public Member Functions

 BoolVarImp (Space &home, int min, int max)
 Initialize with range domain.
Public Member Functions inherited from Gecode::Int::BoolVarImpBase
 BoolVarImpBase (void)
 Constructor for creating static instance of variable.
 BoolVarImpBase (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::BoolVarImpConf >
 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.
VarImpforward (void) const
 Use forward pointer if variable already copied.
unsigned int bits (void) const
 Provide access to free bits.

Domain status access

static const int BITS = 2
 How many bits does the status have.
static const BoolStatus ZERO = 0
 Status of domain assigned to zero.
static const BoolStatus ONE = 3
 Status of domain assigned to one.
static const BoolStatus NONE = 2
 Status of domain not yet assigned.
BoolStatus status (void) const
 Return current domain status.

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)

Boolean domain tests

bool zero (void) const
 Test whether variable is assigned to zero.
bool one (void) const
 Test whether variable is assigned to one.
bool none (void) const
 Test whether variable is not yet assigned.

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.

Boolean update operations

ModEvent zero (Space &home)
 Assign variable to zero.
ModEvent one (Space &home)
 Assign variable to one.
ModEvent zero_none (Space &home)
 Assign unassigned variable to zero.
ModEvent one_none (Space &home)
 Assign unassigned variable to one.

Dependencies

void subscribe (Space &home, Propagator &p, PropCond pc, bool schedule=true)
 Subscribe propagator p to variable with propagation condition pc.
void cancel (Space &home, Propagator &p, PropCond pc)
 Cancel subscription of propagator p with propagation condition pc.
void subscribe (Space &home, Advisor &a, bool fail)
 Subscribe advisor a to variable.
void cancel (Space &home, Advisor &a, bool fail)
 Cancel subscription of advisor a.

Variable implementation-dependent propagator support

void reschedule (Space &home, Propagator &p, PropCond pc)
 Re-schedule propagator p.
static void schedule (Space &home, Propagator &p, ModEvent me)
 Schedule propagator p with modification event me.
static ModEventDelta med (ModEvent me)
 Translate modification event me to modification event delta for view.

Cloning

BoolVarImpcopy (Space &home)
 Return copy of this variable.

Support for delta information for advisors

static ModEvent modevent (const Delta &d)
 Return modification event.
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.
static bool zero (const Delta &d)
 Test whether a variable has been assigned to zero.
static bool one (const Delta &d)
 Test whether a variable has been assigned to one.

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::BoolVarImpConf >
ActorLink ** base
 Subscribed actors.
VarImp< Gecode::Int::BoolVarImpConf > * fwd
 Forwarding pointer.
unsigned int idx [pc_max+1]
 Indices of subscribed actors.
VarImp< Gecode::Int::BoolVarImpConf > * next
 During cloning, points to the next copied variable.
Protected Member Functions inherited from Gecode::Int::BoolVarImpBase
 BoolVarImpBase (Gecode::Space &home, BoolVarImpBase &x)
 Constructor for cloning x.
Protected Member Functions inherited from Gecode::VarImp< Gecode::Int::BoolVarImpConf >
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.

Detailed Description

Boolean variable implementation.

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

Constructor & Destructor Documentation

◆ BoolVarImp()

Gecode::Int::BoolVarImp::BoolVarImp ( Space & home,
int min,
int max )
inline

Initialize with range domain.

Definition at line 46 of file bool.hpp.

Member Function Documentation

◆ status()

BoolStatus Gecode::Int::BoolVarImp::status ( void ) const
inline

Return current domain status.

Definition at line 58 of file bool.hpp.

◆ min() [1/2]

int Gecode::Int::BoolVarImp::min ( void ) const
inline

Return minimum of domain.

Definition at line 62 of file bool.hpp.

◆ max() [1/2]

int Gecode::Int::BoolVarImp::max ( void ) const
inline

Return maximum of domain.

Definition at line 66 of file bool.hpp.

◆ val()

int Gecode::Int::BoolVarImp::val ( void ) const
inline

Return assigned value (only if assigned)

Definition at line 75 of file bool.hpp.

◆ med() [1/2]

int Gecode::Int::BoolVarImp::med ( void ) const
inline

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

Definition at line 70 of file bool.hpp.

◆ size()

unsigned int Gecode::Int::BoolVarImp::size ( void ) const
inline

Return size (cardinality) of domain.

Definition at line 96 of file bool.hpp.

◆ width() [1/2]

unsigned int Gecode::Int::BoolVarImp::width ( void ) const
inline

Return width of domain (distance between maximum and minimum)

Definition at line 91 of file bool.hpp.

◆ regret_min()

unsigned int Gecode::Int::BoolVarImp::regret_min ( void ) const
inline

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

Definition at line 101 of file bool.hpp.

◆ regret_max()

unsigned int Gecode::Int::BoolVarImp::regret_max ( void ) const
inline

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

Definition at line 105 of file bool.hpp.

◆ zero() [1/3]

bool Gecode::Int::BoolVarImp::zero ( void ) const
inline

Test whether variable is assigned to zero.

Definition at line 131 of file bool.hpp.

◆ one() [1/3]

bool Gecode::Int::BoolVarImp::one ( void ) const
inline

Test whether variable is assigned to one.

Definition at line 135 of file bool.hpp.

◆ none()

bool Gecode::Int::BoolVarImp::none ( void ) const
inline

Test whether variable is not yet assigned.

Definition at line 139 of file bool.hpp.

◆ range()

bool Gecode::Int::BoolVarImp::range ( void ) const
inline

Test whether domain is a range.

Definition at line 81 of file bool.hpp.

◆ assigned()

bool Gecode::Int::BoolVarImp::assigned ( void ) const
inline

Test whether variable is assigned.

Definition at line 85 of file bool.hpp.

◆ in() [1/2]

bool Gecode::Int::BoolVarImp::in ( int n) const
inline

Test whether n is contained in domain.

Definition at line 117 of file bool.hpp.

◆ in() [2/2]

bool Gecode::Int::BoolVarImp::in ( long long int n) const
inline

Test whether n is contained in domain.

Definition at line 121 of file bool.hpp.

◆ lq() [1/2]

ModEvent Gecode::Int::BoolVarImp::lq ( Space & home,
int n )
inline

Restrict domain values to be less or equal than n.

Definition at line 214 of file bool.hpp.

◆ lq() [2/2]

ModEvent Gecode::Int::BoolVarImp::lq ( Space & home,
long long int n )
inline

Restrict domain values to be less or equal than n.

Definition at line 220 of file bool.hpp.

◆ gq() [1/2]

ModEvent Gecode::Int::BoolVarImp::gq ( Space & home,
int n )
inline

Restrict domain values to be greater or equal than n.

Definition at line 201 of file bool.hpp.

◆ gq() [2/2]

ModEvent Gecode::Int::BoolVarImp::gq ( Space & home,
long long int n )
inline

Restrict domain values to be greater or equal than n.

Definition at line 207 of file bool.hpp.

◆ nq() [1/2]

ModEvent Gecode::Int::BoolVarImp::nq ( Space & home,
int n )
inline

Restrict domain values to be different from n.

Definition at line 238 of file bool.hpp.

◆ nq() [2/2]

ModEvent Gecode::Int::BoolVarImp::nq ( Space & home,
long long int n )
inline

Restrict domain values to be different from n.

Definition at line 243 of file bool.hpp.

◆ eq() [1/2]

ModEvent Gecode::Int::BoolVarImp::eq ( Space & home,
int n )
inline

Restrict domain values to be equal to n.

Definition at line 227 of file bool.hpp.

◆ eq() [2/2]

ModEvent Gecode::Int::BoolVarImp::eq ( Space & home,
long long int n )
inline

Restrict domain values to be equal to n.

Definition at line 232 of file bool.hpp.

◆ narrow_r()

template<class I>
ModEvent Gecode::Int::BoolVarImp::narrow_r ( Space & home,
I & i,
bool depends = true )
inline

Replace domain by ranges described by i.

Definition at line 276 of file bool.hpp.

◆ inter_r()

template<class I>
ModEvent Gecode::Int::BoolVarImp::inter_r ( Space & home,
I & i,
bool depends = true )
inline

Intersect domain with ranges described by i.

Definition at line 297 of file bool.hpp.

◆ minus_r()

template<class I>
ModEvent Gecode::Int::BoolVarImp::minus_r ( Space & home,
I & i,
bool depends = true )
inline

Remove from domain the ranges described by i.

Definition at line 314 of file bool.hpp.

◆ narrow_v()

template<class I>
ModEvent Gecode::Int::BoolVarImp::narrow_v ( Space & home,
I & i,
bool depends = true )
inline

Replace domain by values described by i.

Definition at line 332 of file bool.hpp.

◆ inter_v()

template<class I>
ModEvent Gecode::Int::BoolVarImp::inter_v ( Space & home,
I & i,
bool depends = true )
inline

Intersect domain with values described by i.

Definition at line 351 of file bool.hpp.

◆ minus_v()

template<class I>
ModEvent Gecode::Int::BoolVarImp::minus_v ( Space & home,
I & i,
bool depends = true )
inline

Remove from domain the values described by i.

Definition at line 370 of file bool.hpp.

◆ zero() [2/3]

ModEvent Gecode::Int::BoolVarImp::zero ( Space & home)
inline

Assign variable to zero.

Definition at line 183 of file bool.hpp.

◆ one() [2/3]

ModEvent Gecode::Int::BoolVarImp::one ( Space & home)
inline

Assign variable to one.

Definition at line 189 of file bool.hpp.

◆ zero_none()

ModEvent Gecode::Int::BoolVarImp::zero_none ( Space & home)

Assign unassigned variable to zero.

Definition at line 51 of file bool.cpp.

◆ one_none()

ModEvent Gecode::Int::BoolVarImp::one_none ( Space & home)

Assign unassigned variable to one.

Definition at line 42 of file bool.cpp.

◆ subscribe() [1/2]

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

Subscribe propagator p to variable with propagation condition pc.

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

The propagation condition pc can be a propagation condition for integer variables, which will be mapped to PC_BOOL_VAL.

Definition at line 60 of file bool.cpp.

◆ cancel() [1/2]

void Gecode::Int::BoolVarImp::cancel ( Space & home,
Propagator & p,
PropCond pc )
inline

Cancel subscription of propagator p with propagation condition pc.

The propagation condition pc can be a propagation condition for integer variables, which will be mapped to PC_BOOL_VAL.

Definition at line 395 of file bool.hpp.

◆ subscribe() [2/2]

void Gecode::Int::BoolVarImp::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 73 of file bool.cpp.

◆ cancel() [2/2]

void Gecode::Int::BoolVarImp::cancel ( Space & home,
Advisor & a,
bool fail )
inline

Cancel subscription of advisor a.

Definition at line 400 of file bool.hpp.

◆ schedule()

void Gecode::Int::BoolVarImp::schedule ( Space & home,
Propagator & p,
ModEvent me )
inlinestatic

Schedule propagator p with modification event me.

The modfication event me can be a modification event for integer variables, however me will be ignored if it is not ME_INT_VAL (or ME_BOOL_VAL).

Definition at line 405 of file bool.hpp.

◆ reschedule()

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

Re-schedule propagator p.

Definition at line 68 of file bool.cpp.

◆ med() [2/2]

ModEventDelta Gecode::Int::BoolVarImp::med ( ModEvent me)
inlinestatic

Translate modification event me to modification event delta for view.

Definition at line 410 of file bool.hpp.

◆ modevent()

ModEvent Gecode::Int::BoolVarImp::modevent ( const Delta & d)
inlinestatic

Return modification event.

Definition at line 149 of file bool.hpp.

◆ min() [2/2]

int Gecode::Int::BoolVarImp::min ( const Delta & d)
inlinestatic

Return minimum value just pruned.

Definition at line 153 of file bool.hpp.

◆ max() [2/2]

int Gecode::Int::BoolVarImp::max ( const Delta & d)
inlinestatic

Return maximum value just pruned.

Definition at line 157 of file bool.hpp.

◆ width() [2/2]

unsigned int Gecode::Int::BoolVarImp::width ( const Delta & d)
inlinestatic

Return width of values just pruned.

Definition at line 161 of file bool.hpp.

◆ any()

bool Gecode::Int::BoolVarImp::any ( const Delta & d)
inlinestatic

Test whether arbitrary values got pruned.

Definition at line 165 of file bool.hpp.

◆ zero() [3/3]

bool Gecode::Int::BoolVarImp::zero ( const Delta & d)
inlinestatic

Test whether a variable has been assigned to zero.

Definition at line 169 of file bool.hpp.

◆ one() [3/3]

bool Gecode::Int::BoolVarImp::one ( const Delta & d)
inlinestatic

Test whether a variable has been assigned to one.

Definition at line 173 of file bool.hpp.

◆ copy()

BoolVarImp * Gecode::Int::BoolVarImp::copy ( Space & home)
inline

Return copy of this variable.

Definition at line 258 of file bool.hpp.

Member Data Documentation

◆ BITS

const int Gecode::Int::BoolVarImp::BITS = 2
static

How many bits does the status have.

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

◆ ZERO

const BoolStatus Gecode::Int::BoolVarImp::ZERO = 0
static

Status of domain assigned to zero.

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

◆ ONE

const BoolStatus Gecode::Int::BoolVarImp::ONE = 3
static

Status of domain assigned to one.

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

◆ NONE

const BoolStatus Gecode::Int::BoolVarImp::NONE = 2
static

Status of domain not yet assigned.

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


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