44 namespace Gecode {
namespace Int {
namespace Linear {
54 :
Propagator(home), co(home),
x(x0), n_as(n_s), n_hs(n_s),
c(c0) {
66 for (
int i=n_hs;
i--; )
68 x[
i]=
x[--n_hs];
x[n_hs]=
x[--n_x];
76 for (
int i=n_x-1;
i>=n_hs;
i--)
79 }
else if (
x[
i].zero()) {
89 :
Propagator(home,share,p), n_as(p.n_as), n_hs(n_as) {
92 co.update(home,share,p.
co);
106 for (
int i=n_hs;
i--; )
110 return sizeof(*this);
146 for (
int i =
x.size()-1;
i>=n_hs;
i--)
148 std::swap(
x[
i],
x[n_hs]);
149 x[n_hs++].subscribe(home,a);
152 }
else if (
x[
i].
one()) {
156 assert(n_hs <=
x.size());
165 int n =
x.size()-n_hs+n_as;
168 if ((
c <= 0) || (
c == n))
178 assert((n_as ==
c) && (
x.size() == n_hs));
182 for (
int i=n_hs;
i--; )
194 for (
int i=n_x;
i--; )
197 }
else if (x[
i].
one()) {
198 x[
i] = x[--n_x]; c--;
212 for (
int i=n_x;
i--; )
254 if ((
c+1 < n_as) && (
x.size()-n_hs <
c))
257 for (
int i =
x.size()-1;
i>=n_hs;
i--)
259 std::swap(
x[
i],
x[n_hs]);
260 x[n_hs++].subscribe(home,a);
263 }
else if (
x[
i].
one()) {
271 int n =
x.size()-n_hs+n_as;
272 if ((
c < 0) || (
c > n))
274 if ((
c == 0) || (
c == n))
283 assert(
x.size() == n_hs);
288 for (
int i=n_hs;
i--; )
293 for (
int i=n_hs;
i--; )
305 for (
int i=n_x;
i--; )
308 }
else if (x[
i].
one()) {
309 x[
i] = x[--n_x]; c--;
313 if ((c < 0) || (c > n_x))
317 for (
int i=n_x;
i--; )
323 for (
int i=n_x;
i--; )
342 b[b.
size()-1]),
x(b),
c(c0) {
343 assert(
x.
size() >= 2);
351 return sizeof(*this);
364 }
else if (p.
x[
i].one()) {
365 n--; p_c--; p.
x[
i]=p.
x[
n];
x[
i]=
x[
n];
380 }
else if (x[
i].zero()) {
384 if ((n < c) || (c < 0))
421 }
else if (
x[
i].zero()) {
425 assert(!
x[
i].zero() && !
x[
i].
one());
441 if (x0.zero() || x0.one())
444 if (x1.zero() || x1.one())
446 int n =
x.size() + s0 + s1;
447 if ((n <
c) || (
c < 0))
475 template<
class VX,
class VB>
484 template<
class VX,
class VB>
487 if (n_s !=
x.size()) {
489 for (
int i=n_x;
i--; )
493 assert(
x.size() == n_s);
497 template<
class VX,
class VB>
503 co.update(home,share,p.
co);
505 b.update(home,share,p.
b);
508 template<
class VX,
class VB>
516 return sizeof(*this);
519 template<
class VX,
class VB>
555 template<
class VX,
class VB, ReifyMode rm>
560 template<
class VX,
class VB, ReifyMode rm>
566 template<
class VX,
class VB, ReifyMode rm>
572 template<
class VX,
class VB, ReifyMode rm>
578 if ((n_s <
c) || (
c <= 0))
584 template<
class VX,
class VB, ReifyMode rm>
603 for (
int i=
x.size();
i--; )
606 ::
post(home(*
this),nx,
x.size()-
c+1));
613 template<
class VX,
class VB, ReifyMode rm>
616 assert(!b.assigned());
620 for (
int i=n_x;
i--; )
623 }
else if (x[
i].
one()) {
624 x[
i] = x[--n_x]; c--;
635 }
else if ((c == 1) && (rm ==
RM_EQV)) {
638 }
else if ((c == n_x) && (rm ==
RM_EQV)) {
641 for (
int i=n_x;
i--; )
657 template<
class VX,
class VB, ReifyMode rm>
662 template<
class VX,
class VB, ReifyMode rm>
668 template<
class VX,
class VB, ReifyMode rm>
674 template<
class VX,
class VB, ReifyMode rm>
681 if ((
c < 0) || (
c > n_s) || (n_s == 0))
687 template<
class VX,
class VB, ReifyMode rm>
691 if ((
c == 0) && (n_s == 0)) {
711 template<
class VX,
class VB, ReifyMode rm>
714 assert(!b.assigned());
718 for (
int i=n_x;
i--; )
721 }
else if (x[
i].
one()) {
722 x[
i] = x[--n_x]; c--;
725 if ((n_x < c) || (c < 0)) {
729 }
else if ((c == 0) && (n_x == 0)) {
733 }
else if ((c == 0) && (rm ==
RM_EQV)) {
737 }
else if ((c == n_x) && (rm ==
RM_EQV)) {
740 for (
int i=n_x;
i--; )
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
ViewArray< VX > x
Boolean views.
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
void update(Space &, bool share, ViewArray< View > &a)
Update array to be a clone of array a.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear)
Inverse implication for reification.
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
ExecStatus ES_SUBSUMED(Propagator &p)
GqBoolInt(Space &home, bool share, GqBoolInt &p)
Constructor for cloning p.
NqBoolInt(Home home, ViewArray< VX > &b, int c)
Constructor for posting.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
bool one(const Gecode::FloatValArgs &a)
Check whether has only one coefficients.
void post(Home home, Term< BoolView > *t, int n, IntRelType irt, IntView x, int c, IntConLevel)
Post propagator for linear constraint over Booleans.
void cancel(Space &home, Propagator &p, IntSet &y)
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high unary)
ExecStatus resubscribe(Space &home, Propagator &p, VX &x0, ViewArray< VX > &x, VY &x1, ViewArray< VY > &y)
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Baseclass for integer Boolean sum.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
static ExecStatus post(Home home, ViewArray< VX > &x, int c, VB b)
Post propagator for .
static ExecStatus post(Home home, ViewArray< VX > &x, int c, VB b)
Post propagator for .
static ExecStatus post(Home home, ViewArray< VX > &x, int c)
Post propagator for .
Propagator for integer disequal to Boolean sum (cardinality)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
bool normalize(Term< View > *t, int &n, Term< View > *&t_p, int &n_p, Term< View > *&t_n, int &n_n, int &g)
Normalize linear integer constraints.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
A & advisor(void) const
Return advisor.
Base-class for propagators.
ReGqBoolInt(Space &home, bool share, ReGqBoolInt &p)
Constructor for cloning p.
ReEqBoolInt(Space &home, bool share, ReEqBoolInt &p)
Constructor for cloning p.
Class to iterate over advisors of a council.
ReLinBoolInt(Space &home, bool share, ReLinBoolInt &p)
Constructor for cloning p.
Propagation has computed fixpoint.
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Base-class for both propagators and branchers.
Council< Advisor > co
Council for single advisor.
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
int n_as
Number of active subscriptions.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Execution has resulted in failure.
EqBoolInt(Space &home, bool share, EqBoolInt &p)
Constructor for cloning p.
Propagator for integer less or equal to Boolean sum (cardinality)
void subscribe(Space &home, Propagator &p, PropCond pc, bool process=true)
Subscribe propagator p with propagation condition pc to variable.
View base(void) const
Return view from which this view is derived.
Propagator for integer equal to Boolean sum (cardinality)
void subscribe(Space &home, Propagator &p, IntSet &y)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
unsigned int size(I &i)
Size of all ranges of range iterator i.
static ExecStatus post(Home home, ViewArray< VX > &x, int c)
Post propagator for .
bool resubscribe(Space &home, VX &y)
Update subscription.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
void normalize(void)
Normalize by removing unused views.
Propagator for reified integer less or equal to Boolean sum (cardinality)
void normalize(void)
Normalize by removing unused views.
Propagator for reified integer equal to Boolean sum (cardinality)
#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.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Baseclass for reified integer Boolean sum.
void check(const FloatVal &n, const char *l)
Check whether float n is a valid number, otherwise throw out of limits exception with information l...
static NegBoolView neg(BoolView x)
Return negated View.
static ExecStatus post(Home home, ViewArray< VX > &b, int c)
Post propagator for .
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Node * x
Pointer to corresponding Boolean expression node.
NegBoolView NegView
The negated view.
Generic domain change information to be supplied to advisors.
Traits for Boolean negation view.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual size_t dispose(Space &home)
Delete actor and return its size.
BoolView NegView
The negated view.
Boolean n-ary disjunction propagator.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
LinBoolInt(Space &home, bool share, LinBoolInt &p)
Constructor for cloning p.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Propagation has not computed fixpoint.
Council< Advisor > co
Council for managing single advisor.
static ExecStatus post(Home home, ViewArray< BV > &b)
Post propagator .
ViewArray< VX > x
Views not yet subscribed to.
int size(void) const
Return size of array (number of elements)
static ExecStatus post(Home home, ViewArray< VX > &x, VY y)
Post propagator .
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
Implication for reification.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high unary)
virtual size_t dispose(Space &home)
Delete propagator and return its size.
static BoolView neg(NegBoolView x)
Return negated View.
int ModEventDelta
Modification event deltas.
Home class for posting propagators
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
Equivalence for reification (default)
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.