43 IntVarImp::closer_min(
int n)
const {
44 unsigned int l =
static_cast<unsigned int>(n) -
45 static_cast<unsigned int>(
dom.min());
46 unsigned int r =
static_cast<unsigned int>(
dom.max()) -
47 static_cast<unsigned int>(n);
55 return (
dom.min()+
dom.max())/2 - ((
dom.min()+
dom.max())%2 < 0 ? 1 : 0);
56 unsigned int i =
size() / 2;
61 while (i >= c->width()) {
65 return c->min() +
static_cast<int>(i);
69 IntVarImp::in_full(
int m)
const {
73 while (m > c->max()) {
76 return (m >= c->min());
78 const RangeList* n =
nullptr;
79 const RangeList* c =
lst();
80 while (m < c->
min()) {
81 const RangeList* p=c->prev(n); n=c; c=p;
83 return (m <= c->
max());
93 IntVarImp::lq_full(Space& home,
int m) {
94 assert((m >=
dom.min()) && (m <=
dom.max()));
95 int old_max =
dom.max();
109 while (m < c->
min()) {
111 h +=
static_cast<unsigned int>(
c->min()) -
112 static_cast<unsigned int>(p->max()) - 1U;
116 int max_c = std::min(m,
c->max());
117 dom.max(max_c);
c->max(max_c);
119 n->dispose(home,
lst());
120 c->next(n,
nullptr);
lst(c);
123 IntDelta
d(
dom.max()+1,old_max);
128 IntVarImp::gq_full(Space& home,
int m) {
129 assert((m >=
dom.min()) && (m <=
dom.max()));
130 int old_min =
dom.min();
135 }
else if (m >
lst()->prev(
nullptr)->
max()) {
144 while (m >
c->max()) {
146 h +=
static_cast<unsigned int>(n->min()) -
147 static_cast<unsigned int>(
c->max()) - 1U;
151 int min_c = std::max(m,
c->min());
152 dom.min(min_c);
c->min(min_c);
155 c->prev(p,
nullptr);
fst(c);
158 IntDelta
d(old_min,
dom.min()-1);
163 IntVarImp::eq_full(Space& home,
int m) {
169 while (m >
c->max()) {
174 while (c !=
nullptr) {
188 IntVarImp::nq_full(Space& home,
int m) {
189 assert(!((m <
dom.min()) || (m >
dom.max())));
192 if ((m ==
dom.min()) && (m ==
dom.max()))
194 if (m ==
dom.min()) {
197 }
else if (m ==
dom.max()) {
203 f->prevnext(
nullptr,l);
204 l->prevnext(f,
nullptr);
211 int f_min =
dom.min();
212 if ((m == f_min) && (m == f_max)) {
214 dom.min(f_next->min());
215 if (f_next ==
lst()) {
221 f_next->prev(
fst(),
nullptr);
223 holes -=
static_cast<unsigned int>(
dom.min()) -
224 static_cast<unsigned int>(f_min) - 1U;
227 }
else if (m == f_min) {
230 }
else if (m == f_max) {
235 f->prevnext(
nullptr,
fst());
239 }
else if (m >
lst()->prev(
nullptr)->
max()) {
243 int l_max =
dom.max();
244 if ((m == l_min) && (m == l_max)) {
246 dom.max(l_prev->max());
247 if (l_prev ==
fst()) {
249 l_prev->dispose(home,
lst());
253 l_prev->next(
lst(),
nullptr);
255 holes -=
static_cast<unsigned int>(l_max) -
256 static_cast<unsigned int>(
dom.max()) - 1U;
259 }
else if (m == l_max) {
262 }
else if (m == l_min) {
279 n=
c->next(p); p=
c;
c=n;
280 }
while (m >
c->max());
289 p=
c->prev(n); n=
c;
c=p;
290 }
while (m < c->
min());
295 assert((
fst() != c) && (
lst() != c));
296 assert((m >=
c->min()) && (m <= c->
max()));
298 int c_min =
c->min();
299 int c_max =
c->max();
300 if ((c_min == m) && (c_max == m)) {
302 p->next(c,n); n->prev(c,p);
303 }
else if (c_min == m) {
339 }
while (s_c !=
nullptr);
350 d_c->
next(
nullptr,d_n);
355 }
while (s_c !=
nullptr);
356 d_c->
next(
nullptr,
nullptr);
363 IntVarImp::perform_copy(
Space& home) {
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
int PropCond
Type for propagation conditions.
int ModEvent
Type for modification events.