38 namespace Gecode {
namespace Int {
45 BoolVarImp::BoolVarImp(
int n) {
47 bits() |= (n << 1) | n;
53 bits() |= (max << 1) | min;
67 return static_cast<int>(
bits() & 1);
71 return static_cast<int>((
bits() & 2) >> 1);
122 return (n >=
min()) && (n <=
max());
126 return (n >=
min()) && (n <=
max());
207 if (n > 1)
return fail(home);
213 if (n > 1)
return fail(home);
219 if (n < 0)
return fail(home);
225 if (n < 0)
return fail(home);
232 if ((n < 0) || (n > 1))
return fail(home);
233 return (n == 0) ?
zero(home):
one(home);
237 if ((n < 0) || (n > 1))
return fail(home);
238 return (n == 0) ?
zero(home):
one(home);
244 return (n == 0) ?
one(home):
zero(home);
249 return (n == 0) ?
one(home):
zero(home);
284 assert((i.min() == 0) || (i.min() == 1));
285 assert((i.max() == 0) || (i.max() == 1));
303 while (
i() && (i.max() < 0))
306 if (!
i() || (i.min() > 1))
308 assert(i.min() <= 1);
313 assert((i.min() <= 0) && (i.max() >= 1));
320 while (
i() && (i.max() < 0))
323 if (!
i() || (i.min() > 1))
325 assert(i.min() <= 1);
330 assert((i.min() <= 0) && (i.max() >= 1));
344 }
while (
i() && (i.val() == 0));
349 assert(i.val() == 1);
356 while (
i() && (i.val() < 0))
358 if (!
i() || (i.val() > 1))
363 }
while (
i() && (i.val() == 0));
364 if (!
i() || (i.val() > 1))
368 assert(i.val() == 1);
375 while (
i() && (i.val() < 0))
377 if (!
i() || (i.val() > 1))
382 }
while (
i() && (i.val() == 0));
383 if (!
i() || (i.val() > 1))
387 assert(i.val() == 1);
ModEvent minus_r(Space &home, I &i, bool depends=true)
Remove from domain the ranges described by i.
BoolVarImp * copy(Space &home)
Return copy of this variable.
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
VarImp * forward(void) const
Use forward pointer if variable already copied.
bool in(int n) const
Test whether n is contained in domain.
unsigned int BoolStatus
Type for status of a Boolean variable.
static const BoolStatus NONE
Status of domain not yet assigned.
void cancel(Space &home, Propagator &p, PropCond pc)
Cancel subscription of propagator p with propagation condition pc.
ModEvent zero_none(Space &home)
Assign unassigned variable to zero.
const ModEvent ME_GEN_ASSIGNED
Generic modification event: variable is assigned a value.
unsigned int size(void) const
Return size (cardinality) of domain.
int ModEvent
Type for modification events.
ModEvent minus_v(Space &home, I &i, bool depends=true)
Remove from domain the values described by i.
static bool any(const Delta &d)
Test whether arbitrary values got pruned.
Base-class for propagators.
static ModEventDelta med(ModEvent me)
Translate modification event me into modification event delta.
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
bool zero(void) const
Test whether variable is assigned to zero.
bool assigned(void) const
Test whether variable is assigned.
void cancel(Space &home)
Cancel all subscriptions when variable implementation is assigned.
Boolean variable implementation.
int min(void) const
Return minimum of domain.
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
static ModEvent me(const ModEventDelta &med)
Project modification event for this variable type from med.
bool copied(void) const
Is variable already copied.
int PropCond
Type for propagation conditions.
const Gecode::ModEvent ME_BOOL_NONE
Domain operation has not changed domain.
int max(void) const
Return maximum of domain.
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Integer delta information for advisors.
ModEvent inter_v(Space &home, I &i, bool depends=true)
Intersect domain with values described by i.
BoolStatus status(void) const
Return current domain status.
bool range(void) const
Test whether domain is a range.
Generic domain change information to be supplied to advisors.
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
ModEvent one_none(Space &home)
Assign unassigned variable to one.
ModEvent inter_r(Space &home, I &i, bool depends=true)
Intersect domain with ranges described by i.
bool none(void) const
Test whether variable is not yet assigned.
int val(void) const
Return assigned value (only if assigned)
Base-class for Bool-variable implementations.
ModEvent nq(Space &home, int n)
Restrict domain values to be different from n.
ModEvent fail(Space &home)
Run advisors to be run on failure and returns ME_GEN_FAILED.
Post propagator for SetVar x
const Gecode::ModEvent ME_BOOL_FAILED
Domain operation has resulted in failure.
static void schedule(Gecode::Space &home, Gecode::Propagator &p, Gecode::ModEvent me)
Schedule propagator p.
Gecode toplevel namespace
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
static void schedule(Space &home, Propagator &p, ModEvent me)
Schedule propagator p with modification event me.
ModEvent narrow_v(Space &home, I &i, bool depends=true)
Replace domain by values described by i.
static ModEvent modevent(const Delta &d)
Return modification event.
int ModEventDelta
Modification event deltas.
unsigned int bits(void) const
Provide access to free bits.
BoolVarImpBase(void)
Constructor for creating static instance of variable.
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
const Gecode::ModEvent ME_INT_NONE
Domain operation has not changed domain.
int med(void) const
Return median of domain (greatest element not greater than the median)
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
bool one(void) const
Test whether variable is assigned to one.
ModEvent narrow_r(Space &home, I &i, bool depends=true)
Replace domain by ranges described by i.
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
const Gecode::ModEvent ME_BOOL_VAL
Domain operation has resulted in a value (assigned variable)