40 namespace Gecode {
namespace Int {
namespace Linear {
46 template<
class P,
class N>
63 template<
class Val,
class P,
class N, PropCond pc>
67 x.subscribe(home,*
this,pc);
68 y.subscribe(home,*
this,pc);
71 template<
class Val,
class P,
class N, PropCond pc>
75 x.update(home,share,
p.x);
76 y.update(home,share,
p.y);
79 template<
class Val,
class P,
class N, PropCond pc>
85 template<
class Val,
class P,
class N, PropCond pc>
88 x.cancel(home,*
this,pc);
89 y.cancel(home,*
this,pc);
90 (void) Propagator::dispose(home);
98 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
106 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
111 b.update(home,share,
p.b);
114 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
119 return sizeof(*this);
127 template<
class Val,
class View>
132 for (
int i =
n;
i--; ) {
135 c -= m;
x[
i] =
x[--
n];
137 sl -= m; su -=
x[
i].max();
142 for (
int i =
n;
i--; ) {
143 sl -=
x[
i].min(); su -=
x[
i].max();
148 template<
class Val,
class View>
153 for (
int i =
n;
i--; ) {
156 c += m; y[
i] = y[--
n];
158 sl += m; su += y[
i].min();
163 for (
int i =
n;
i--; ) {
164 sl += y[
i].max(); su += y[
i].min();
170 template<
class Val,
class P,
class N>
178 bounds_p<Val,P>(med,
x,
c, sl, su);
179 bounds_n<Val,N>(med, y,
c, sl, su);
181 if ((IntView::me(med) ==
ME_INT_VAL) && ((
x.size() + y.
size()) <= 1)) {
190 return (
c == static_cast<Val>(0)) ?
196 const int mod_sl = 1;
197 const int mod_su = 2;
199 int mod = mod_sl | mod_su;
205 for (
int i =
x.size();
i--; ) {
206 const Val xi_max =
x[
i].max();
211 su += xi_max -
x[
i].max();
216 for (
int i = y.
size();
i--; ) {
217 const Val yi_min = y[
i].min();
222 su += y[
i].min() - yi_min;
230 for (
int i =
x.size();
i--; ) {
231 const Val xi_min =
x[
i].min();
236 sl += xi_min -
x[
i].min();
241 for (
int i = y.
size();
i--; ) {
242 const Val yi_max = y[
i].max();
247 sl += y[
i].max() - yi_max;
262 template<
class Val,
class P,
class N>
267 template<
class Val,
class P,
class N>
273 }
else if (
x.size() == 0) {
282 template<
class Val,
class P,
class N>
291 template<
class Val,
class P,
class N>
300 assert(
x.size() == 2);
302 (home,share,
p,
x[0],
x[1],
c);
308 assert(y.
size() == 2);
310 (home,share,
p,y[0],y[1],-
c);
318 (home,share,
p,
x[0],
x[1],
c);
323 (home,share,
p,y[0],y[1],-
c);
330 template<
class Val,
class P,
class N>
339 assert(
x.size() == 3);
341 (home,share,
p,
x[0],
x[1],
x[2],
c);
347 assert(y.
size() == 3);
349 (home,share,
p,y[0],y[1],y[2],-
c);
357 (home,share,
p,
x[0],
x[1],
x[2],
c);
365 (home,share,
p,y[0],y[1],y[2],-
c);
368 template<
class Val,
class P,
class N>
373 if (
x.size() + y.
size() == 2)
375 if (
x.size() + y.
size() == 3)
381 template<
class Val,
class P,
class N>
384 return prop_bnd<Val,P,N>(home,med,*
this,
x,y,
c);
392 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
398 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
405 }
else if (
x.size() == 0) {
414 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
420 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
426 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
443 bounds_p<Val,P>(med,
x,
c, sl, su);
444 bounds_n<Val,N>(med, y,
c, sl, su);
446 if ((-sl ==
c) && (-su ==
c)) {
451 if ((-sl >
c) || (-su <
c)) {
465 template<
class Val,
class P,
class N>
470 template<
class Val,
class P,
class N>
476 }
else if (
x.size() == 0) {
485 template<
class Val,
class P,
class N>
494 template<
class Val,
class P,
class N>
503 assert(
x.size() == 2);
505 (home,share,
p,
x[0],
x[1],
c);
511 assert(y.
size() == 2);
513 (home,share,
p,y[0],y[1],-
c);
521 (home,share,
p,
x[0],
x[1],
c);
526 (home,share,
p,y[0],y[1],-
c);
533 template<
class Val,
class P,
class N>
542 assert(
x.size() == 3);
544 (home,share,
p,
x[0],
x[1],
x[2],
c);
550 assert(y.
size() == 3);
552 (home,share,
p,y[0],y[1],y[2],-
c);
560 (home,share,
p,
x[0],
x[1],
x[2],
c);
568 (home,share,
p,y[0],y[1],y[2],-
c);
571 template<
class Val,
class P,
class N>
576 if (
x.size() + y.
size() == 2)
578 if (
x.size() + y.
size() == 3)
584 template<
class Val,
class P,
class N>
587 for (
int i =
x.size();
i--; )
589 c -=
x[
i].val();
x.move_lst(
i);
591 for (
int i = y.
size();
i--; )
595 if (
x.size() + y.
size() <= 1) {
602 return (
c == static_cast<Val>(0)) ?
614 template<
class Val,
class P,
class N>
619 template<
class Val,
class P,
class N>
625 }
else if (
x.size() == 0) {
634 template<
class Val,
class P,
class N>
643 template<
class Val,
class P,
class N>
652 assert(
x.size() == 2);
654 (home,share,
p,
x[0],
x[1],
c);
660 assert(y.
size() == 2);
670 (home,share,
p,
x[0],
x[1],
c);
682 template<
class Val,
class P,
class N>
691 assert(
x.size() == 3);
693 (home,share,
p,
x[0],
x[1],
x[2],
c);
699 assert(y.
size() == 3);
709 (home,share,
p,
x[0],
x[1],
x[2],
c);
720 template<
class Val,
class P,
class N>
725 if (
x.size() + y.
size() == 2)
727 if (
x.size() + y.
size() == 3)
733 template<
class Val,
class P,
class N>
740 for (
int i =
x.size();
i--; ) {
743 c -= m;
x.move_lst(
i);
748 for (
int i = y.
size();
i--; ) {
756 if ((
x.size() + y.
size()) <= 1) {
765 return (
c >= static_cast<Val>(0)) ?
769 for (
int i =
x.size();
i--; )
771 for (
int i = y.
size();
i--; )
779 for (
int i =
x.size();
i--; ) {
781 Val slx = sl +
x[
i].min();
791 for (
int i = y.
size();
i--; ) {
793 Val sly = y[
i].max() - sl;
810 template<
class Val,
class P,
class N, ReifyMode rm>
816 template<
class Val,
class P,
class N, ReifyMode rm>
823 }
else if (
x.size() == 0) {
832 template<
class Val,
class P,
class N, ReifyMode rm>
837 template<
class Val,
class P,
class N, ReifyMode rm>
843 template<
class Val,
class P,
class N, ReifyMode rm>
861 bounds_p<Val,P>(med,
x,
c,sl,su);
862 bounds_n<Val,N>(med,y,
c,sl,su);
Propagator for bounds consistent binary linear disequality
ReEq(Space &home, bool share, ReEq &p)
Constructor for cloning p.
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
bool isunit(ViewArray< P > &, ViewArray< N > &)
Test if only unit-coefficient arrays used.
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c)
Post propagator for .
Propagator for bounds consistent n-ary linear equality
Lq(Space &home, bool share, Lq &p)
Constructor for cloning p.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatNum c)
Post propagator for .
Inverse implication for reification.
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntConLevel icl)
Post propagator for .
Propagator for reified bounds consistent n-ary linear less or equal
ExecStatus ES_SUBSUMED(Propagator &p)
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c)
Post propagator for .
Propagator for bounds consistent n-ary linear disequality
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Propagator for bounds consistent ternary linear equality
struct Gecode::@511::NNF::@54::@55 b
For binary nodes (and, or, eqv)
ExecStatus prop_bnd(Space &home, ModEventDelta med, Propagator &p, ViewArray< P > &x, ViewArray< N > &y, Val &c)
int ModEvent
Type for modification events.
Base-class for reified n-ary linear propagators.
Base-class for propagators.
Actor * lqtobin(Space &, bool, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of inequality to binary propagators.
Base-class for n-ary linear propagators.
Propagation has computed fixpoint.
Propagator for bounds consistent binary linear equality
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Actor * lqtoter(Space &, bool, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of inequality to ternary propagators.
Base-class for both propagators and branchers.
Actor * eqtoter(Space &, bool, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of equality to ternary propagators.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
const Gecode::ModEvent ME_INT_FAILED
Domain operation has resulted in failure.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Propagator for bounds consistent ternary linear less or equal
Gecode::FloatVal c(-8, 8)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c, BoolView b)
Post propagator for .
int n
Number of negative literals for node type.
Execution has resulted in failure.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Actor * eqtobin(Space &, bool, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of equality to binary propagators.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
Propagator for bounds consistent binary linear less or equal
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Propagator for reified bounds consistent n-ary linear equality
Nq(Space &home, bool share, Nq &p)
Constructor for cloning p.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
void move_lst(int i)
Move view from position size()-1 to position i (truncate array by one)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Lin(Space &home, bool share, Lin< Val, P, N, pc > &p)
Constructor for cloning p.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Eq(Space &home, bool share, Eq &p)
Constructor for cloning p.
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c, Ctrl b)
Post propagator for .
Node * x
Pointer to corresponding Boolean expression node.
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c)
Post propagator for .
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
bool assigned(View x, int v)
Whether x is assigned to value v.
ReLq(Space &home, bool share, ReLq &p)
Constructor for cloning p.
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
void bounds_n(ModEventDelta med, ViewArray< View > &y, FloatVal &c, FloatNum &sl, FloatNum &su)
Compute bounds information for negative views.
Propagation has not computed fixpoint.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Gecode toplevel namespace
Propagator for bounds consistent n-ary linear less or equal
Actor * nqtoter(Space &, bool, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of disequality to ternary propagators.
Implication for reification.
FloatVal max(const FloatVal &x, const FloatVal &y)
Return maximum of x and y.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Propagator for bounds consistent ternary linear disquality
int size(void) const
Return size of array (number of elements)
int ModEventDelta
Modification event deltas.
FloatVal min(const FloatVal &x, const FloatVal &y)
Return minimum of x and y.
Home class for posting propagators
void bounds_p(ModEventDelta med, ViewArray< View > &x, FloatVal &c, FloatNum &sl, FloatNum &su)
Compute bounds information for positive views.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Actor * nqtobin(Space &, bool, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of disequality to binary propagators.
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
Boolean view for Boolean variables.