38 namespace Gecode {
namespace Int {
namespace Linear {
72 int n =
static_cast<int>(sba._lst - sba._fst);
76 for (
int i=n;
i--; ) {
77 _fst[
i].
a = sba._fst[
i].
a;
106 return static_cast<int>(_lst - _fst);
109 ScaleBoolArray::ScaleDec::operator ()(
const ScaleBool&
x,
117 Support::quicksort<ScaleBool,ScaleDec>(
fst(),
size(), scale_dec);
158 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
164 x.subscribe(home,*
this,pcx);
165 p.subscribe(home,*
this);
166 n.subscribe(home,*
this);
169 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
176 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
179 x.reschedule(home,*
this,pcx);
180 p.reschedule(home,*
this);
181 n.reschedule(home,*
this);
184 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
187 x.cancel(home,*
this,pcx);
188 p.cancel(home,*
this);
189 n.cancel(home,*
this);
190 (void) Propagator::dispose(home);
191 return sizeof(*this);
194 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
201 x.update(home,share,x0);
202 p.update(home,share,p0);
203 n.update(home,share,n0);
211 template<
class SBAP,
class SBAN,
class VX>
218 template<
class SBAP,
class SBAN,
class VX>
226 template<
class SBAP,
class SBAN,
class VX>
234 (home,share,*
this,ep,
n,z,
c+x.val());
237 (home,share,*
this,ep,
n,x,
c);
239 }
else if (
n.empty()) {
244 (home,share,*
this,
p,en,z,
c+x.val());
247 (home,share,*
this,
p,en,x,
c);
254 template<
class SBAP,
class SBAN,
class VX>
265 while ((f < l) && f->
x.
none()) {
273 }
else if (f->
x.
none()) {
274 su_n += f->
a; *t = *f; t++;
285 while ((f < l) && f->
x.
none()) {
293 }
else if (f->
x.
none()) {
294 sl_p += f->
a; *t = *f; t++;
307 if (
p.empty() &&
n.empty()) {
315 const int MOD_SL = 1 << 0;
316 const int MOD_SU = 1 << 1;
318 int mod = MOD_SL | MOD_SU;
321 if ((mod & MOD_SL) != 0) {
331 p.fst(f); mod |= MOD_SU;
342 n.fst(f); mod |= MOD_SU;
347 const int x_min = x.min();
348 ModEvent me = x.gq(home,x.max() - sl_p);
352 su_n -= x.min() - x_min;
357 if ((mod & MOD_SU) != 0) {
367 p.fst(f); mod |= MOD_SL;;
378 n.fst(f); mod |= MOD_SL;;
383 const int x_max = x.max();
384 ModEvent me = x.lq(home,x.min() + su_n);
388 sl_p += x.max() - x_max;
400 template<
class SBAP,
class SBAN,
class VX>
403 SBAP&
p, SBAN&
n, VX x,
int c) {
409 }
else if (n.empty()) {
426 template<
class SBAP,
class SBAN,
class VX>
433 template<
class SBAP,
class SBAN,
class VX>
441 template<
class SBAP,
class SBAN,
class VX>
449 (home,share,*
this,ep,
n,z,
c+x.val());
452 (home,share,*
this,ep,
n,x,
c);
454 }
else if (
n.empty()) {
459 (home,share,*
this,
p,en,z,
c+x.val());
462 (home,share,*
this,
p,en,x,
c);
469 template<
class SBAP,
class SBAN,
class VX>
479 while ((f < l) && f->
x.
none())
486 }
else if (f->
x.
none()) {
498 while ((f < l) && f->
x.
none()) {
506 }
else if (f->
x.
none()) {
507 sl += f->
a; *t = *f; t++;
539 const int slx = x.max() - sl;
547 if (
p.empty() &&
n.empty())
555 template<
class SBAP,
class SBAN,
class VX>
558 SBAP&
p, SBAN&
n, VX x,
int c) {
564 }
else if (n.empty()) {
580 template<
class SBAP,
class SBAN,
class VX>
587 template<
class SBAP,
class SBAN,
class VX>
595 template<
class SBAP,
class SBAN,
class VX>
603 (home,share,*
this,ep,
n,z,
c+x.val());
606 (home,share,*
this,ep,
n,x,
c);
608 }
else if (
n.empty()) {
613 (home,share,*
this,
p,en,z,
c+x.val());
616 (home,share,*
this,
p,en,x,
c);
623 template<
class SBAP,
class SBAN,
class VX>
634 c -= f->
a; *f = *(t++);
635 }
else if (f->
x.
zero()) {
649 c += f->
a; *f = *(t++);
650 }
else if (f->
x.
zero()) {
659 if (
p.empty() &&
n.empty()) {
666 if (
p.empty() && (
n.size() == 1)) {
667 if (r == -
n.fst()->a) {
674 if ((
p.size() == 1) &&
n.empty()) {
675 if (r ==
p.fst()->a) {
688 template<
class SBAP,
class SBAN,
class VX>
691 SBAP&
p, SBAN&
n, VX x,
int c) {
696 }
else if (n.empty()) {
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl)
Post propagator for .
void sort(void)
Sort array in decreasing order of coefficients.
Propagator for inequality to Boolean sum with coefficients
bool zero(void) const
Test whether view is assigned to be zero.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatNum c)
Post propagator for .
Empty array of scale Boolean views.
ScaleBool * lst(void) const
Return pointer after last element.
ExecStatus ES_SUBSUMED(Propagator &p)
ScaleBool * lst(void) const
Return pointer after last element.
void subscribe(Space &home, Propagator &p)
Subscribe propagator p.
bool one(void) const
Test whether view is assigned to be one.
void reschedule(Space &home, Propagator &p)
Schedule propagator p.
int ModEvent
Type for modification events.
Base-class for propagators.
void sort(void)
Sort array in decreasing order of coefficients.
static ExecStatus post(Home home, SBAP &p, SBAN &n, VX x, int c)
Post propagator.
void cancel(Space &home, Propagator &p)
Cancel propagator p.
Propagation has computed fixpoint.
Base-class for both propagators and branchers.
int c
Integer constant on right-hand side.
Propagator for equality to Boolean sum with coefficients
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
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.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
LqBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
Execution has resulted in failure.
ModEvent zero_none(Space &home)
Assign not yet assigned view to zero.
EqBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
static ExecStatus post(Home home, SBAP &p, SBAN &n, VX x, int c)
Post propagator.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
ModEventDelta med
A set of modification events (used during propagation)
int size(void) const
Return number of elements.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
ScaleBoolArray(void)
Default constructor.
void subscribe(Space &home, Propagator &p)
Subscribe propagator p.
void update(Space &home, bool share, VarImpView< Var > &y)
Update this view to be a clone of view y.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Propagator for disequality to Boolean sum with coefficients
SBAN n
Negative Boolean views with coefficients on left-hand side.
EmptyScaleBoolArray(void)
Default constructor.
Base class for linear Boolean constraints with coefficients.
void update(Space &home, bool share, ScaleBoolArray &sba)
Update sba during copying.
Array of scale Boolean views.
Node * x
Pointer to corresponding Boolean expression node.
SBAP p
Positive Boolean views with coefficients on left-hand side.
int size(void) const
Return number of elements.
ScaleBool * fst(void) const
Return pointer to first element.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
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.
Coefficient and Boolean view.
NqBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
Propagation has not computed fixpoint.
void cancel(Space &home, Propagator &p)
Cancel propagator p.
bool empty(void) const
Test whether array is empty.
Gecode toplevel namespace
void update(Space &home, bool share, EmptyScaleBoolArray &esba)
Update sba during copying.
ModEvent one_none(Space &home)
Assign not yet assigned view to one.
int a
Integer coefficient.
bool none(void) const
Test whether view is not yet assigned.
void reschedule(Space &home, Propagator &p, IntSet &y)
LinBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
void reschedule(Space &home, Propagator &p)
Schedule propagator p.
bool empty(void) const
Test whether array is empty.
int ModEventDelta
Modification event deltas.
static ExecStatus post(Home home, SBAP &p, SBAN &n, VX x, int c)
Post propagator.
Home class for posting propagators
VX x
Integer view on right-hand side.
ScaleBool * fst(void) const
Return pointer to first element.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
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)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
const Gecode::ModEvent ME_BOOL_VAL
Domain operation has resulted in a value (assigned variable)