Go to the documentation of this file.
38 namespace Gecode {
namespace Int {
45 #define GECODE_INT_RL2PD(r) reinterpret_cast<ptrdiff_t>(r)
46 #define GECODE_INT_PD2RL(p) reinterpret_cast<RangeList*>(p)
107 return static_cast<unsigned int>(
_max -
_min) + 1;
112 IntVarImp::RangeList::operator
delete(
void*) {}
115 IntVarImp::RangeList::operator
delete(
void*,
Space&) {
119 IntVarImp::RangeList::operator
delete(
void*,
void*) {
124 IntVarImp::RangeList::operator
new(size_t,
Space& home) {
125 return home.fl_alloc<
sizeof(
RangeList)>();
129 IntVarImp::RangeList::operator
new(size_t,
void*
p) {
154 #undef GECODE_INT_RL2PD
155 #undef GECODE_INT_PD2RL
199 unsigned int h =
static_cast<unsigned int>(
d.
max()-
d.
min())+1;
202 r[0].prevnext(NULL,&
r[1]);
203 for (
int i = 1;
i <
n-1;
i++) {
206 r[
i].prevnext(&
r[
i-1],&
r[
i+1]);
210 r[
n-1].prevnext(&
r[
n-2],NULL);
239 return fst() == NULL;
289 return (
fst() == NULL) || in_full(
n);
295 return (
fst() == NULL) || in_full(
static_cast<int>(
n));
399 int n =
static_cast<int>(m);
411 return nq_full(home,
n);
417 return nq_full(home,
static_cast<int>(
d));
430 :
p(NULL),
c(
x->ranges_fwd()) {}
433 p=NULL; c=
x->ranges_fwd();
468 :
n(NULL),
c(
x->ranges_bwd()) {}
471 n=NULL; c=
x->ranges_bwd();
524 if ((min0 == min1) && (max0 == max1))
530 if (depends ||
range()) {
534 unsigned int s =
static_cast<unsigned int>(max0-min0+1);
560 f.prevnext(NULL,
fst());
l.prevnext(
lst(),NULL);
571 assert((
r != &
f) && (
r != &
l));
572 if (
r->max() < min0) {
576 p->next(
r,
n);
n->prev(
r,
p);
581 }
else if ((
r->min() == min0) && (
r->max() == max0)) {
588 min0=ri.min(); max0=ri.max(); ++ri;
591 assert((
r->min() <= min0) && (max0 <= r->
max()));
595 r->min(min0);
r->max(max0);
596 assert(h >
r->width());
604 min0=ri.min(); max0=ri.max(); ++ri;
607 assert(h >
static_cast<unsigned int>(max0-min0+1));
610 p->next(
r,
n);
r->prev(
p,
n);
623 p->next(
r,
n);
n->prev(
r,
p);
628 assert((
r == &
l) && !ri());
645 unsigned int b = (
static_cast<unsigned int>(fn->
min()-
dom.
min()) +
646 static_cast<unsigned int>(
dom.
max()-ln->
max()));
686 while (
i() && (
i.max() <
dom.
min()))
701 return lq(home,i_min-1);
705 return gq(home,i_max+1);
713 f.prevnext(NULL,
n);
l.prevnext(
n,NULL);
716 f.prevnext(NULL,
fst());
l.prevnext(
lst(),NULL);
728 assert((
r != &
f) && (
r != &
l));
729 if (i_min >
r->max()) {
733 }
else if (i_max < r->
min()) {
739 }
else if ((i_min <= r->
min()) && (
r->max() <= i_max)) {
743 p->next(
r,
n);
n->prev(
r,
p);
748 }
else if ((i_min >
r->min()) && (i_max < r->
max())) {
750 h +=
static_cast<unsigned int>(i_max - i_min) + 1;
753 p->next(
r,
n);
r->prev(
p,
n);
760 }
else if (i_max < r->
max()) {
761 assert(i_min <= r->
min());
763 h += i_max-
r->min()+1;
771 assert((i_max >=
r->max()) && (
r->min() < i_min));
773 h +=
r->max()-i_min+1;
810 b = (
static_cast<unsigned int>(fn->
min()-
dom.
min()) +
811 static_cast<unsigned int>(
dom.
max()-ln->
max()));
856 while (
i() && (
i.val() <
dom.
min()))
867 }
while (
i() && (
i.val() ==
v));
871 return nq_full(home,
v);
879 f.prevnext(NULL,
n);
l.prevnext(
n,NULL);
882 f.prevnext(NULL,
fst());
l.prevnext(
lst(),NULL);
894 assert((
r != &
f) && (
r != &
l));
901 if ((
v ==
r->min()) && (
v ==
r->max())) {
905 p->next(
r,
n);
n->prev(
r,
p);
910 }
else if (
v ==
r->min()) {
912 }
else if (
v ==
r->max()) {
917 }
else if (
v >
r->min()) {
919 assert(v < r->
max());
923 p->next(
r,
n);
r->prev(
p,
n);
932 assert((
r == &
l) || !
i());
964 unsigned int b = (
static_cast<unsigned int>(fn->
min()-
dom.
min()) +
965 static_cast<unsigned int>(
dom.
max()-ln->
max()));
993 : perform_copy(home);
FreeList * _next
Pointer to next freelist object.
int max(void) const
Return maximum.
ModEvent nq(Space &home, int n)
Restrict domain values to be different from n.
Post propagator for SetVar x
int min(int i) const
Return minimum of range at position i.
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 informatio...
bool in(int n) const
Test whether n is contained in domain.
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
RangeList * lst(void) const
Return last element of rangelist.
int min(void) const
Return minimum of domain.
void dispose(Space &home, RangeList *p, RangeList *l)
Free memory for all elements between this and l (inclusive)
RangeList(void)
Default constructor (noop)
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void fix(RangeList *n)
Restore simple link to next element (so that it becomes a true free list)
const Gecode::ModEvent ME_INT_FAILED
Domain operation has resulted in failure.
int max(int i) const
Return maximum of range at position i.
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
void prevnext(RangeList *p, RangeList *n)
Set previous element to p and next element to n.
ModEvent fail(Space &home)
Run advisors to be run on failure and returns ME_GEN_FAILED.
bool range(void) const
Test whether domain is a range.
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Range iterator for ranges of integer variable implementation.
#define GECODE_INT_RL2PD(r)
const Gecode::ModEvent ME_INT_NONE
Domain operation has not changed domain.
bool operator()(void) const
Test whether iterator is still at a range or done.
int min(void) const
Return smallest value of range.
const RangeList * ranges_fwd(void) const
Return range list for forward iteration.
const RangeList * ranges_bwd(void) const
Return range list for backward iteration.
RangeList * _lst
Link the last element.
IntVarImpFwd(void)
Default constructor.
bool assigned(void) const
Test whether variable is assigned.
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)
Integer variable implementation.
RangeList * next(const RangeList *p) const
Return next element (from previous p)
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
int med(void) const
Return median of domain (greatest element not greater than the median)
int val(void) const
Return assigned value (only if assigned)
void fl_dispose(FreeList *f, FreeList *l)
Return freelist-managed memory to freelist.
Gecode toplevel namespace
void init(const IntVarImp *x)
Initialize with ranges from variable implementation x.
RangeList * fst(void) const
Return first element of rangelist.
RangeList * prev(const RangeList *n) const
Return previous element (from next n)
void operator++(void)
Move iterator to previous range (if possible)
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
Base-class for Int-variable implementations.
IntVarImpBwd(void)
Default constructor.
Generic domain change information to be supplied to advisors.
VarImp * forward(void) const
Use forward pointer if variable already copied.
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
FreeList * next(void) const
Return next freelist object.
#define GECODE_INT_PD2RL(p)
Range iterator from value iterator.
const Gecode::ModEvent ME_INT_BND
Domain operation has changed the minimum or maximum of the domain.
Range iterator for computing intersection (binary)
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Post propagator for SetVar SetOpType SetVar SetRelType r
Range iterator for computing set difference.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
ModEvent inter_r(Space &home, I &i, bool depends=true)
Intersect domain with ranges described by i.
ModEvent inter_v(Space &home, I &i, bool depends=true)
Intersect domain with values described by i.
unsigned int holes
Size of holes in the domain.
int max(void) const
Return largest value of range.
IntVarImp * copy(Space &home)
Return copy of this variable.
#define GECODE_NEVER
Assert that this command is never executed.
int ModEvent
Type for modification events.
RangeList dom
Domain information.
ModEvent narrow_v(Space &home, I &i, bool depends=true)
Replace domain by values described by i.
int max(void) const
Return largest value of range.
unsigned int size(void) const
Return size (cardinality) of domain.
unsigned int width(void) const
Return width (distance between maximum and minimum)
static bool any(const Delta &d)
Test whether arbitrary values got pruned.
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.
Integer delta information for advisors.
void operator++(void)
Move iterator to next range (if possible)
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.
void init(const IntVarImp *x)
Initialize with ranges from variable implementation x.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Gecode::FloatVal c(-8, 8)
bool copied(void) const
Is variable already copied.
int n
Number of negative literals for node type.
unsigned int width(int i) const
Return width of range at position i.
int ModEventDelta
Modification event deltas.
Gecode::IntArgs i({1, 2, 3, 4})
int min(void) const
Return minimum.
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
ModEvent narrow_r(Space &home, I &i, bool depends=true)
Replace domain by ranges described by i.
int min(void) const
Return smallest value of range.
Lists of ranges (intervals)
int p
Number of positive literals for node type.
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
bool operator()(void) const
Test whether iterator is still at a range or done.
IntVarImp(Space &home, IntVarImp &x)
Constructor for cloning x.
int max(void) const
Return maximum of domain.
int ranges(void) const
Return number of ranges of the specification.
#define GECODE_ASSUME(p)
Assert certain property.