40namespace Gecode {
namespace Int {
namespace Linear {
50 :
Propagator(home), co(home),
x(x0), n_as(n_s), n_hs(n_s), c(c0) {
52 for (
int i=0; i<
n_as; i++)
53 x[i].subscribe(home,*
a);
62 for (
int i=n_hs; i--; )
64 x[i]=
x[--n_hs];
x[n_hs]=
x[--n_x];
72 for (
int i=n_x-1; i>=n_hs; i--)
75 }
else if (
x[i].zero()) {
102 for (
int i=0; i<n_hs; i++)
106 return sizeof(*this);
142 for (
int i =
x.size()-1; i>=n_hs; i--)
144 std::swap(
x[i],
x[n_hs]);
145 x[n_hs++].subscribe(home,
a);
148 }
else if (
x[i].one()) {
152 assert(n_hs <=
x.size());
161 int n =
x.size()-n_hs+n_as;
162 if ((
n < c) && !disabled())
164 if ((c <= 0) || (c ==
n))
173 int n =
x.size()-n_hs+n_as;
174 if ((c <= 0) || (c >=
n))
182 if (
x.size() - n_hs + n_as < c)
185 assert((n_as == c) && (
x.size() == n_hs));
189 for (
int i=0; i<n_hs; i++)
201 for (
int i=n_x; i--; )
204 }
else if (
x[i].one()) {
205 x[i] =
x[--n_x]; c--;
219 for (
int i=0; i<n_x; i++)
261 if ((c+1 < n_as) && (
x.size()-n_hs < c))
264 for (
int i =
x.size()-1; i>=n_hs; i--)
266 std::swap(
x[i],
x[n_hs]);
267 x[n_hs++].subscribe(home,
a);
270 }
else if (
x[i].one()) {
278 int n =
x.size()-n_hs+n_as;
279 if (((c < 0) || (c >
n)) && !disabled())
281 if ((c == 0) || (c ==
n))
290 int n =
x.size()-n_hs+n_as;
291 if ((c <= 0) || (c >=
n))
299 if ((c < 0) || (c >
x.size()-n_hs+n_as))
302 assert(
x.size() == n_hs);
307 for (
int i=0; i<n_hs; i++)
312 for (
int i=0; i<n_hs; i++)
324 for (
int i=n_x; i--; )
327 }
else if (
x[i].one()) {
328 x[i] =
x[--n_x]; c--;
332 if ((c < 0) || (c > n_x))
336 for (
int i=0; i<n_x; i++)
342 for (
int i=0; i<n_x; i++)
361 b[
b.size()-1]),
x(
b), c(c0) {
362 assert(
x.
size() >= 2);
370 return sizeof(*this);
382 n--; p.x[i]=p.x[n]; x[i]=x[n];
383 }
else if (
p.x[i].one()) {
384 n--; p_c--; p.x[i]=p.x[n]; x[i]=x[n];
386 x[i].update(home,p.x[i]);
399 }
else if (
x[i].zero()) {
403 if ((
n < c) || (c < 0))
440 }
else if (
x[i].zero()) {
444 assert(!
x[i].zero() && !
x[i].one());
460 if (x0.zero() || x0.one())
461 s0 = resubscribe(home,x0);
463 if (x1.zero() || x1.one())
464 s1 = resubscribe(home,x1);
465 int n =
x.size() + s0 + s1;
466 if ((
n < c) || (c < 0))
494 template<
class VX,
class VB>
498 :
Propagator(home), co(home),
x(x0), n_s(
x.size()), c(c0),
b(b0) {
503 template<
class VX,
class VB>
506 if (n_s !=
x.size()) {
508 for (
int i=n_x; i--; )
512 assert(
x.size() == n_s);
516 template<
class VX,
class VB>
521 co.update(home,
p.co);
526 template<
class VX,
class VB>
534 return sizeof(*this);
537 template<
class VX,
class VB>
572 template<
class VX,
class VB, ReifyMode rm>
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 if ((n_s < c) || (c <= 0))
600 template<
class VX,
class VB, ReifyMode rm>
604 if ((n_s < c) || (c <= 0))
608 template<
class VX,
class VB, ReifyMode rm>
627 for (
int i=0; i<
x.size(); i++)
630 ::post(home(*
this),nx,
x.size()-c+1));
637 template<
class VX,
class VB, ReifyMode rm>
640 assert(!
b.assigned());
644 for (
int i=n_x; i--; )
647 }
else if (
x[i].one()) {
648 x[i] =
x[--n_x]; c--;
659 }
else if ((c == 1) && (rm ==
RM_EQV)) {
662 }
else if ((c == n_x) && (rm ==
RM_EQV)) {
665 for (
int i=0; i<n_x; i++)
681 template<
class VX,
class VB, ReifyMode rm>
686 template<
class VX,
class VB, ReifyMode rm>
691 template<
class VX,
class VB, ReifyMode rm>
697 template<
class VX,
class VB, ReifyMode rm>
704 if ((c < 0) || (c > n_s) || (n_s == 0))
710 template<
class VX,
class VB, ReifyMode rm>
714 if ((c < 0) || (c > n_s) || (n_s == 0))
718 template<
class VX,
class VB, ReifyMode rm>
722 if ((c == 0) && (n_s == 0)) {
742 template<
class VX,
class VB, ReifyMode rm>
745 assert(!
b.assigned());
749 for (
int i=n_x; i--; )
752 }
else if (
x[i].one()) {
753 x[i] =
x[--n_x]; c--;
756 if ((n_x < c) || (c < 0)) {
760 }
else if ((c == 0) && (n_x == 0)) {
764 }
else if ((c == 0) && (rm ==
RM_EQV)) {
768 }
else if ((c == n_x) && (rm ==
RM_EQV)) {
771 for (
int i=0; i<n_x; i++)
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Base-class for both propagators and branchers.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Class to iterate over advisors of a council.
A & advisor(void) const
Return advisor.
Generic domain change information to be supplied to advisors.
Home class for posting propagators
Boolean view for Boolean variables.
static ExecStatus post(Home home, ViewArray< BV > &b)
Post propagator .
Boolean n-ary disjunction propagator.
static ExecStatus post(Home home, ViewArray< VX > &x, VY y)
Post propagator .
NegBoolView NegView
The negated view.
static NegBoolView neg(BoolView x)
Return negated View.
BoolView NegView
The negated view.
static BoolView neg(NegBoolView x)
Return negated View.
Traits for Boolean negation view.
Propagator for integer equal to Boolean sum (cardinality)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
virtual void reschedule(Space &home)
Schedule function.
static ExecStatus post(Home home, ViewArray< VX > &x, int c)
Post propagator for .
virtual Actor * copy(Space &home)
Create copy during cloning.
EqBoolInt(Space &home, EqBoolInt &p)
Constructor for cloning p.
Propagator for integer less or equal to Boolean sum (cardinality)
virtual void reschedule(Space &home)
Schedule function.
GqBoolInt(Space &home, GqBoolInt &p)
Constructor for cloning p.
virtual Actor * copy(Space &home)
Create copy during cloning.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ExecStatus post(Home home, ViewArray< VX > &x, int c)
Post propagator for .
Baseclass for integer Boolean sum.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high unary)
int n_as
Number of active subscriptions.
void normalize(void)
Normalize by removing unused views.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Council< Advisor > co
Council for managing single advisor.
ViewArray< VX > x
Boolean views.
LinBoolInt(Space &home, LinBoolInt &p)
Constructor for cloning p.
Propagator for integer disequal to Boolean sum (cardinality)
static ExecStatus post(Home home, ViewArray< VX > &b, int c)
Post propagator for .
bool resubscribe(Space &home, VX &y)
Update subscription.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear)
virtual size_t dispose(Space &home)
Delete propagator and return its size.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
NqBoolInt(Home home, ViewArray< VX > &b, int c)
Constructor for posting.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
ViewArray< VX > x
Views not yet subscribed to.
Propagator for reified integer equal to Boolean sum (cardinality)
virtual Actor * copy(Space &home)
Create copy during cloning.
static ExecStatus post(Home home, ViewArray< VX > &x, int c, VB b)
Post propagator for .
virtual void reschedule(Space &home)
Schedule function.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
ReEqBoolInt(Space &home, ReEqBoolInt &p)
Constructor for cloning p.
Propagator for reified integer less or equal to Boolean sum (cardinality)
virtual void reschedule(Space &home)
Schedule function.
static ExecStatus post(Home home, ViewArray< VX > &x, int c, VB b)
Post propagator for .
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
virtual Actor * copy(Space &home)
Create copy during cloning.
ReGqBoolInt(Space &home, ReGqBoolInt &p)
Constructor for cloning p.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Baseclass for reified integer Boolean sum.
Council< Advisor > co
Council for single advisor.
void normalize(void)
Normalize by removing unused views.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high unary)
ReLinBoolInt(Space &home, ReLinBoolInt &p)
Constructor for cloning p.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
Base-class for propagators.
VarImp * x
Pointer to variable implementation.
void update(Space &home, ViewArray< View > &a)
Update array to be a clone of array a.
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to variable.
int size(void) const
Return size of array (number of elements)
void post(Home home, Term< IntView > *t, int n, IntRelType irt, int c, IntPropLevel=IPL_DEF)
Post propagator for linear constraint over integers.
ExecStatus ES_SUBSUMED(Propagator &p)
int ModEventDelta
Modification event deltas.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
@ RM_IMP
Implication for reification.
@ RM_PMI
Inverse implication for reification.
@ RM_EQV
Equivalence for reification (default)
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.
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
const Gecode::ModEvent ME_BOOL_VAL
Domain operation has resulted in a value (assigned variable)
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar y
@ ES_OK
Execution is okay.
@ ES_FIX
Propagation has computed fixpoint.
@ ES_FAILED
Execution has resulted in failure.
@ ES_NOFIX
Propagation has not computed fixpoint.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar x