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);
79 template<
class Val,
class P,
class N, PropCond pc>
85 template<
class Val,
class P,
class N, PropCond pc>
88 x.reschedule(home,*
this,pc);
89 y.reschedule(home,*
this,pc);
92 template<
class Val,
class P,
class N, PropCond pc>
95 x.cancel(home,*
this,pc);
96 y.cancel(home,*
this,pc);
97 (void) Propagator::dispose(home);
105 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
113 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
118 b.update(home,share,
p.b);
121 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
124 x.reschedule(home,*
this,pc);
125 y.reschedule(home,*
this,pc);
129 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
134 return sizeof(*this);
142 template<
class Val,
class View>
147 for (
int i =
n;
i--; ) {
150 c -= m;
x[
i] =
x[--
n];
152 sl -= m; su -=
x[
i].max();
157 for (
int i =
n;
i--; ) {
158 sl -=
x[
i].min(); su -=
x[
i].max();
163 template<
class Val,
class View>
168 for (
int i =
n;
i--; ) {
171 c += m;
y[
i] =
y[--
n];
173 sl += m; su +=
y[
i].min();
178 for (
int i =
n;
i--; ) {
179 sl +=
y[
i].max(); su +=
y[
i].min();
185 template<
class Val,
class P,
class N>
193 bounds_p<Val,P>(med,
x,
c, sl, su);
194 bounds_n<Val,N>(med,
y,
c, sl, su);
196 if ((IntView::me(med) ==
ME_INT_VAL) && ((
x.size() +
y.size()) <= 1)) {
205 return (
c == static_cast<Val>(0)) ?
211 const int mod_sl = 1;
212 const int mod_su = 2;
214 int mod = mod_sl | mod_su;
220 for (
int i =
x.size();
i--; ) {
221 const Val xi_max =
x[
i].max();
226 su += xi_max -
x[
i].max();
231 for (
int i =
y.size();
i--; ) {
232 const Val yi_min =
y[
i].min();
237 su +=
y[
i].min() - yi_min;
245 for (
int i =
x.size();
i--; ) {
246 const Val xi_min =
x[
i].min();
251 sl += xi_min -
x[
i].min();
256 for (
int i =
y.size();
i--; ) {
257 const Val yi_max =
y[
i].max();
262 sl +=
y[
i].max() - yi_max;
277 template<
class Val,
class P,
class N>
282 template<
class Val,
class P,
class N>
288 }
else if (
x.size() == 0) {
297 template<
class Val,
class P,
class N>
306 template<
class Val,
class P,
class N>
315 assert(
x.size() == 2);
317 (home,share,
p,
x[0],
x[1],
c);
323 assert(
y.size() == 2);
325 (home,share,
p,
y[0],
y[1],-
c);
333 (home,share,
p,
x[0],
x[1],
c);
338 (home,share,
p,
y[0],
y[1],-
c);
345 template<
class Val,
class P,
class N>
354 assert(
x.size() == 3);
356 (home,share,
p,
x[0],
x[1],
x[2],
c);
362 assert(
y.size() == 3);
364 (home,share,
p,
y[0],
y[1],
y[2],-
c);
372 (home,share,
p,
x[0],
x[1],
x[2],
c);
380 (home,share,
p,
y[0],
y[1],
y[2],-
c);
383 template<
class Val,
class P,
class N>
388 if (
x.size() +
y.size() == 2)
390 if (
x.size() +
y.size() == 3)
396 template<
class Val,
class P,
class N>
399 return prop_bnd<Val,P,N>(home,med,*
this,
x,
y,
c);
407 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
413 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
420 }
else if (
x.size() == 0) {
429 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
435 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
441 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
458 bounds_p<Val,P>(med,
x,
c, sl, su);
459 bounds_n<Val,N>(med,
y,
c, sl, su);
461 if ((-sl ==
c) && (-su ==
c)) {
466 if ((-sl >
c) || (-su <
c)) {
480 template<
class Val,
class P,
class N>
485 template<
class Val,
class P,
class N>
491 }
else if (
x.size() == 0) {
500 template<
class Val,
class P,
class N>
509 template<
class Val,
class P,
class N>
518 assert(
x.size() == 2);
520 (home,share,
p,
x[0],
x[1],
c);
526 assert(
y.size() == 2);
528 (home,share,
p,
y[0],
y[1],-
c);
536 (home,share,
p,
x[0],
x[1],
c);
541 (home,share,
p,
y[0],
y[1],-
c);
548 template<
class Val,
class P,
class N>
557 assert(
x.size() == 3);
559 (home,share,
p,
x[0],
x[1],
x[2],
c);
565 assert(
y.size() == 3);
567 (home,share,
p,
y[0],
y[1],
y[2],-
c);
575 (home,share,
p,
x[0],
x[1],
x[2],
c);
583 (home,share,
p,
y[0],
y[1],
y[2],-
c);
586 template<
class Val,
class P,
class N>
591 if (
x.size() +
y.size() == 2)
593 if (
x.size() +
y.size() == 3)
599 template<
class Val,
class P,
class N>
602 for (
int i =
x.size();
i--; )
604 c -=
x[
i].val();
x.move_lst(
i);
606 for (
int i =
y.size();
i--; )
608 c +=
y[
i].val();
y.move_lst(
i);
610 if (
x.size() +
y.size() <= 1) {
617 return (
c == static_cast<Val>(0)) ?
629 template<
class Val,
class P,
class N>
634 template<
class Val,
class P,
class N>
640 }
else if (
x.size() == 0) {
649 template<
class Val,
class P,
class N>
658 template<
class Val,
class P,
class N>
667 assert(
x.size() == 2);
669 (home,share,
p,
x[0],
x[1],
c);
675 assert(
y.size() == 2);
685 (home,share,
p,
x[0],
x[1],
c);
697 template<
class Val,
class P,
class N>
706 assert(
x.size() == 3);
708 (home,share,
p,
x[0],
x[1],
x[2],
c);
714 assert(
y.size() == 3);
724 (home,share,
p,
x[0],
x[1],
x[2],
c);
735 template<
class Val,
class P,
class N>
740 if (
x.size() +
y.size() == 2)
742 if (
x.size() +
y.size() == 3)
748 template<
class Val,
class P,
class N>
755 for (
int i =
x.size();
i--; ) {
758 c -= m;
x.move_lst(
i);
763 for (
int i =
y.size();
i--; ) {
766 c += m;
y.move_lst(
i);
771 if ((
x.size() +
y.size()) <= 1) {
780 return (
c >= static_cast<Val>(0)) ?
784 for (
int i =
x.size();
i--; )
786 for (
int i =
y.size();
i--; )
794 for (
int i =
x.size();
i--; ) {
796 Val slx = sl +
x[
i].min();
806 for (
int i =
y.size();
i--; ) {
808 Val sly =
y[
i].max() - sl;
825 template<
class Val,
class P,
class N, ReifyMode rm>
831 template<
class Val,
class P,
class N, ReifyMode rm>
838 }
else if (
x.size() == 0) {
847 template<
class Val,
class P,
class N, ReifyMode rm>
852 template<
class Val,
class P,
class N, ReifyMode rm>
858 template<
class Val,
class P,
class N, ReifyMode rm>
876 bounds_p<Val,P>(med,
x,
c,sl,su);
877 bounds_n<Val,N>(med,
y,
c,sl,su);
Propagator for bounds consistent binary linear disequality
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl)
Post propagator for .
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.
Inverse implication for reification.
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 .
void update(Space &home, bool share, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
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
ExecStatus prop_bnd(Space &home, ModEventDelta med, Propagator &p, ViewArray< P > &x, ViewArray< N > &y, Val &c)
int ModEvent
Type for modification events.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
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
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
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.
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.
Post propagator for SetVar SetOpType SetVar y
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.
Post propagator for SetVar x
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.
void reschedule(Space &home, Propagator &p, IntSet &y)
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 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.