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>
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>
121 template<
class Val,
class P,
class N, PropCond pc,
class Ctrl>
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,p,x[0],x[1],c);
323 assert(y.
size() == 2);
325 (home,p,y[0],y[1],-c);
333 (home,
p,x[0],x[1],
c);
338 (home,p,y[0],y[1],-c);
345 template<
class Val,
class P,
class N>
354 assert(x.
size() == 3);
356 (home,p,x[0],x[1],x[2],c);
362 assert(y.
size() == 3);
364 (home,p,y[0],y[1],y[2],-c);
372 (home,
p,x[0],x[1],x[2],
c);
380 (home,p,y[0],y[1],y[2],-c);
383 template<
class Val,
class P,
class N>
389 return eqtobin(home,*
this,x,y,c);
391 return eqtoter(home,*
this,x,y,c);
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>
434 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
440 template<
class Val,
class P,
class N,
class Ctrl, ReifyMode rm>
457 bounds_p<Val,P>(
med,
x,
c, sl, su);
458 bounds_n<Val,N>(
med,
y,
c, sl, su);
460 if ((-sl == c) && (-su ==
c)) {
465 if ((-sl > c) || (-su < c)) {
479 template<
class Val,
class P,
class N>
484 template<
class Val,
class P,
class N>
490 }
else if (x.
size() == 0) {
499 template<
class Val,
class P,
class N>
508 template<
class Val,
class P,
class N>
517 assert(x.
size() == 2);
519 (home,p,x[0],x[1],c);
525 assert(y.
size() == 2);
527 (home,p,y[0],y[1],-c);
535 (home,
p,x[0],x[1],
c);
540 (home,p,y[0],y[1],-c);
547 template<
class Val,
class P,
class N>
556 assert(x.
size() == 3);
558 (home,p,x[0],x[1],x[2],c);
564 assert(y.
size() == 3);
566 (home,p,y[0],y[1],y[2],-c);
574 (home,
p,x[0],x[1],x[2],
c);
582 (home,p,y[0],y[1],y[2],-c);
585 template<
class Val,
class P,
class N>
591 return nqtobin(home,*
this,x,y,c);
593 return nqtoter(home,*
this,x,y,c);
598 template<
class Val,
class P,
class N>
601 for (
int i = x.
size();
i--; )
603 c -= x[
i].val(); x.move_lst(
i);
605 for (
int i = y.
size();
i--; )
607 c += y[
i].val(); y.move_lst(
i);
616 return (c == static_cast<Val>(0)) ?
628 template<
class Val,
class P,
class N>
633 template<
class Val,
class P,
class N>
639 }
else if (x.
size() == 0) {
648 template<
class Val,
class P,
class N>
657 template<
class Val,
class P,
class N>
666 assert(x.
size() == 2);
668 (home,p,x[0],x[1],c);
674 assert(y.
size() == 2);
684 (home,
p,x[0],x[1],
c);
696 template<
class Val,
class P,
class N>
705 assert(x.
size() == 3);
707 (home,p,x[0],x[1],x[2],c);
713 assert(y.
size() == 3);
723 (home,
p,x[0],x[1],x[2],
c);
734 template<
class Val,
class P,
class N>
740 return lqtobin(home,*
this,x,y,c);
742 return lqtoter(home,*
this,x,y,c);
747 template<
class Val,
class P,
class N>
754 for (
int i = x.
size();
i--; ) {
757 c -= m; x.move_lst(
i);
762 for (
int i = y.
size();
i--; ) {
765 c += m; y.move_lst(
i);
779 return (c >= static_cast<Val>(0)) ?
783 for (
int i = x.
size();
i--; )
785 for (
int i = y.
size();
i--; )
793 for (
int i = x.
size();
i--; ) {
795 Val slx = sl + x[
i].min();
805 for (
int i = y.
size();
i--; ) {
807 Val sly = y[
i].max() - sl;
824 template<
class Val,
class P,
class N, ReifyMode rm>
830 template<
class Val,
class P,
class N, ReifyMode rm>
837 }
else if (x.
size() == 0) {
846 template<
class Val,
class P,
class N, ReifyMode rm>
851 template<
class Val,
class P,
class N, ReifyMode rm>
857 template<
class Val,
class P,
class N, ReifyMode rm>
875 bounds_p<Val,P>(
med,
x,
c,sl,su);
876 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 .
#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
bool zero(void) const
Test whether view is assigned to be zero.
Actor * nqtobin(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of disequality to binary propagators.
Inverse implication for reification.
int size(void) const
Return size of array (number of elements)
Actor * eqtobin(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of equality to binary propagators.
ViewArray< N > y
Array of negative views.
Propagator for reified bounds consistent n-ary linear less or equal
ExecStatus ES_SUBSUMED(Propagator &p)
const FloatNum max
Largest allowed float value.
Actor * lqtoter(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of inequality to ternary propagators.
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, Val c)
Post propagator for .
Propagator for bounds consistent n-ary linear disequality
bool one(void) const
Test whether view is assigned to be one.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Actor * lqtobin(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of inequality to binary propagators.
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.
Base-class for n-ary linear propagators.
virtual Actor * copy(Space &home)
Create copy during cloning.
Propagation has computed fixpoint.
virtual Actor * copy(Space &home)
Create copy during cloning.
Propagator for bounds consistent binary linear equality
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
ReEq(Space &home, ReEq &p)
Constructor for cloning p.
Base-class for both propagators and branchers.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
ViewArray< P > x
Array of positive views.
const Gecode::ModEvent ME_INT_FAILED
Domain operation has resulted in failure.
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.
const FloatNum min
Smallest allowed float value.
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.
ModEvent zero_none(Space &home)
Assign not yet assigned view to zero.
void bounds_n(ModEventDelta med, ViewArray< View > &y, Val &c, Val &sl, Val &su)
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)
virtual Actor * copy(Space &home)
Create copy during cloning.
ModEventDelta med
A set of modification events (used during propagation)
Propagator for bounds consistent binary linear less or equal
virtual Actor * copy(Space &home)
Create copy during cloning.
Actor * nqtoter(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of disequality to ternary propagators.
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
size_t size
The size of the propagator (used during subsumption)
ReLq(Space &home, ReLq &p)
Constructor for cloning p.
Propagator for reified bounds consistent n-ary linear equality
void bounds_p(ModEventDelta med, ViewArray< View > &x, Val &c, Val &sl, Val &su)
#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.
Lq(Space &home, Lq &p)
Constructor for cloning p.
Actor * eqtoter(Space &, Propagator &, ViewArray< P > &, ViewArray< N > &, Val)
Rewriting of equality to ternary propagators.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
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.
virtual Actor * copy(Space &home)
Create copy during cloning.
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.
bool assigned(View x, int v)
Whether x is assigned to value v.
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.
Eq(Space &home, Eq &p)
Constructor for cloning p.
Post propagator for SetVar x
Propagation has not computed fixpoint.
Nq(Space &home, Nq &p)
Constructor for cloning p.
Ctrl b
Control view for reification.
Gecode toplevel namespace
Propagator for bounds consistent n-ary linear less or equal
Implication for reification.
Lin(Space &home, Lin< Val, P, N, pc > &p)
Constructor for cloning p.
virtual void reschedule(Space &home)
Schedule function.
ModEvent one_none(Space &home)
Assign not yet assigned view to one.
void reschedule(Space &home, Propagator &p, IntSet &y)
Propagator for bounds consistent ternary linear disquality
int size(void) const
Return size of array (number of elements)
int ModEventDelta
Modification event deltas.
Home class for posting propagators
bool me_failed(ModEvent me)
Check whether modification event me is failed.
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.