34 namespace Gecode {
namespace Int {
namespace Linear {
68 int n =
static_cast<int>(sba._lst - sba._fst);
72 for (
int i=n;
i--; ) {
73 _fst[
i].
a = sba._fst[
i].
a;
102 return static_cast<int>(_lst - _fst);
105 ScaleBoolArray::ScaleDec::operator ()(
const ScaleBool&
x,
113 Support::quicksort<ScaleBool,ScaleDec>(
fst(),
size(), scale_dec);
154 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
160 x.subscribe(home,*
this,pcx);
161 p.subscribe(home,*
this);
162 n.subscribe(home,*
this);
165 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
172 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
175 x.reschedule(home,*
this,pcx);
176 p.reschedule(home,*
this);
177 n.reschedule(home,*
this);
180 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
183 x.cancel(home,*
this,pcx);
184 p.cancel(home,*
this);
185 n.cancel(home,*
this);
186 (void) Propagator::dispose(home);
187 return sizeof(*this);
190 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
207 template<
class SBAP,
class SBAN,
class VX>
214 template<
class SBAP,
class SBAN,
class VX>
222 template<
class SBAP,
class SBAN,
class VX>
230 (home,*
this,ep,
n,z,
c+x.val());
233 (home,*
this,ep,
n,x,
c);
235 }
else if (
n.empty()) {
240 (home,*
this,
p,en,z,
c+x.val());
243 (home,*
this,
p,en,x,
c);
250 template<
class SBAP,
class SBAN,
class VX>
261 while ((f < l) && f->
x.
none()) {
269 }
else if (f->
x.
none()) {
270 su_n += f->
a; *t = *
f; t++;
281 while ((f < l) && f->
x.
none()) {
289 }
else if (f->
x.
none()) {
290 sl_p += f->
a; *t = *
f; t++;
303 if (
p.empty() &&
n.empty()) {
311 const int MOD_SL = 1 << 0;
312 const int MOD_SU = 1 << 1;
314 int mod = MOD_SL | MOD_SU;
317 if ((mod & MOD_SL) != 0) {
327 p.fst(f); mod |= MOD_SU;
338 n.fst(f); mod |= MOD_SU;
343 const int x_min = x.min();
344 ModEvent me = x.gq(home,x.max() - sl_p);
348 su_n -= x.min() - x_min;
353 if ((mod & MOD_SU) != 0) {
363 p.fst(f); mod |= MOD_SL;;
374 n.fst(f); mod |= MOD_SL;;
379 const int x_max = x.max();
380 ModEvent me = x.lq(home,x.min() + su_n);
384 sl_p += x.max() - x_max;
396 template<
class SBAP,
class SBAN,
class VX>
399 SBAP&
p, SBAN&
n, VX x,
int c) {
405 }
else if (n.empty()) {
422 template<
class SBAP,
class SBAN,
class VX>
429 template<
class SBAP,
class SBAN,
class VX>
437 template<
class SBAP,
class SBAN,
class VX>
445 (home,*
this,ep,
n,z,
c+x.val());
448 (home,*
this,ep,
n,x,
c);
450 }
else if (
n.empty()) {
455 (home,*
this,
p,en,z,
c+x.val());
458 (home,*
this,
p,en,x,
c);
465 template<
class SBAP,
class SBAN,
class VX>
475 while ((f < l) && f->
x.
none())
482 }
else if (f->
x.
none()) {
494 while ((f < l) && f->
x.
none()) {
502 }
else if (f->
x.
none()) {
503 sl += f->
a; *t = *
f; t++;
535 const int slx = x.max() - sl;
543 if (
p.empty() &&
n.empty())
551 template<
class SBAP,
class SBAN,
class VX>
554 SBAP&
p, SBAN&
n, VX x,
int c) {
560 }
else if (n.empty()) {
576 template<
class SBAP,
class SBAN,
class VX>
583 template<
class SBAP,
class SBAN,
class VX>
591 template<
class SBAP,
class SBAN,
class VX>
599 (home,*
this,ep,
n,z,
c+x.val());
602 (home,*
this,ep,
n,x,
c);
604 }
else if (
n.empty()) {
609 (home,*
this,
p,en,z,
c+x.val());
612 (home,*
this,
p,en,x,
c);
619 template<
class SBAP,
class SBAN,
class VX>
630 c -= f->
a; *f = *(t++);
631 }
else if (f->
x.
zero()) {
645 c += f->
a; *f = *(t++);
646 }
else if (f->
x.
zero()) {
655 if (
p.empty() &&
n.empty()) {
662 if (
p.empty() && (
n.size() == 1)) {
663 if (r == -
n.fst()->a) {
670 if ((
p.size() == 1) &&
n.empty()) {
671 if (r ==
p.fst()->a) {
684 template<
class SBAP,
class SBAN,
class VX>
687 SBAP&
p, SBAN&
n, VX x,
int c) {
692 }
else if (n.empty()) {
void update(Space &home, ScaleBoolArray &sba)
Update sba during copying.
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.
void update(Space &home, VarImpView< Var > &y)
Update this view to be a clone of view y.
Propagator for inequality to Boolean sum with coefficients
bool zero(void) const
Test whether view is assigned to be zero.
Empty array of scale Boolean views.
ScaleBool * lst(void) const
Return pointer after last element.
void update(Space &home, EmptyScaleBoolArray &esba)
Update sba during copying.
ExecStatus ES_SUBSUMED(Propagator &p)
ScaleBool * lst(void) const
Return pointer after last element.
void subscribe(Space &home, Propagator &p)
Subscribe propagator p.
virtual Actor * copy(Space &home)
Create copy during cloning.
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.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
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.
virtual Actor * copy(Space &home)
Create copy during cloning.
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.
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.
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
void subscribe(Space &home, Propagator &p)
Subscribe propagator p.
#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.
Post propagator for SetVar SetOpType SetVar SetRelType r
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Post propagator for SetVar SetOpType SetVar y
Array of scale Boolean views.
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.
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.
Post propagator for SetVar x
Propagation has not computed fixpoint.
void cancel(Space &home, Propagator &p)
Cancel propagator p.
bool empty(void) const
Test whether array is empty.
virtual Actor * copy(Space &home)
Create copy during cloning.
Gecode toplevel namespace
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.
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)