40 namespace Gecode {
namespace Int {
namespace Rel {
57 if (!
same(x0,x1) && (x0.max() > x1.min()))
58 (void)
new (home)
Lq<View>(home,x0,x1);
70 return new (home)
Lq<View>(home,share,*
this);
100 if (x0.max() >= x1.min())
101 (
void)
new (home)
Le<View>(home,x0,x1);
113 return new (home)
Le<View>(home,share,*
this);
131 template<
class View,
int o>
137 template<
class View,
int o>
144 template<
class View,
int o>
149 template<
class View,
int o>
155 template<
class View,
int o>
159 template<
class View,
int o>
165 template<
class View,
int o>
168 return home.fl_alloc<
sizeof(
Pos)>();
171 template<
class View,
int o>
178 template<
class View,
int o>
183 template<
class View,
int o>
187 if ((
pos != NULL) && (
pos->
p == p))
191 template<
class View,
int o>
201 template<
class View,
int o>
206 for (
int i=x.
size();
i--; )
210 template<
class View,
int o>
213 assert((o == 0) || (o == 1));
223 for (
int i=0;
i<
n;
i++)
224 for (
int j=n-1; j>
i; j--)
225 if (
same(x[i],x[j])) {
229 for (
int k=j-i; k--; )
233 for (
int k=0; k<n-1-j-1+1; k++)
243 for (
int i=x.
size()-1;
i--;)
250 while ((i+1 < x.
size()) && (x[i].
max()+o <= x[i+1].min()))
257 while ((i > 0) && (x[i-1].
max()+o <= x[i].
min()))
264 for (
int i=1;
i+1<x.
size();
i++)
265 if ((x[j-1].
max()+o > x[
i].
min()) ||
266 (x[
i].max()+o > x[
i+1].min()))
268 x[j++]=x[x.
size()-1];
277 }
else if (x.
size() >= 2) {
283 template<
class View,
int o>
287 pos(NULL), run(false), n_subsumed(p.n_subsumed) {
288 assert(p.
pos == NULL);
289 c.update(home, share, p.
c);
292 template<
class View,
int o>
295 if (n_subsumed > n_threshold) {
300 a.
set(static_cast<unsigned int>(as.advisor().i));
302 int* m = r.
alloc<
int>(
x.size());
304 for (
int i=0;
i<
x.size();
i++)
305 if (a.
get(static_cast<unsigned int>(
i))) {
306 m[
i] = j;
x[j++] =
x[
i];
311 as.advisor().i = m[as.advisor().i];
318 template<
class View,
int o>
324 template<
class View,
int o>
328 x[as.advisor().i].cancel(home,as.advisor());
333 return sizeof(*this);
337 template<
class View,
int o>
342 switch (View::modevent(d)) {
348 if (((i == 0) || (
x[i-1].
max()+o <=
x[i].
min())) &&
349 ((i ==
x.size()-1) || (
x[i].
max()+o <=
x[i+1].min()))) {
361 if (((i <
x.size()-1) && (
x[i+1].
min() <
x[
i].min()+o)) ||
362 ((i > 0) && (
x[i-1].
max() >
x[
i].max()-o))) {
369 template<
class View,
int o>
376 for (
int i=p;
i<n-1;
i++) {
383 for (
int i=p;
i>0;
i--) {
392 for (
int i=0;
i<n-1;
i++)
394 for (
int i=n-1;
i>0;
i--)
397 if (n_subsumed+1 >= n)
410 template<
class View,
class CtrlView, ReifyMode rm>
415 template<
class View,
class CtrlView, ReifyMode rm>
443 }
else if (rm !=
RM_IMP) {
449 template<
class View,
class CtrlView, ReifyMode rm>
454 template<
class View,
class CtrlView, ReifyMode rm>
460 template<
class View,
class CtrlView, ReifyMode rm>
466 }
else if (
b.zero()) {
492 template<
class View,
class CtrlView, ReifyMode rm>
497 template<
class View,
class CtrlView, ReifyMode rm>
503 }
else if (b.zero()) {
526 template<
class View,
class CtrlView, ReifyMode rm>
531 template<
class View,
class CtrlView, ReifyMode rm>
537 template<
class View,
class CtrlView, ReifyMode rm>
543 }
else if (
b.zero()) {
bool get(unsigned int i) const
Access value at bit i.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Relation may hold or not.
Inverse implication for reification.
ExecStatus ES_SUBSUMED(Propagator &p)
Lq(Space &home, bool share, Lq &p)
Constructor for cloning p.
Reified unary propagator.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Pos * next(void) const
Return next position.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
static ExecStatus post(Home home, ViewArray< View > &x)
Post propagator for .
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
int n_subsumed
Number of already subsumed advisors (or views)
Reified binary propagator.
bool pos(const View &x)
Test whether x is postive.
void push(Space &home, int p)
Push a new position p to be propagated.
int ModEvent
Type for modification events.
int p
Position of view in view array.
ViewArray< View > x
Array of views.
Reified less or equal with integer propagator.
Base-class for propagators.
FreeList * next(void) const
Return next freelist object.
Class to iterate over advisors of a council.
Propagation has computed fixpoint.
bool empty(void) const
Whether no more positions must be propagated.
static ExecStatus post(Home home, View x0, View x1)
Post propagator .
ReLq(Space &home, bool share, ReLq &p)
Constructor for cloning p.
Base-class for both propagators and branchers.
bool run
Whether the propagator is currently running.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Reified less or equal propagator.
Index(Space &home, Propagator &p, Council< Index > &c, int i)
Create index advisor.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
bool same(const CachedView< View > &x, const CachedView< View > &y)
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
void drop_lst(int i)
Drop views from positions i+1 to size()-1 from array.
int n
Number of negative literals for node type.
const Gecode::PropCond PC_INT_NONE
Propagation condition to be ignored (convenience)
Execution has resulted in failure.
Council< Index > c
The advisor council.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
void subscribe(Space &home, Propagator &p, IntSet &y)
int pop(Space &home)
Pop a position to be propagated and return it.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Less or equal propagator.
static ExecStatus post(Home home, View x0, View x1)
Post propagator .
static ExecStatus post(Home home, View x, int c, CtrlView b)
Post propagator for .
const Gecode::ModEvent ME_INT_BND
Domain operation has changed the minimum or maximum of the domain.
void set(unsigned int i)
Set bit i.
void drop_fst(int i)
Drop views from positions 0 to i-1 from array.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
n-ary less and less or equal propagator
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
static ExecStatus post(Home home, View x0, View x1, CtrlView b)
Post propagator for .
Node * x
Pointer to corresponding Boolean expression node.
Generic domain change information to be supplied to advisors.
void dispose(Space &home)
Free memory for this position.
ReLqInt(Space &home, bool share, ReLqInt &p)
Constructor for cloning p.
void dispose(Space &home, Council< A > &c)
Dispose the advisor.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
bool same(const Space &home) const
Test whether array has multiple occurence of the same view.
Base-class for freelist-managed objects.
void fl_dispose(FreeList *f, FreeList *l)
Return freelist-managed memory to freelist.
Propagation has not computed fixpoint.
NaryLqLe(Space &home, bool share, NaryLqLe< View, o > &p)
Constructor for cloning p.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Positions in view array that have to be propagated.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
n-ary bounds consistent equality propagator
int size(void) const
Return size of array (number of elements)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
int i
The position of the view in the view array.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
Pos(int p, Pos *n)
Initialize with position p and next position n.
Implication for reification.
Le(Space &home, bool share, Le &p)
Constructor for cloning p.
Advisors for views (by position in array)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
int ModEventDelta
Modification event deltas.
Home class for posting propagators
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
#define GECODE_NEVER
Assert that this command is never executed.
Pos * pos
Stack of positions.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
RelTest rtest_lq(View x, int n)
Test whether view x is less or equal than integer n.