42 template<
class P,
class N>
59 template<
class Val,
class P,
class N, PropCond pc>
63 x.subscribe(home,*
this,pc);
64 y.subscribe(home,*
this,pc);
67 template<
class Val,
class P,
class N, PropCond pc>
75 template<
class Val,
class P,
class N, PropCond pc>
81 template<
class Val,
class P,
class N, PropCond pc>
84 x.reschedule(home,*
this,pc);
85 y.reschedule(home,*
this,pc);
88 template<
class Val,
class P,
class N, PropCond pc>
91 x.cancel(home,*
this,pc);
92 y.cancel(home,*
this,pc);
101 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
109 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
113 :
Lin<
Val,P,N,pc>(home,p) {
117 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
120 x.reschedule(home,*
this,pc);
121 y.reschedule(home,*
this,pc);
125 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
130 return sizeof(*this);
138 template<
class Val,
class View>
143 for (
int i=n; i--; ) {
145 if (
x[i].assigned()) {
146 c -= m;
x[i] =
x[--n];
148 sl -= m; su -=
x[i].max();
153 for (
int i=0; i<n; i++) {
154 sl -=
x[i].min(); su -=
x[i].max();
159 template<
class Val,
class View>
164 for (
int i=n; i--; ) {
166 if (
y[i].assigned()) {
167 c += m;
y[i] =
y[--n];
169 sl += m; su +=
y[i].min();
174 for (
int i=0; i<n; i++) {
175 sl +=
y[i].max(); su +=
y[i].min();
181 template<
class Val,
class P,
class N>
201 return (c ==
static_cast<Val>(0)) ?
207 const int mod_sl = 1;
208 const int mod_su = 2;
210 int mod = mod_sl | mod_su;
216 for (
int i=0; i<
x.size(); i++) {
217 const Val xi_max =
x[i].max();
222 su += xi_max -
x[i].max();
227 for (
int i=0; i<
y.size(); i++) {
228 const Val yi_min =
y[i].min();
233 su +=
y[i].min() - yi_min;
241 for (
int i=0; i<
x.size(); i++) {
242 const Val xi_min =
x[i].min();
247 sl += xi_min -
x[i].min();
252 for (
int i=0; i<
y.size(); i++) {
253 const Val yi_max =
y[i].max();
258 sl +=
y[i].max() - yi_max;
273 template<
class Val,
class P,
class N>
278 template<
class Val,
class P,
class N>
284 }
else if (
x.size() == 0) {
293 template<
class Val,
class P,
class N>
302 template<
class Val,
class P,
class N>
311 assert(
x.size() == 2);
313 (home,p,
x[0],
x[1],c);
319 assert(
y.size() == 2);
321 (home,p,
y[0],
y[1],-c);
329 (home,p,
x[0],
x[1],c);
334 (home,p,
y[0],
y[1],-c);
341 template<
class Val,
class P,
class N>
350 assert(
x.size() == 3);
352 (home,p,
x[0],
x[1],
x[2],c);
358 assert(
y.size() == 3);
360 (home,p,
y[0],
y[1],
y[2],-c);
368 (home,p,
x[0],
x[1],
x[2],c);
376 (home,p,
y[0],
y[1],
y[2],-c);
379 template<
class Val,
class P,
class N>
384 if (
x.size() +
y.size() == 2)
386 if (
x.size() +
y.size() == 3)
392 template<
class Val,
class P,
class N>
403 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
409 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
416 }
else if (
x.size() == 0) {
425 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
430 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
436 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
456 if ((-sl ==
c) && (-su ==
c)) {
461 if ((-sl >
c) || (-su <
c)) {
475 template<
class Val,
class P,
class N>
480 template<
class Val,
class P,
class N>
486 }
else if (
x.size() == 0) {
495 template<
class Val,
class P,
class N>
504 template<
class Val,
class P,
class N>
513 assert(
x.size() == 2);
515 (home,p,
x[0],
x[1],
c);
521 assert(
y.size() == 2);
523 (home,p,
y[0],
y[1],-c);
531 (home,p,
x[0],
x[1],c);
536 (home,p,
y[0],
y[1],-c);
543 template<
class Val,
class P,
class N>
552 assert(
x.size() == 3);
554 (home,p,
x[0],
x[1],
x[2],
c);
560 assert(
y.size() == 3);
562 (home,p,
y[0],
y[1],
y[2],-
c);
570 (home,p,
x[0],
x[1],
x[2],c);
578 (home,p,
y[0],
y[1],
y[2],-c);
581 template<
class Val,
class P,
class N>
586 if (
x.size() +
y.size() == 2)
588 if (
x.size() +
y.size() == 3)
594 template<
class Val,
class P,
class N>
597 for (
int i=
x.size(); i--; )
598 if (
x[i].assigned()) {
599 c -=
x[i].val();
x.move_lst(i);
601 for (
int i=
y.size(); i--; )
602 if (
y[i].assigned()) {
603 c +=
y[i].val();
y.move_lst(i);
605 if (
x.size() +
y.size() <= 1) {
612 return (
c ==
static_cast<Val>(0)) ?
624 template<
class Val,
class P,
class N>
629 template<
class Val,
class P,
class N>
635 }
else if (
x.size() == 0) {
644 template<
class Val,
class P,
class N>
653 template<
class Val,
class P,
class N>
662 assert(
x.size() == 2);
664 (home,p,
x[0],
x[1],c);
670 assert(
y.size() == 2);
680 (home,p,
x[0],
x[1],c);
692 template<
class Val,
class P,
class N>
701 assert(
x.size() == 3);
703 (home,p,
x[0],
x[1],
x[2],c);
709 assert(
y.size() == 3);
719 (home,p,
x[0],
x[1],
x[2],c);
730 template<
class Val,
class P,
class N>
735 if (
x.size() +
y.size() == 2)
737 if (
x.size() +
y.size() == 3)
743 template<
class Val,
class P,
class N>
750 for (
int i=
x.size(); i--; ) {
752 if (
x[i].assigned()) {
753 c -= m;
x.move_lst(i);
758 for (
int i=
y.size(); i--; ) {
760 if (
y[i].assigned()) {
761 c += m;
y.move_lst(i);
766 if ((
x.size() +
y.size()) <= 1) {
775 return (
c >=
static_cast<Val>(0)) ?
779 for (
int i=0; i<
x.size(); i++)
781 for (
int i=0; i<
y.size(); i++)
788 bool assigned =
true;
789 for (
int i=0; i<
x.size(); i++) {
790 assert(!
x[i].assigned());
791 Val slx = sl +
x[i].min();
801 for (
int i=0; i<
y.size(); i++) {
802 assert(!
y[i].assigned());
803 Val sly =
y[i].max() - sl;
820 template<
class Val,
class P,
class N, ReifyMode rm>
826 template<
class Val,
class P,
class N, ReifyMode rm>
833 }
else if (
x.size() == 0) {
842 template<
class Val,
class P,
class N, ReifyMode rm>
847 template<
class Val,
class P,
class N, ReifyMode rm>
853 template<
class Val,
class P,
class N, ReifyMode rm>
Base-class for both propagators and branchers.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Home class for posting propagators
Boolean view for Boolean variables.
Propagator for bounds consistent binary linear equality
Propagator for bounds consistent ternary linear equality
Propagator for bounds consistent n-ary linear equality
virtual Actor * copy(Space &home)
Create copy during cloning.
Eq(Space &home, Eq &p)
Constructor for cloning p.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c)
Post propagator for .
Base-class for n-ary linear propagators.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Lin(Space &home, Lin< Val, P, N, pc > &p)
Constructor for cloning p.
ViewArray< N > y
Array of negative views.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear)
ViewArray< P > x
Array of positive views.
virtual void reschedule(Space &home)
Schedule function.
Propagator for bounds consistent binary linear less or equal
Propagator for bounds consistent ternary linear less or equal
Propagator for bounds consistent n-ary linear less or equal
virtual Actor * copy(Space &home)
Create copy during cloning.
Lq(Space &home, Lq &p)
Constructor for cloning p.
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c)
Post propagator for .
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Propagator for bounds consistent binary linear disequality
Propagator for bounds consistent ternary linear disquality
Propagator for bounds consistent n-ary linear disequality
virtual Actor * copy(Space &home)
Create copy during cloning.
Nq(Space &home, Nq &p)
Constructor for cloning p.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c)
Post propagator for .
Propagator for reified bounds consistent n-ary linear equality
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c, Ctrl b)
Post propagator for .
ReEq(Space &home, ReEq &p)
Constructor for cloning p.
virtual Actor * copy(Space &home)
Create copy during cloning.
Base-class for reified n-ary linear propagators.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
virtual void reschedule(Space &home)
Schedule function.
ReLin(Space &home, ReLin &p)
Constructor for cloning p.
Ctrl b
Control view for reification.
Propagator for reified bounds consistent n-ary linear less or equal
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c, BoolView b)
Post propagator for .
ReLq(Space &home, ReLq &p)
Constructor for cloning p.
virtual Actor * copy(Space &home)
Create copy during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
Base-class for propagators.
ModEventDelta med
A set of modification events (used during propagation)
Propagator(Home home)
Constructor for posting.
static ModEvent me(const ModEventDelta &med)
ExecStatus ES_SUBSUMED(Propagator &p)
Propagator p is subsumed
int ModEventDelta
Modification event deltas.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
@ RM_IMP
Implication for reification.
@ RM_PMI
Inverse implication for reification.
Actor * nqtobin(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of disequality to binary propagators.
void bounds_n(ModEventDelta med, ViewArray< View > &y, Val &c, Val &sl, Val &su)
Actor * lqtoter(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of inequality to ternary propagators.
bool isunit(ViewArray< P > &, ViewArray< N > &)
Test if only unit-coefficient arrays used.
Actor * nqtoter(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of disequality to ternary propagators.
ExecStatus prop_bnd(Space &home, ModEventDelta med, Propagator &p, ViewArray< P > &x, ViewArray< N > &y, Val &c)
void bounds_p(ModEventDelta med, ViewArray< View > &x, Val &c, Val &sl, Val &su)
Actor * eqtobin(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of equality to binary propagators.
Actor * eqtoter(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of equality to ternary propagators.
Actor * lqtobin(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of inequality to binary propagators.
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
const Gecode::ModEvent ME_INT_FAILED
Domain operation has resulted in failure.
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
Gecode toplevel namespace
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl=IPL_DEF)
Post propagator for .
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar SetOpType SetVar y
@ ES_OK
Execution is okay.
@ ES_FIX
Propagation has computed fixpoint.
@ ES_FAILED
Execution has resulted in failure.
@ ES_NOFIX
Propagation has not computed fixpoint.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar x
int ModEvent
Type for modification events.