38 namespace Gecode {
namespace Int {
namespace Linear {
67 int n =
static_cast<int>(sba._lst - sba._fst);
71 for (
int i=n;
i--; ) {
72 _fst[
i].
a = sba._fst[
i].
a;
101 return static_cast<int>(_lst - _fst);
104 ScaleBoolArray::ScaleDec::operator ()(
const ScaleBool&
x,
112 Support::quicksort<ScaleBool,ScaleDec>(
fst(),
size(), scale_dec);
151 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
157 x.subscribe(home,*
this,pcx);
158 p.subscribe(home,*
this);
159 n.subscribe(home,*
this);
162 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
169 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
172 x.cancel(home,*
this,pcx);
173 p.cancel(home,*
this);
174 n.cancel(home,*
this);
176 return sizeof(*this);
179 template<
class SBAP,
class SBAN,
class VX, PropCond pcx>
186 x.update(home,share,x0);
187 p.update(home,share,p0);
188 n.update(home,share,n0);
196 template<
class SBAP,
class SBAN,
class VX>
203 template<
class SBAP,
class SBAN,
class VX>
211 template<
class SBAP,
class SBAN,
class VX>
219 (home,share,*
this,ep,
n,z,
c+
x.val());
222 (home,share,*
this,ep,
n,
x,
c);
224 }
else if (
n.empty()) {
229 (home,share,*
this,
p,en,z,
c+
x.val());
232 (home,share,*
this,
p,en,
x,
c);
239 template<
class SBAP,
class SBAN,
class VX>
250 while ((f < l) && f->
x.
none()) {
258 }
else if (f->
x.
none()) {
259 su_n += f->
a; *t = *f; t++;
270 while ((f < l) && f->
x.
none()) {
278 }
else if (f->
x.
none()) {
279 sl_p += f->
a; *t = *f; t++;
292 if (
p.empty() &&
n.empty()) {
300 const int MOD_SL = 1 << 0;
301 const int MOD_SU = 1 << 1;
303 int mod = MOD_SL | MOD_SU;
306 if ((mod & MOD_SL) != 0) {
316 p.fst(f); mod |= MOD_SU;
327 n.fst(f); mod |= MOD_SU;
332 const int x_min =
x.min();
337 su_n -=
x.min() - x_min;
342 if ((mod & MOD_SU) != 0) {
352 p.fst(f); mod |= MOD_SL;;
363 n.fst(f); mod |= MOD_SL;;
368 const int x_max =
x.max();
373 sl_p +=
x.max() - x_max;
385 template<
class SBAP,
class SBAN,
class VX>
388 SBAP&
p, SBAN&
n, VX
x,
int c) {
394 }
else if (n.empty()) {
411 template<
class SBAP,
class SBAN,
class VX>
418 template<
class SBAP,
class SBAN,
class VX>
426 template<
class SBAP,
class SBAN,
class VX>
434 (home,share,*
this,ep,
n,z,
c+
x.val());
437 (home,share,*
this,ep,
n,
x,
c);
439 }
else if (
n.empty()) {
444 (home,share,*
this,
p,en,z,
c+
x.val());
447 (home,share,*
this,
p,en,
x,
c);
454 template<
class SBAP,
class SBAN,
class VX>
464 while ((f < l) && f->
x.
none())
471 }
else if (f->
x.
none()) {
483 while ((f < l) && f->
x.
none()) {
491 }
else if (f->
x.
none()) {
492 sl += f->
a; *t = *f; t++;
524 const int slx =
x.max() - sl;
532 if (
p.empty() &&
n.empty())
540 template<
class SBAP,
class SBAN,
class VX>
543 SBAP&
p, SBAN&
n, VX
x,
int c) {
549 }
else if (n.empty()) {
565 template<
class SBAP,
class SBAN,
class VX>
572 template<
class SBAP,
class SBAN,
class VX>
580 template<
class SBAP,
class SBAN,
class VX>
588 (home,share,*
this,ep,
n,z,
c+
x.val());
591 (home,share,*
this,ep,
n,
x,
c);
593 }
else if (
n.empty()) {
598 (home,share,*
this,
p,en,z,
c+
x.val());
601 (home,share,*
this,
p,en,
x,
c);
608 template<
class SBAP,
class SBAN,
class VX>
619 c -= f->
a; *f = *(t++);
620 }
else if (f->
x.
zero()) {
634 c += f->
a; *f = *(t++);
635 }
else if (f->
x.
zero()) {
644 if (
p.empty() &&
n.empty()) {
651 if (
p.empty() && (
n.size() == 1)) {
652 if (r == -
n.fst()->a) {
659 if ((
p.size() == 1) &&
n.empty()) {
660 if (r ==
p.fst()->a) {
673 template<
class SBAP,
class SBAN,
class VX>
676 SBAP&
p, SBAN&
n, VX
x,
int c) {
681 }
else if (n.empty()) {
bool none(void) const
Test whether view is not yet assigned.
void sort(void)
Sort array in decreasing order of coefficients.
Propagator for inequality to Boolean sum with coefficients
bool empty(void) const
Test whether array is empty.
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntConLevel icl)
Post propagator for .
Empty array of scale Boolean views.
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
ExecStatus ES_SUBSUMED(Propagator &p)
void subscribe(Space &home, Propagator &p)
Subscribe 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.
int size(void) const
Return number of elements.
void cancel(Space &home, Propagator &p)
Cancel propagator p.
ScaleBool * lst(void) const
Return pointer after last element.
Propagation has computed fixpoint.
Base-class for both propagators and branchers.
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.
ScaleBool * fst(void) const
Return pointer to first element.
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.
ScaleBool * fst(void) const
Return pointer to first element.
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.
bool one(void) const
Test whether view is assigned to be one.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Array of scale Boolean views.
Node * x
Pointer to corresponding Boolean expression node.
SBAP p
Positive Boolean views with coefficients on left-hand side.
ScaleBool * lst(void) const
Return pointer after last element.
virtual size_t dispose(Space &home)
Delete actor and return its size.
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.
bool empty(void) const
Test whether array is empty.
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.
int size(void) const
Return number of elements.
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 zero(void) const
Test whether view is assigned to be zero.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear)
LinBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
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.
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)