Go to the documentation of this file.
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()) {
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--)
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;
166 if ((
n <
c) && !disabled())
168 if ((
c <= 0) || (
c ==
n))
177 int n =
x.size()-n_hs+n_as;
178 if ((
c <= 0) || (
c >=
n))
186 if (
x.size() - n_hs + n_as <
c)
189 assert((n_as ==
c) && (
x.size() == n_hs));
193 for (
int i=n_hs;
i--; )
205 for (
int i=n_x;
i--; )
208 }
else if (
x[
i].
one()) {
209 x[
i] =
x[--n_x];
c--;
223 for (
int i=n_x;
i--; )
265 if ((
c+1 < n_as) && (
x.size()-n_hs <
c))
268 for (
int i =
x.size()-1;
i>=n_hs;
i--)
271 x[n_hs++].subscribe(home,
a);
274 }
else if (
x[
i].
one()) {
282 int n =
x.size()-n_hs+n_as;
283 if (((
c < 0) || (
c >
n)) && !disabled())
285 if ((
c == 0) || (
c ==
n))
294 int n =
x.size()-n_hs+n_as;
295 if ((
c <= 0) || (
c >=
n))
303 if ((
c < 0) || (
c >
x.size()-n_hs+n_as))
306 assert(
x.size() == n_hs);
311 for (
int i=n_hs;
i--; )
316 for (
int i=n_hs;
i--; )
328 for (
int i=n_x;
i--; )
331 }
else if (
x[
i].
one()) {
332 x[
i] =
x[--n_x];
c--;
336 if ((
c < 0) || (
c > n_x))
340 for (
int i=n_x;
i--; )
346 for (
int i=n_x;
i--; )
366 assert(
x.
size() >= 2);
374 return sizeof(*this);
387 }
else if (
p.x[
i].one()) {
403 }
else if (
x[
i].zero()) {
407 if ((
n <
c) || (
c < 0))
444 }
else if (
x[
i].zero()) {
448 assert(!
x[
i].zero() && !
x[
i].
one());
464 if (x0.zero() || x0.one())
467 if (x1.zero() || x1.one())
469 int n =
x.size() + s0 + s1;
470 if ((
n <
c) || (
c < 0))
498 template<
class VX,
class VB>
507 template<
class VX,
class VB>
510 if (n_s !=
x.size()) {
512 for (
int i=n_x;
i--; )
516 assert(
x.size() == n_s);
520 template<
class VX,
class VB>
526 co.update(home,share,
p.co);
528 b.update(home,share,
p.b);
531 template<
class VX,
class VB>
539 return sizeof(*this);
542 template<
class VX,
class VB>
577 template<
class VX,
class VB, ReifyMode rm>
582 template<
class VX,
class VB, ReifyMode rm>
588 template<
class VX,
class VB, ReifyMode rm>
594 template<
class VX,
class VB, ReifyMode rm>
600 if ((n_s <
c) || (
c <= 0))
606 template<
class VX,
class VB, ReifyMode rm>
610 if ((n_s <
c) || (
c <= 0))
614 template<
class VX,
class VB, ReifyMode rm>
633 for (
int i=
x.size();
i--; )
636 ::
post(home(*
this),nx,
x.size()-
c+1));
643 template<
class VX,
class VB, ReifyMode rm>
646 assert(!
b.assigned());
650 for (
int i=n_x;
i--; )
653 }
else if (
x[
i].
one()) {
654 x[
i] =
x[--n_x];
c--;
665 }
else if ((
c == 1) && (rm ==
RM_EQV)) {
668 }
else if ((
c == n_x) && (rm ==
RM_EQV)) {
671 for (
int i=n_x;
i--; )
687 template<
class VX,
class VB, ReifyMode rm>
692 template<
class VX,
class VB, ReifyMode rm>
698 template<
class VX,
class VB, ReifyMode rm>
704 template<
class VX,
class VB, ReifyMode rm>
711 if ((
c < 0) || (
c > n_s) || (n_s == 0))
717 template<
class VX,
class VB, ReifyMode rm>
721 if ((
c < 0) || (
c > n_s) || (n_s == 0))
725 template<
class VX,
class VB, ReifyMode rm>
729 if ((
c == 0) && (n_s == 0)) {
749 template<
class VX,
class VB, ReifyMode rm>
752 assert(!
b.assigned());
756 for (
int i=n_x;
i--; )
759 }
else if (
x[
i].
one()) {
760 x[
i] =
x[--n_x];
c--;
763 if ((n_x <
c) || (
c < 0)) {
767 }
else if ((
c == 0) && (n_x == 0)) {
771 }
else if ((
c == 0) && (rm ==
RM_EQV)) {
775 }
else if ((
c == n_x) && (rm ==
RM_EQV)) {
778 for (
int i=n_x;
i--; )
Post propagator for SetVar x
Propagator for reified integer equal to Boolean sum (cardinality)
Baseclass for integer Boolean sum.
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
Post propagator for SetVar SetOpType SetVar y
Propagator for integer disequal to Boolean sum (cardinality)
Propagator for reified integer less or equal to Boolean sum (cardinality)
ReGqBoolInt(Space &home, bool share, ReGqBoolInt &p)
Constructor for cloning p.
@ RM_PMI
Inverse implication for reification.
void update(Space &, bool share, ViewArray< View > &a)
Update array to be a clone of array a.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to variable.
ExecStatus ES_SUBSUMED(Propagator &p)
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
unsigned int size(I &i)
Size of all ranges of range iterator i.
ReLinBoolInt(Space &home, bool share, ReLinBoolInt &p)
Constructor for cloning p.
ReEqBoolInt(Space &home, bool share, ReEqBoolInt &p)
Constructor for cloning p.
virtual void reschedule(Space &home)
Schedule function.
Class to iterate over advisors of a council.
@ RM_IMP
Implication for reification.
Gecode::IntArgs i(4, 1, 2, 3, 4)
NegBoolView NegView
The negated view.
GqBoolInt(Space &home, bool share, GqBoolInt &p)
Constructor for cloning p.
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
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.
Base-class for both propagators and branchers.
LinBoolInt(Space &home, bool share, LinBoolInt &p)
Constructor for cloning p.
const Gecode::ModEvent ME_BOOL_VAL
Domain operation has resulted in a value (assigned variable)
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
EqBoolInt(Space &home, bool share, EqBoolInt &p)
Constructor for cloning p.
Propagator for integer less or equal to Boolean sum (cardinality)
Propagator for integer equal to Boolean sum (cardinality)
virtual void reschedule(Space &home)
Schedule function.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
ViewArray< VX > x
Boolean views.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
static ExecStatus post(Home home, ViewArray< VX > &x, int c, VB b)
Post propagator for .
static ExecStatus post(Home home, ViewArray< VX > &b, int c)
Post propagator for .
Boolean view for Boolean variables.
Gecode toplevel namespace
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Base-class for propagators.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
ExecStatus resubscribe(Space &home, Propagator &p, VX &x0, ViewArray< VX > &x, VY &x1, ViewArray< VY > &y)
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high unary)
static ExecStatus post(Home home, ViewArray< VX > &x, int c)
Post propagator for .
Traits for Boolean negation view.
Generic domain change information to be supplied to advisors.
BoolView NegView
The negated view.
@ RM_EQV
Equivalence for reification (default)
Home class for posting propagators
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
Boolean n-ary disjunction propagator.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear)
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
IntRelType swap(IntRelType irt)
Return swapped relation type of irt.
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.
Baseclass for reified integer Boolean sum.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
NqBoolInt(Home home, ViewArray< VX > &b, int c)
Constructor for posting.
static BoolView neg(NegBoolView x)
Return negated View.
static ExecStatus post(Home home, ViewArray< VX > &x, int c)
Post propagator for .
void normalize(void)
Normalize by removing unused views.
static NegBoolView neg(BoolView x)
Return negated View.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
void normalize(void)
Normalize by removing unused views.
int n_as
Number of active subscriptions.
void cancel(Space &home, Propagator &p, IntSet &y)
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
@ ES_FIX
Propagation has computed fixpoint.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
bool neg
Is atomic formula negative.
int size(void) const
Return size of array (number of elements)
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.
bool resubscribe(Space &home, VX &y)
Update subscription.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high unary)
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Council< Advisor > co
Council for single advisor.
void post(Home home, Term< BoolView > *t, int n, IntRelType irt, IntView x, int c, IntPropLevel)
Post propagator for linear constraint over Booleans.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Gecode::FloatVal c(-8, 8)
A & advisor(void) const
Return advisor.
void subscribe(Space &home, Propagator &p, IntSet &y)
int n
Number of negative literals for node type.
@ ES_FAILED
Execution has resulted in failure.
int ModEventDelta
Modification event deltas.
@ ES_NOFIX
Propagation has not computed fixpoint.
Council< Advisor > co
Council for managing single advisor.
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
@ ES_OK
Execution is okay.
int p
Number of positive literals for node type.
static ExecStatus post(Home home, ViewArray< VX > &x, int c, VB b)
Post propagator for .
ViewArray< VX > x
Views not yet subscribed to.
virtual void reschedule(Space &home)
Schedule function.
static ExecStatus post(Home home, ViewArray< VX > &x, VY y)
Post propagator .
virtual void reschedule(Space &home)
Schedule function.
static ExecStatus post(Home home, ViewArray< BV > &b)
Post propagator .