39 IntVarImp::closer_min(
int n)
const {
40 unsigned int l =
static_cast<unsigned int>(n -
dom.min());
41 unsigned int r =
static_cast<unsigned int>(
dom.max() - n);
49 return (
dom.min()+
dom.max())/2 - ((
dom.min()+
dom.max())%2 < 0 ? 1 : 0);
50 unsigned int i =
size() / 2;
55 while (i >= c->width()) {
59 return c->
min() +
static_cast<int>(i);
63 IntVarImp::in_full(
int m)
const {
67 while (m > c->
max()) {
70 return (m >= c->
min());
72 const RangeList* n = NULL;
73 const RangeList* c =
lst();
74 while (m < c->
min()) {
75 const RangeList* p=c->prev(n); n=c; c=p;
77 return (m <= c->
max());
87 IntVarImp::lq_full(Space& home,
int m) {
88 assert((m >=
dom.min()) && (m <=
dom.max()));
89 int old_max =
dom.max();
103 while (m < c->
min()) {
105 h += (
c->
min() - p->
max() - 1);
109 int max_c = std::min(m,
c->
max());
112 n->dispose(home,
lst());
113 c->next(n,NULL);
lst(c);
116 IntDelta
d(
dom.max()+1,old_max);
121 IntVarImp::gq_full(Space& home,
int m) {
122 assert((m >=
dom.min()) && (m <=
dom.max()));
123 int old_min =
dom.min();
128 }
else if (m >
lst()->prev(NULL)->
max()) {
137 while (m >
c->
max()) {
139 h += (n->min() -
c->
max() - 1);
143 int min_c = std::max(m,
c->
min());
147 c->prev(p,NULL);
fst(c);
150 IntDelta
d(old_min,
dom.min()-1);
155 IntVarImp::eq_full(Space& home,
int m) {
161 while (m >
c->
max()) {
180 IntVarImp::nq_full(Space& home,
int m) {
181 assert(!((m <
dom.min()) || (m >
dom.max())));
184 if ((m ==
dom.min()) && (m ==
dom.max()))
186 if (m ==
dom.min()) {
189 }
else if (m ==
dom.max()) {
203 int f_min =
dom.min();
204 if ((m == f_min) && (m == f_max)) {
206 dom.min(f_next->min());
207 if (f_next ==
lst()) {
213 f_next->prev(
fst(),NULL);
218 }
else if (m == f_min) {
221 }
else if (m == f_max) {
226 f->prevnext(NULL,
fst());
230 }
else if (m >
lst()->prev(NULL)->
max()) {
234 int l_max =
dom.max();
235 if ((m == l_min) && (m == l_max)) {
237 dom.max(l_prev->max());
238 if (l_prev ==
fst()) {
240 l_prev->dispose(home,
lst());
244 l_prev->next(
lst(),NULL);
249 }
else if (m == l_max) {
252 }
else if (m == l_min) {
269 n=
c->next(p); p=
c;
c=n;
270 }
while (m >
c->
max());
279 p=
c->prev(n); n=
c;
c=p;
280 }
while (m < c->
min());
285 assert((
fst() != c) && (
lst() != c));
286 assert((m >=
c->
min()) && (m <= c->
max()));
288 int c_min =
c->
min();
289 int c_max =
c->
max();
290 if ((c_min == m) && (c_max == m)) {
292 p->next(c,n); n->prev(c,p);
293 }
else if (c_min == m) {
329 }
while (s_c != NULL);
333 d_c->
min(
x.fst()->min());
334 d_c->
max(
x.fst()->max());
345 }
while (s_c != NULL);
346 d_c->
next(NULL,NULL);
353 IntVarImp::perform_copy(
Space& home) {
friend FloatVal max(const FloatVal &x, const FloatVal &y)
friend FloatVal min(const FloatVal &x, const FloatVal &y)
void subscribe(Gecode::Space &home, Gecode::Propagator &p, Gecode::PropCond pc, bool assigned, bool schedule)
Subscribe propagator p with propagation condition pc.
static void schedule(Gecode::Space &home, Gecode::Propagator &p, Gecode::ModEvent me)
Schedule propagator p.
IntVarImpBase(Gecode::Space &home, IntVarImpBase &x)
Constructor for cloning x.
void reschedule(Gecode::Space &home, Gecode::Propagator &p, Gecode::PropCond pc, bool assigned)
Re-schedule propagator p.
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...
Lists of ranges (intervals)
int min(void) const
Return minimum.
void prevnext(RangeList *p, RangeList *n)
Set previous element to p and next element to n.
RangeList * prev(const RangeList *n) const
Return previous element (from next n)
RangeList * next(const RangeList *p) const
Return next element (from previous p)
int max(void) const
Return maximum.
void dispose(Space &home, RangeList *p, RangeList *l)
Free memory for all elements between this and l (inclusive)
Integer variable implementation.
RangeList * lst(void) const
Return last element of rangelist.
int med(void) const
Return median of domain (greatest element not greater than the median)
bool assigned(void) const
Test whether variable is assigned.
int max(void) const
Return maximum of domain.
RangeList * fst(void) const
Return first element of rangelist.
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to variable.
unsigned int size(void) const
Return size (cardinality) of domain.
int min(void) const
Return minimum of domain.
RangeList dom
Domain information.
unsigned int holes
Size of holes in the domain.
bool range(void) const
Test whether domain is a range.
IntVarImp(Space &home, IntVarImp &x)
Constructor for cloning x.
void reschedule(Space &home, Propagator &p, PropCond pc)
Re-schedule propagator p.
Base-class for propagators.
Lists of ranges (intervals)
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
ModEvent fail(Space &home)
static ModEvent me(const ModEventDelta &med)
VarImp< Gecode::Int::IntVarImpConf > * next
const Gecode::ModEvent ME_INT_BND
Domain operation has changed the minimum or maximum of the domain.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
const Gecode::ModEvent ME_INT_NONE
Domain operation has not changed domain.
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
int PropCond
Type for propagation conditions.
Post propagator for SetVar x
int ModEvent
Type for modification events.
Gecode::FloatVal c(-8, 8)