40 namespace Gecode {
namespace Int {
43 IntVarImp::closer_min(
int n)
const {
44 unsigned int l =
static_cast<unsigned int>(n -
dom.
min());
45 unsigned int r =
static_cast<unsigned int>(
dom.
max() -
n);
54 unsigned int i =
size() / 2;
59 while (i >= c->
width()) {
63 return c->
min() +
static_cast<int>(
i);
67 IntVarImp::in_full(
int m)
const {
71 while (m > c->
max()) {
74 return (m >= c->
min());
76 const RangeList* n = NULL;
77 const RangeList* c =
lst();
78 while (m < c->
min()) {
79 const RangeList* p=c->prev(n); n=
c; c=
p;
81 return (m <= c->
max());
91 IntVarImp::lq_full(Space& home,
int m) {
105 RangeList* c =
lst();
107 while (m < c->
min()) {
108 RangeList* p = c->prev(n); c->fix(n);
109 h += (c->min() - p->max() - 1);
114 dom.
max(max_c); c->max(max_c);
116 n->dispose(home,
lst());
117 c->next(n,NULL);
lst(c);
124 IntVarImp::gq_full(Space& home,
int m) {
131 }
else if (m >
lst()->prev(NULL)->
max()) {
138 RangeList* c =
fst();
140 while (m > c->max()) {
141 RangeList* n = c->next(p); c->fix(n);
142 h += (n->min() - c->max() - 1);
147 dom.
min(min_c); c->min(min_c);
150 c->prev(p,NULL);
fst(c);
157 IntVarImp::eq_full(Space& home,
int m) {
162 RangeList* c =
fst();
163 while (m > c->max()) {
164 RangeList* n=c->next(p); c->fix(n); p=
c; c=
n;
169 RangeList* n=c->next(p); c->fix(n); p=
c; c=
n;
182 IntVarImp::nq_full(Space& home,
int m) {
191 }
else if (m ==
dom.
max()) {
195 RangeList* f =
new (home) RangeList(
dom.
min(),m-1);
196 RangeList* l =
new (home) RangeList(m+1,
dom.
max());
206 if ((m == f_min) && (m == f_max)) {
207 RangeList* f_next =
fst()->
next(NULL);
209 if (f_next ==
lst()) {
215 f_next->prev(
fst(),NULL);
220 }
else if (m == f_min) {
223 }
else if (m == f_max) {
227 RangeList* f =
new (home) RangeList(f_min,m-1);
228 f->prevnext(NULL,
fst());
232 }
else if (m >
lst()->prev(NULL)->
max()) {
237 if ((m == l_min) && (m == l_max)) {
238 RangeList* l_prev =
lst()->
prev(NULL);
240 if (l_prev ==
fst()) {
242 l_prev->dispose(home,
lst());
246 l_prev->next(
lst(),NULL);
251 }
else if (m == l_max) {
254 }
else if (m == l_min) {
257 RangeList* l =
new (home) RangeList(m+1,l_max);
258 l->prevnext(
lst(),NULL);
271 n=c->next(p); p=
c; c=
n;
272 }
while (m > c->max());
281 p=c->prev(n); n=
c; c=
p;
282 }
while (m < c->
min());
287 assert((
fst() != c) && (
lst() != c));
288 assert((m >= c->min()) && (m <= c->
max()));
290 int c_min = c->min();
291 int c_max = c->max();
292 if ((c_min == m) && (c_max == m)) {
294 p->next(c,n); n->prev(c,p);
295 }
else if (c_min == m) {
300 RangeList* l =
new (home) RangeList(m+1,c_max);
331 }
while (s_c != NULL);
347 }
while (s_c != NULL);
348 d_c->
next(NULL,NULL);
355 IntVarImp::perform_copy(
Space& home,
bool share) {
356 return new (home)
IntVarImp(home,share,*
this);
unsigned int size(void) const
Return size (cardinality) of domain.
void dispose(Space &home, RangeList *p, RangeList *l)
Free memory for all elements between this and l (inclusive)
int min(void) const
Return minimum.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
int ModEvent
Type for modification events.
int min(void) const
Return minimum.
Base-class for Int-variable implementations.
RangeList * lst(void) const
Return last element of rangelist.
int max(void) const
Return maximum.
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.
Gecode::FloatVal c(-8, 8)
void max(Home home, SetVar s, IntVar x, Reify r)
Post reified propagator for b iff x is the maximal element of s.
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.
bool assigned(void) const
Test whether variable is assigned.
static ModEvent me(const ModEventDelta &med)
Project modification event for this variable type from med.
bool range(void) const
Test whether domain is a range.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
int max(void) const
Return maximum.
RangeList * next(void) const
Return next element.
const Gecode::ModEvent ME_INT_BND
Domain operation has changed the minimum or maximum of the domain.
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...
RangeList * prev(const RangeList *n) const
Return previous element (from next n)
unsigned int holes
Size of holes in the domain.
void min(Home home, SetVar s, IntVar x, Reify r)
Post reified propagator for b iff x is the minimal element of s.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Integer variable implementation.
RangeList dom
Domain information.
IntVarImp(Space &home, bool share, IntVarImp &x)
Constructor for cloning x.
Node * x
Pointer to corresponding Boolean expression node.
Lists of ranges (intervals)
VarImp * next(void) const
Return next copied variable.
int max(void) const
Return maximum of domain.
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
unsigned int width(void) const
Return width (distance between maximum and minimum)
void prevnext(RangeList *p, RangeList *n)
Set previous element to p and next element to n.
RangeList * next(const RangeList *p) const
Return next element (from previous p)
int med(void) const
Return median of domain (greatest element not greater than the median)
Lists of ranges (intervals)
Gecode toplevel namespace
int min(void) const
Return minimum of domain.
const Gecode::ModEvent ME_INT_NONE
Domain operation has not changed domain.
RangeList * fst(void) const
Return first element of rangelist.