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;
203 for (
int i = 1;
i < n-1;
i++) {
239 return fst() == NULL;
289 return (
fst() == NULL) || in_full(n);
295 return (
fst() == NULL) || in_full(static_cast<int>(n));
357 ModEvent me = gq_full(home,static_cast<int>(n));
378 ModEvent me = lq_full(home,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));
468 :
n(NULL), c(x->ranges_bwd()) {}
519 fst()->dispose(home,NULL,lst());
520 fst(NULL); holes = 0;
522 const int min1 =
dom.min();
dom.min(min0);
523 const int max1 =
dom.max();
dom.max(max0);
524 if ((min0 == min1) && (max0 == max1))
530 if (depends ||
range()) {
534 unsigned int s =
static_cast<unsigned int>(max0-min0+1);
543 fst()->dispose(home,NULL,lst());
550 const int min1 =
dom.min(); min0 = f->
min();
dom.min(min0);
551 const int max1 =
dom.max(); max0 = l->
max();
dom.max(max0);
561 fst()->prev(NULL,&f); lst()->next(NULL,&l);
571 assert((r != &f) && (r != &l));
572 if (r->
max() < min0) {
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));
628 assert((r == &l) && !ri());
643 fn->
prev(&f,NULL); ln->
next(&l,NULL);
645 unsigned int b = (
static_cast<unsigned int>(fn->
min()-
dom.min()) +
646 static_cast<unsigned int>(
dom.max()-ln->
max()));
651 assert((
dom.min() != fn->
min()) || (
dom.max() != ln->
max()));
658 assert((
dom.min() == fn->
min()) && (
dom.max() == ln->
max()));
665 return notify(home,me,d);
673 return narrow_r(home,ij,
true);
682 return narrow_r(home,ij,
true);
686 while (
i() && (i.max() <
dom.min()))
690 if (!
i() || (i.min() >
dom.max()))
697 if ((i_min <=
dom.min()) && (i_max >=
dom.max()))
700 if ((i_min >
dom.min()) && (i_max >=
dom.max()))
701 return lq(home,i_min-1);
703 if ((i_min <=
dom.min()) && (i_max <
dom.max()) &&
704 (!
i() || (i.min() >
dom.max())))
705 return gq(home,i_max+1);
717 fst()->prev(NULL,&f); lst()->next(NULL,&l);
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)) {
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;
787 fst(NULL); lst(NULL); holes=0;
799 fst(NULL); lst(NULL);
808 fn->
prev(&f,NULL); ln->
next(&l,NULL);
810 b = (
static_cast<unsigned int>(fn->
min()-
dom.min()) +
811 static_cast<unsigned int>(
dom.max()-ln->
max()));
816 assert((
dom.min() != fn->
min()) || (
dom.max() != ln->
max()));
823 assert((
dom.min() == fn->
min()) && (
dom.max() == ln->
max()));
830 return notify(home,me,d);
837 return narrow_r(home,r,depends);
844 return inter_r(home,r,depends);
852 return minus_r(home, r,
true);
856 while (
i() && (i.val() <
dom.min()))
860 if (!
i() || (i.val() >
dom.max()))
867 }
while (
i() && (i.val() ==
v));
870 if (!
i() || (i.val() >
dom.max()))
871 return nq_full(home,v);
883 fst()->prev(NULL,&f); lst()->next(NULL,&l);
894 assert((r != &f) && (r != &l));
901 if ((v == r->
min()) && (v == r->
max())) {
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());
940 fst(NULL); lst(NULL); holes=0;
951 fst(NULL); lst(NULL);
962 fn->
prev(&f,NULL); ln->
next(&l,NULL);
964 unsigned int b = (
static_cast<unsigned int>(fn->
min()-
dom.min()) +
965 static_cast<unsigned int>(
dom.max()-ln->
max()));
970 assert((
dom.min() != fn->
min()) || (
dom.max() != ln->
max()));
977 assert((
dom.min() == fn->
min()) && (
dom.max() == ln->
max()));
992 return copied() ?
static_cast<IntVarImp*
>(forward())
993 : perform_copy(home);
ModEvent nq(Space &home, int n)
Restrict domain values to be different from n.
RangeList * next(const RangeList *p) const
Return next element (from previous p)
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
int min(void) const
Return minimum.
int min(void) const
Return minimum of domain.
IntVarImp(Space &home, IntVarImp &x)
Constructor for cloning x.
void dispose(Space &home, RangeList *p, RangeList *l)
Free memory for all elements between this and l (inclusive)
#define GECODE_ASSUME(p)
Assert certain property.
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
bool range(void) const
Test whether domain is a range.
void fix(RangeList *n)
Restore simple link to next element (so that it becomes a true free list)
RangeList * prev(const RangeList *n) const
Return previous element (from next n)
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_bwd(void) const
Return range list for backward iteration.
FreeList * next(void) const
Return next freelist object.
RangeList * _lst
Link the last element.
unsigned int width(int i) const
Return width of range at position i.
bool in(int n) const
Test whether n is contained in domain.
RangeList * lst(void) const
Return last element of rangelist.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
int ModEvent
Type for modification events.
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
IntVarImpFwd(void)
Default constructor.
static ModEventDelta med(ModEvent me)
Translate modification event me into modification event delta.
Base-class for Int-variable implementations.
int min(int i) const
Return minimum of range at position i.
void init(const IntVarImp *x)
Initialize with ranges from variable implementation x.
const RangeList * ranges_fwd(void) const
Return range list for forward iteration.
int med(void) const
Return median of domain (greatest element not greater than the median)
RangeList(void)
Default constructor (noop)
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
const Gecode::ModEvent ME_INT_FAILED
Domain operation has resulted in failure.
int val(void) const
Return assigned value (only if assigned)
IntVarImpBwd(void)
Default constructor.
Gecode::FloatVal c(-8, 8)
int _max
Maximum of range.
int p
Number of positive literals for node type.
bool assigned(void) const
Test whether variable is assigned.
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
int n
Number of negative literals for node type.
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value)
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Gecode::IntArgs i({1, 2, 3, 4})
static ModEvent me(const ModEventDelta &med)
Project modification event for this variable type from med.
int max(void) const
Return maximum.
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value)
Range iterator for computing intersection (binary)
void operator++(void)
Move iterator to previous range (if possible)
int max(int i) const
Return maximum of range at position i.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
struct Gecode::@593::NNF::@62::@63 b
For binary nodes (and, or, eqv)
Range iterator from value iterator.
RangeList * fst(void) const
Return first element of rangelist.
unsigned int size(I &i)
Size of all ranges of range iterator i.
void range(Home home, const IntVarArgs &x, SetVar y, SetVar z)
Post constraint .
Range iterator for ranges of integer variable implementation.
const Gecode::ModEvent ME_INT_BND
Domain operation has changed the minimum or maximum of the domain.
FreeList * _next
Pointer to next freelist object.
unsigned int width(void) const
Return width (distance between maximum and minimum)
ModEvent inter_r(Space &home, I &i, bool depends=true)
Intersect domain with ranges described by i.
#define GECODE_INT_PD2RL(p)
unsigned int holes
Size of holes in the domain.
ModEvent minus_v(Space &home, I &i, bool depends=true)
Remove from domain the values described by i.
Post propagator for SetVar SetOpType SetVar SetRelType r
ModEvent narrow_v(Space &home, I &i, bool depends=true)
Replace domain by values described by i.
Integer delta information for advisors.
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
int max(void) const
Return largest value of range.
Integer variable implementation.
RangeList dom
Domain information.
ModEvent inter_v(Space &home, I &i, bool depends=true)
Intersect domain with values described by i.
Generic domain change information to be supplied to advisors.
Lists of ranges (intervals)
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
void operator++(void)
Move iterator to next range (if possible)
IntVarImp * copy(Space &home)
Return copy of this variable.
bool assigned(View x, int v)
Whether x is assigned to value v.
int max(void) const
Return largest value of range.
void prevnext(RangeList *p, RangeList *n)
Set previous element to p and next element to n.
ModEvent minus_r(Space &home, I &i, bool depends=true)
Remove from domain the ranges described by i.
ModEvent fail(Space &home)
Run advisors to be run on failure and returns ME_GEN_FAILED.
void fl_dispose(FreeList *f, FreeList *l)
Return freelist-managed memory to freelist.
Post propagator for SetVar x
unsigned int size(void) const
Return size (cardinality) of domain.
int ranges(void) const
Return number of ranges of the specification.
static bool any(const Delta &d)
Test whether arbitrary values got pruned.
Gecode toplevel namespace
Range iterator for computing set difference.
int min(void) const
Return smallest value of range.
int _min
Minimum of range.
void init(const IntVarImp *x)
Initialize with ranges from variable implementation x.
bool operator()(void) const
Test whether iterator is still at a range or done.
int ModEventDelta
Modification event deltas.
ModEvent narrow_r(Space &home, I &i, bool depends=true)
Replace domain by ranges described by i.
#define GECODE_NEVER
Assert that this command is never executed.
const Gecode::ModEvent ME_INT_NONE
Domain operation has not changed domain.
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
#define GECODE_INT_RL2PD(r)
int max(void) const
Return maximum of domain.