Go to the documentation of this file.
34 namespace Gecode {
namespace Int {
41 BoolVarImp::BoolVarImp(
int n) {
63 return static_cast<int>(
bits() & 1);
67 return static_cast<int>((
bits() & 2) >> 1);
118 return (
n >=
min()) && (
n <=
max());
122 return (
n >=
min()) && (
n <=
max());
154 return static_cast<const IntDelta&>(
d).min();
158 return static_cast<const IntDelta&>(
d).min();
162 return static_cast<const IntDelta&>(
d).width();
170 return static_cast<const IntDelta&>(
d).min() != 0;
174 return static_cast<const IntDelta&>(
d).min() == 0;
203 if (
n > 1)
return fail(home);
209 if (
n > 1)
return fail(home);
215 if (
n < 0)
return fail(home);
221 if (
n < 0)
return fail(home);
228 if ((
n < 0) || (
n > 1))
return fail(home);
229 return (
n == 0) ?
zero(home):
one(home);
233 if ((
n < 0) || (
n > 1))
return fail(home);
234 return (
n == 0) ?
zero(home):
one(home);
240 return (
n == 0) ?
one(home):
zero(home);
245 return (
n == 0) ?
one(home):
zero(home);
260 return static_cast<BoolVarImp*>(
forward());
280 assert((
i.min() == 0) || (
i.min() == 1));
281 assert((
i.max() == 0) || (
i.max() == 1));
299 while (
i() && (
i.max() < 0))
302 if (!
i() || (
i.min() > 1))
304 assert(
i.min() <= 1);
309 assert((
i.min() <= 0) && (
i.max() >= 1));
316 while (
i() && (
i.max() < 0))
319 if (!
i() || (
i.min() > 1))
321 assert(
i.min() <= 1);
326 assert((
i.min() <= 0) && (
i.max() >= 1));
340 }
while (
i() && (
i.val() == 0));
345 assert(
i.val() == 1);
352 while (
i() && (
i.val() < 0))
354 if (!
i() || (
i.val() > 1))
359 }
while (
i() && (
i.val() == 0));
360 if (!
i() || (
i.val() > 1))
364 assert(
i.val() == 1);
371 while (
i() && (
i.val() < 0))
373 if (!
i() || (
i.val() > 1))
378 }
while (
i() && (
i.val() == 0));
379 if (!
i() || (
i.val() > 1))
383 assert(
i.val() == 1);
BoolStatus status(void) const
Return current domain status.
static const BoolStatus NONE
Status of domain not yet assigned.
Post propagator for SetVar x
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
Base-class for Bool-variable implementations.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
bool one(void) const
Test whether variable is assigned to one.
ModEvent fail(Space &home)
Run advisors to be run on failure and returns ME_GEN_FAILED.
const Gecode::ModEvent ME_BOOL_FAILED
Domain operation has resulted in failure.
const Gecode::ModEvent ME_INT_NONE
Domain operation has not changed domain.
bool zero(void) const
Test whether variable is assigned to zero.
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
ModEvent minus_v(Space &home, I &i, bool depends=true)
Remove from domain the values described by i.
ModEvent minus_r(Space &home, I &i, bool depends=true)
Remove from domain the ranges described by i.
unsigned int bits(void) const
Provide access to free bits.
bool assigned(void) const
Test whether variable is assigned.
const Gecode::ModEvent ME_BOOL_VAL
Domain operation has resulted in a value (assigned variable)
ModEvent zero_none(Space &home)
Assign unassigned variable to zero.
unsigned int BoolStatus
Type for status of a Boolean variable.
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
bool range(void) const
Test whether domain is a range.
bool in(int n) const
Test whether n is contained in domain.
Gecode toplevel namespace
Base-class for propagators.
void cancel(Space &home, Propagator &p, PropCond pc)
Cancel subscription of propagator p with propagation condition pc.
static void schedule(Gecode::Space &home, Gecode::Propagator &p, Gecode::ModEvent me)
Schedule propagator p.
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
int max(void) const
Return maximum of domain.
Generic domain change information to be supplied to advisors.
VarImp * forward(void) const
Use forward pointer if variable already copied.
BoolVarImp * copy(Space &home)
Return copy of this variable.
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Boolean variable implementation.
static void schedule(Space &home, Propagator &p, ModEvent me)
Schedule propagator p with modification event me.
static ModEvent modevent(const Delta &d)
Return modification event.
unsigned int size(void) const
Return size (cardinality) of domain.
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
ModEvent inter_r(Space &home, I &i, bool depends=true)
Intersect domain with ranges described by i.
int ModEvent
Type for modification events.
int PropCond
Type for propagation conditions.
ModEvent narrow_r(Space &home, I &i, bool depends=true)
Replace domain by ranges described by i.
ModEvent narrow_v(Space &home, I &i, bool depends=true)
Replace domain by values described by i.
static ModEvent me(const ModEventDelta &med)
Project modification event for this variable type from med.
const Gecode::ModEvent ME_BOOL_NONE
Domain operation has not changed domain.
static ModEventDelta med(ModEvent me)
Translate modification event me into modification event delta.
ModEvent inter_v(Space &home, I &i, bool depends=true)
Intersect domain with values described by i.
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
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)
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
bool copied(void) const
Is variable already copied.
void cancel(Space &home)
Cancel all subscriptions when variable implementation is assigned.
int n
Number of negative literals for node type.
int min(void) const
Return minimum of domain.
int ModEventDelta
Modification event deltas.
bool none(void) const
Test whether variable is not yet assigned.
Gecode::IntArgs i({1, 2, 3, 4})
ModEvent one_none(Space &home)
Assign unassigned variable to one.
static bool any(const Delta &d)
Test whether arbitrary values got pruned.
int p
Number of positive literals for node type.
ModEvent nq(Space &home, int n)
Restrict domain values to be different from n.