34 namespace Gecode {
namespace Int {
namespace Linear {
68 int n =
static_cast<int>(sba._lst - sba._fst);
72 for (
int i=0;
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);
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();
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();
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()) {
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
Node * x
Pointer to corresponding Boolean expression node.
Base-class for both propagators and branchers.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Home class for posting propagators
Empty array of scale Boolean views.
ScaleBool * fst(void) const
Return pointer to first element.
void sort(void)
Sort array in decreasing order of coefficients.
int size(void) const
Return number of elements.
void reschedule(Space &home, Propagator &p)
Schedule propagator p.
void update(Space &home, EmptyScaleBoolArray &esba)
Update sba during copying.
void cancel(Space &home, Propagator &p)
Cancel propagator p.
EmptyScaleBoolArray(void)
Default constructor.
bool empty(void) const
Test whether array is empty.
void subscribe(Space &home, Propagator &p)
Subscribe propagator p.
ScaleBool * lst(void) const
Return pointer after last element.
Propagator for equality to Boolean sum with coefficients
static ExecStatus post(Home home, SBAP &p, SBAN &n, VX x, int c)
Post propagator.
virtual Actor * copy(Space &home)
Create copy during cloning.
EqBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Base class for linear Boolean constraints with coefficients.
LinBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
SBAP p
Positive Boolean views with coefficients on left-hand side.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear)
VX x
Integer view on right-hand side.
virtual void reschedule(Space &home)
Schedule function.
SBAN n
Negative Boolean views with coefficients on left-hand side.
Propagator for inequality to Boolean sum with coefficients
LqBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
virtual Actor * copy(Space &home)
Create copy during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ExecStatus post(Home home, SBAP &p, SBAN &n, VX x, int c)
Post propagator.
Propagator for disequality to Boolean sum with coefficients
virtual Actor * copy(Space &home)
Create copy during cloning.
static ExecStatus post(Home home, SBAP &p, SBAN &n, VX x, int c)
Post propagator.
NqBoolScale(Home home, SBAP &p, SBAN &n, VX x, int c)
Constructor for creation.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Array of scale Boolean views.
void cancel(Space &home, Propagator &p)
Cancel propagator p.
void sort(void)
Sort array in decreasing order of coefficients.
void reschedule(Space &home, Propagator &p)
Schedule propagator p.
ScaleBool * lst(void) const
Return pointer after last element.
void subscribe(Space &home, Propagator &p)
Subscribe propagator p.
int size(void) const
Return number of elements.
ScaleBool * fst(void) const
Return pointer to first element.
ScaleBoolArray(void)
Default constructor.
bool empty(void) const
Test whether array is empty.
void update(Space &home, ScaleBoolArray &sba)
Update sba during copying.
Coefficient and Boolean view.
int a
Integer coefficient.
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
Base-class for propagators.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
void update(Space &home, VarImpView< Var > &y)
Update this view to be a clone of view y.
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
@ 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.
int ModEvent
Type for modification events.
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl)
Post propagator for .
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
Post propagator for SetVar SetOpType SetVar y
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.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
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)
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i({1, 2, 3, 4})