36 namespace Gecode {
namespace Int {
namespace Rel {
43 template<
class V0,
class V1>
48 template<
class V0,
class V1>
67 template<
class V0,
class V1>
72 if (!
same(x0,x1) && (x0.max() > x1.min()))
77 template<
class V0,
class V1>
82 template<
class V0,
class V1>
88 template<
class V0,
class V1>
103 template<
class V0,
class V1>
108 template<
class V0,
class V1>
111 (void) x0; (void) x1;
133 template<
class V0,
class V1>
140 if (x0.max() >= x1.min())
145 template<
class V0,
class V1>
150 template<
class V0,
class V1>
156 template<
class V0,
class V1>
171 template<
class View,
int o>
177 template<
class View,
int o>
184 template<
class View,
int o>
189 template<
class View,
int o>
195 template<
class View,
int o>
199 template<
class View,
int o>
205 template<
class View,
int o>
208 return home.fl_alloc<
sizeof(
Pos)>();
211 template<
class View,
int o>
218 template<
class View,
int o>
223 template<
class View,
int o>
227 if ((
pos != NULL) && (
pos->
p == p))
231 template<
class View,
int o>
241 template<
class View,
int o>
246 for (
int i=x.
size();
i--; )
250 template<
class View,
int o>
253 assert((o == 0) || (o == 1));
263 for (
int i=0;
i<
n;
i++)
264 for (
int j=n-1; j>
i; j--)
265 if (
same(x[i],x[j])) {
269 for (
int k=j-i; k--; )
273 for (
int k=0; k<n-1-j-1+1; k++)
284 for (
int i=x.
size()-1;
i--;)
291 while ((i+1 < x.
size()) && (x[i].
max()+o <= x[i+1].min()))
298 while ((i > 0) && (x[i-1].
max()+o <= x[i].
min()))
305 for (
int i=1;
i+1<x.
size();
i++)
306 if ((x[j-1].
max()+o > x[
i].
min()) ||
307 (x[
i].max()+o > x[
i+1].min()))
309 x[j++]=x[x.
size()-1];
318 }
else if (x.
size() >= 2) {
324 template<
class View,
int o>
329 assert(p.
pos == NULL);
333 template<
class View,
int o>
341 a.
set(static_cast<unsigned int>(as.advisor().i));
343 int* m = r.
alloc<
int>(
x.size());
345 for (
int i=0;
i<
x.size();
i++)
346 if (a.
get(static_cast<unsigned int>(
i))) {
347 m[
i] = j;
x[j++] =
x[
i];
352 as.advisor().i = m[as.advisor().i];
359 template<
class View,
int o>
365 template<
class View,
int o>
369 x[as.advisor().i].cancel(home,as.advisor());
374 return sizeof(*this);
378 template<
class View,
int o>
383 switch (View::modevent(d)) {
389 if (((i == 0) || (
x[i-1].
max()+o <=
x[i].
min())) &&
390 ((i ==
x.size()-1) || (
x[i].
max()+o <=
x[i+1].min()))) {
402 if (((i <
x.size()-1) && (
x[i+1].
min() <
x[
i].min()+o)) ||
403 ((i > 0) && (
x[i-1].
max() >
x[
i].max()-o))) {
410 template<
class View,
int o>
416 template<
class View,
int o>
423 for (
int i=p;
i<n-1;
i++) {
430 for (
int i=p;
i>0;
i--) {
439 for (
int i=0;
i<n-1;
i++)
441 for (
int i=n-1;
i>0;
i--)
457 template<
class View,
class CtrlView, ReifyMode rm>
462 template<
class View,
class CtrlView, ReifyMode rm>
490 }
else if (rm !=
RM_IMP) {
496 template<
class View,
class CtrlView, ReifyMode rm>
501 template<
class View,
class CtrlView, ReifyMode rm>
507 template<
class View,
class CtrlView, ReifyMode rm>
513 }
else if (
b.zero()) {
539 template<
class View,
class CtrlView, ReifyMode rm>
544 template<
class View,
class CtrlView, ReifyMode rm>
550 }
else if (b.zero()) {
573 template<
class View,
class CtrlView, ReifyMode rm>
578 template<
class View,
class CtrlView, ReifyMode rm>
584 template<
class View,
class CtrlView, ReifyMode rm>
590 }
else if (
b.zero()) {
bool get(unsigned int i) const
Access value at bit i.
bool empty(void) const
Whether no more positions must be propagated.
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
Relation may hold or not.
Le(Space &home, Le &p)
Constructor for cloning p.
Inverse implication for reification.
ReLq(Space &home, ReLq &p)
Constructor for cloning p.
ExecStatus ES_SUBSUMED(Propagator &p)
Reified unary propagator.
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 .
static ExecStatus post(Home home, V0 x0, V1 x1)
Post propagator .
FreeList * next(void) const
Return next freelist object.
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.
int c
Integer constant to check.
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.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Class to iterate over advisors of a council.
Lq(Space &home, Lq &p)
Constructor for cloning p.
Propagation has computed fixpoint.
CtrlView b
Boolean control view.
Base-class for both propagators and branchers.
bool run
Whether the propagator is currently running.
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.
RelTest rtest_lq(VX x, VY y)
Test whether view x is less or equal than view y.
bool same(const CachedView< View > &x, const CachedView< View > &y)
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
bool same(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether two views are the same.
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.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
const Gecode::PropCond PC_INT_NONE
Propagation condition to be ignored (convenience)
Execution has resulted in failure.
Council< Index > c
The advisor council.
Pos * next(void) const
Return next position.
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.
Less or equal propagator.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
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.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
void set(unsigned int i)
Set bit i.
NaryLqLe(Space &home, NaryLqLe< View, o > &p)
Constructor for cloning p.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
virtual void reschedule(Space &home)
Schedule function.
void drop_fst(int i)
Drop views from positions 0 to i-1 from array.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
n-ary less and less or equal propagator
Post propagator for SetVar SetOpType SetVar SetRelType r
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 .
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
Integer view for integer variables.
Post propagator for SetVar SetOpType SetVar y
Generic domain change information to be supplied to advisors.
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
void dispose(Space &home)
Free memory for this position.
static ExecStatus post(Home home, V0 x0, V1 x1)
Post propagator .
void dispose(Space &home, Council< A > &c)
Dispose the advisor.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
ReLqInt(Space &home, ReLqInt &p)
Constructor for cloning p.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
Base-class for freelist-managed objects.
void fl_dispose(FreeList *f, FreeList *l)
Return freelist-managed memory to freelist.
Post propagator for SetVar x
Propagation has not computed fixpoint.
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
static const int n_threshold
Compact during cloning when more advisors than that are subsumed.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static bool same(V0 x0, V1 x1)
Whether views refer to same variable.
int i
The position of the view in the view array.
Gecode toplevel namespace
Pos(int p, Pos *n)
Initialize with position p and next position n.
Implication for reification.
CtrlView b
Boolean control view.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Advisors for views (by position in array)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
int size(void) const
Return size of array (number of elements)
int ModEventDelta
Modification event deltas.
Home class for posting propagators
bool same(void) const
Test whether array has multiple occurence of the same view.
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
#define GECODE_NEVER
Assert that this command is never executed.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Pos * pos
Stack of positions.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
static bool same(V0 x0, V1 x1)
Whether views refer to same variable.
Boolean view for Boolean variables.