42 namespace Gecode {
namespace Int {
49 #define GECODE_INT_RL2PD(r) reinterpret_cast<ptrdiff_t>(r) 50 #define GECODE_INT_PD2RL(p) reinterpret_cast<RangeList*>(p) 111 return static_cast<unsigned int>(
_max -
_min) + 1;
116 IntVarImp::RangeList::operator
delete(
void*) {}
119 IntVarImp::RangeList::operator
delete(
void*,
Space&) {
123 IntVarImp::RangeList::operator
delete(
void*,
void*) {
128 IntVarImp::RangeList::operator
new(size_t,
Space& home) {
129 return home.fl_alloc<
sizeof(
RangeList)>();
133 IntVarImp::RangeList::operator
new(size_t,
void*
p) {
158 #undef GECODE_INT_RL2PD 159 #undef GECODE_INT_PD2RL 203 unsigned int h =
static_cast<unsigned int>(d.
max()-d.
min())+1;
207 for (
int i = 1;
i < n-1;
i++) {
243 return fst() == NULL;
293 return (
fst() == NULL) || in_full(n);
299 return (
fst() == NULL) || in_full(static_cast<int>(n));
361 ModEvent me = gq_full(home,static_cast<int>(n));
382 ModEvent me = lq_full(home,static_cast<int>(n));
403 int n =
static_cast<int>(m);
415 return nq_full(home,n);
421 return nq_full(home,static_cast<int>(d));
472 :
n(NULL), c(x->ranges_bwd()) {}
523 fst()->dispose(home,NULL,lst());
524 fst(NULL); holes = 0;
526 const int min1 =
dom.min();
dom.min(min0);
527 const int max1 =
dom.max();
dom.max(max0);
528 if ((min0 == min1) && (max0 == max1))
534 if (depends ||
range()) {
538 unsigned int s =
static_cast<unsigned int>(max0-min0+1);
547 fst()->dispose(home,NULL,lst());
554 const int min1 =
dom.min(); min0 = f->
min();
dom.min(min0);
555 const int max1 =
dom.max(); max0 = l->
max();
dom.max(max0);
565 fst()->prev(NULL,&f); lst()->next(NULL,&l);
575 assert((r != &f) && (r != &l));
576 if (r->
max() < min0) {
585 }
else if ((r->
min() == min0) && (r->
max() == max0)) {
592 min0=ri.
min(); max0=ri.max(); ++ri;
595 assert((r->
min() <= min0) && (max0 <= r->
max()));
599 r->
min(min0); r->
max(max0);
600 assert(h > r->
width());
608 min0=ri.
min(); max0=ri.max(); ++ri;
611 assert(h > static_cast<unsigned int>(max0-min0+1));
632 assert((r == &l) && !ri());
647 fn->
prev(&f,NULL); ln->
next(&l,NULL);
649 unsigned int b = (
static_cast<unsigned int>(fn->
min()-
dom.min()) +
650 static_cast<unsigned int>(
dom.max()-ln->
max()));
655 assert((
dom.min() != fn->
min()) || (
dom.max() != ln->
max()));
662 assert((
dom.min() == fn->
min()) && (
dom.max() == ln->
max()));
669 return notify(home,me,d);
677 return narrow_r(home,ij,
true);
686 return narrow_r(home,ij,
true);
690 while (
i() && (i.max() <
dom.min()))
694 if (!
i() || (i.min() >
dom.max()))
701 if ((i_min <=
dom.min()) && (i_max >=
dom.max()))
704 if ((i_min >
dom.min()) && (i_max >=
dom.max()))
705 return lq(home,i_min-1);
707 if ((i_min <=
dom.min()) && (i_max <
dom.max()) &&
708 (!
i() || (i.min() >
dom.max())))
709 return gq(home,i_max+1);
721 fst()->prev(NULL,&f); lst()->next(NULL,&l);
732 assert((r != &f) && (r != &l));
733 if (i_min > r->
max()) {
737 }
else if (i_max < r->
min()) {
743 }
else if ((i_min <= r->
min()) && (r->
max() <= i_max)) {
752 }
else if ((i_min > r->
min()) && (i_max < r->
max())) {
754 h +=
static_cast<unsigned int>(i_max - i_min) + 1;
757 p->next(r,n); r->
prev(p,n);
764 }
else if (i_max < r->
max()) {
765 assert(i_min <= r->
min());
767 h += i_max-r->
min()+1;
775 assert((i_max >= r->
max()) && (r->
min() < i_min));
777 h += r->
max()-i_min+1;
791 fst(NULL); lst(NULL); holes=0;
803 fst(NULL); lst(NULL);
812 fn->
prev(&f,NULL); ln->
next(&l,NULL);
814 b = (
static_cast<unsigned int>(fn->
min()-
dom.min()) +
815 static_cast<unsigned int>(
dom.max()-ln->
max()));
820 assert((
dom.min() != fn->
min()) || (
dom.max() != ln->
max()));
827 assert((
dom.min() == fn->
min()) && (
dom.max() == ln->
max()));
834 return notify(home,me,d);
841 return narrow_r(home,r,depends);
848 return inter_r(home,r,depends);
856 return minus_r(home, r,
true);
860 while (
i() && (i.val() <
dom.min()))
864 if (!
i() || (i.val() >
dom.max()))
871 }
while (
i() && (i.val() ==
v));
874 if (!
i() || (i.val() >
dom.max()))
875 return nq_full(home,v);
887 fst()->prev(NULL,&f); lst()->next(NULL,&l);
898 assert((r != &f) && (r != &l));
905 if ((v == r->
min()) && (v == r->
max())) {
914 }
else if (v == r->
min()) {
916 }
else if (v == r->
max()) {
921 }
else if (v > r->
min()) {
923 assert(v < r->
max());
927 p->next(r,n); r->
prev(p,n);
936 assert((r == &l) || !
i());
944 fst(NULL); lst(NULL); holes=0;
955 fst(NULL); lst(NULL);
966 fn->
prev(&f,NULL); ln->
next(&l,NULL);
968 unsigned int b = (
static_cast<unsigned int>(fn->
min()-
dom.min()) +
969 static_cast<unsigned int>(
dom.max()-ln->
max()));
974 assert((
dom.min() != fn->
min()) || (
dom.max() != ln->
max()));
981 assert((
dom.min() == fn->
min()) && (
dom.max() == ln->
max()));
996 return copied() ?
static_cast<IntVarImp*
>(forward())
997 : 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.
Gecode::IntArgs i(4, 1, 2, 3, 4)
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)
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)
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.
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
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.