Go to the documentation of this file.
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();
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();
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()) {
Post propagator for SetVar x
int a
Integer coefficient.
static ExecStatus post(Home home, SBAP &p, SBAN &n, VX x, int c)
Post propagator.
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
Post propagator for SetVar SetOpType SetVar y
bool me_failed(ModEvent me)
Check whether modification event me is failed.
ScaleBool * fst(void) const
Return pointer to first element.
NqBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
LqBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
ExecStatus ES_SUBSUMED(Propagator &p)
static ExecStatus post(Home home, SBAP &p, SBAN &n, VX x, int c)
Post propagator.
ScaleBool * lst(void) const
Return pointer after last element.
bool empty(void) const
Test whether array is empty.
void cancel(Space &home, Propagator &p)
Cancel propagator p.
Propagator for inequality to Boolean sum with coefficients
void cancel(Space &home, Propagator &p)
Cancel propagator p.
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
Gecode::IntArgs i(4, 1, 2, 3, 4)
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Base-class for both propagators and branchers.
bool assigned(void) const
Test whether view is assigned.
void sort(void)
Sort array in decreasing order of coefficients.
const Gecode::ModEvent ME_BOOL_VAL
Domain operation has resulted in a value (assigned variable)
void sort(void)
Sort array in decreasing order of coefficients.
EmptyScaleBoolArray(void)
Default constructor.
Gecode toplevel namespace
Base-class for propagators.
Node * x
Pointer to corresponding Boolean expression node.
void reschedule(Space &home, Propagator &p, IntSet &y)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Home class for posting propagators
Propagator for equality to Boolean sum with coefficients
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
void update(Space &home, bool share, EmptyScaleBoolArray &esba)
Update sba during copying.
Post propagator for SetVar SetOpType SetVar SetRelType r
void subscribe(Space &home, Propagator &p)
Subscribe propagator p.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
void reschedule(Space &home, Propagator &p)
Schedule propagator p.
Array of scale Boolean views.
static ExecStatus post(Home home, SBAP &p, SBAN &n, VX x, int c)
Post propagator.
Base class for linear Boolean constraints with coefficients.
ScaleBoolArray(void)
Default constructor.
LinBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
void update(Space &home, bool share, VarImpView< Var > &y)
Update this view to be a clone of view y.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
int ModEvent
Type for modification events.
int size(void) const
Return number of elements.
void update(Space &home, bool share, ScaleBoolArray &sba)
Update sba during copying.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
EqBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl)
Post propagator for .
Propagator for disequality to Boolean sum with coefficients
ScaleBool * lst(void) const
Return pointer after last element.
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
int size(void) const
Return number of elements.
@ ES_FIX
Propagation has computed fixpoint.
bool empty(void) const
Test whether array is empty.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Empty array of scale Boolean views.
void reschedule(Space &home, Propagator &p)
Schedule propagator p.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Gecode::FloatVal c(-8, 8)
void subscribe(Space &home, Propagator &p)
Subscribe propagator p.
int n
Number of negative literals for node type.
ScaleBool * fst(void) const
Return pointer to first element.
Coefficient and Boolean view.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
@ ES_FAILED
Execution has resulted in failure.
int ModEventDelta
Modification event deltas.
@ ES_NOFIX
Propagation has not computed fixpoint.
@ ES_OK
Execution is okay.
int p
Number of positive literals for node type.