38 namespace Gecode {
namespace Int {
namespace Bool {
105 template<
class BVA,
class BVB>
110 template<
class BVA,
class BVB>
115 template<
class BVA,
class BVB>
121 template<
class BVA,
class BVB>
127 template<
class BVA,
class BVB>
139 }
else if (b1.zero()) {
141 }
else if (!b0.one() && !b1.one()) {
150 template<
class BVA,
class BVB>
153 #define GECODE_INT_STATUS(S0,S1) \
154 ((BVA::S0<<(1*BVA::BITS))|(BVB::S1<<(0*BVB::BITS)))
155 switch ((x0.status() << (1*BVA::BITS)) | (x1.status() << (0*BVB::BITS))) {
175 #undef GECODE_INT_STATUS
192 return sizeof(*this);
199 x2.update(home,share,p.
x2);
207 x2.update(home,share,b2);
213 assert(x0.none() && x1.none());
232 #define GECODE_INT_STATUS(S0,S1,S2) \
233 ((BV::S0<<(2*BV::BITS))|(BV::S1<<(1*BV::BITS))|(BV::S2<<(0*BV::BITS)))
234 switch ((x0.status() << (2*BV::BITS)) | (x1.status() << (1*BV::BITS)) |
235 (x2.status() << (0*BV::BITS))) {
241 std::swap(x1,x2); x1.subscribe(home,*
this,
PC_BOOL_VAL);
251 std::swap(x0,x2); x0.subscribe(home,*
this,
PC_BOOL_VAL);
279 #undef GECODE_INT_STATUS
290 :
BoolBinary<BV,BV>(home,b0,b1), x2(b2), x3(b3) {}
296 return sizeof(*this);
303 x2.update(home,share,p.
x2);
304 x3.update(home,share,p.
x3);
310 BV b0, BV b1, BV
b2, BV b3)
312 x2.update(home,share,b2);
313 x3.update(home,share,b3);
319 assert(x0.none() && x1.none());
320 if (x2.one() || x3.one())
322 else if (x2.zero() && x3.zero())
342 #define GECODE_INT_STATUS(S0,S1,S2,S3) \
343 ((BV::S0 << (3*BV::BITS)) | (BV::S1 << (2*BV::BITS)) | \
344 (BV::S2 << (1*BV::BITS)) | (BV::S3 << (0*BV::BITS)))
345 switch ((x0.status() << (3*BV::BITS)) | (x1.status() << (2*BV::BITS)) |
346 (x2.status() << (1*BV::BITS)) | (x3.status() << (0*BV::BITS))) {
359 std::swap(x1,x2); x1.subscribe(home,*
this,
PC_BOOL_VAL,
false);
364 std::swap(x1,x3); x1.subscribe(home,*
this,
PC_BOOL_VAL,
false);
384 std::swap(x0,x2); x0.subscribe(home,*
this,
PC_BOOL_VAL,
false);
389 std::swap(x0,x3); x0.subscribe(home,*
this,
PC_BOOL_VAL,
false);
399 std::swap(x0,x2); x0.subscribe(home,*
this,
PC_BOOL_VAL,
false);
400 std::swap(x1,x3); x1.subscribe(home,*
this,
PC_BOOL_VAL,
false);
455 #undef GECODE_INT_STATUS
463 template<
class BVA,
class BVB,
class BVC>
468 template<
class BVA,
class BVB,
class BVC>
473 template<
class BVA,
class BVB,
class BVC>
476 BVA b0, BVB b1, BVC
b2)
477 :
BoolTernary<BVA,BVB,BVC>(home,share,p,b0,b1,b2) {}
479 template<
class BVA,
class BVB,
class BVC>
483 assert(x0.none() && x1.none());
485 }
else if (x0.zero()) {
486 assert(x1.none() && x2.none());
487 return new (home)
Eq<BVB,BVC>(home,share,*
this,x1,x2);
488 }
else if (x1.zero()) {
489 assert(x0.none() && x2.none());
490 return new (home)
Eq<BVA,BVC>(home,share,*
this,x0,x2);
496 template<
class BVA,
class BVB,
class BVC>
502 }
else if (b2.one()) {
512 if (b0.one() || b1.one()) {
514 }
else if (b0.zero()) {
516 }
else if (b1.zero()) {
528 template<
class BVA,
class BVB,
class BVC>
531 #define GECODE_INT_STATUS(S0,S1,S2) \
532 ((BVA::S0<<(2*BVA::BITS))|(BVB::S1<<(1*BVB::BITS))|(BVC::S2<<(0*BVC::BITS)))
533 switch ((x0.status() << (2*BVA::BITS)) | (x1.status() << (1*BVB::BITS)) |
534 (x2.status() << (0*BVC::BITS))) {
607 #undef GECODE_INT_STATUS
619 assert(
x.
size() > 2);
645 x[0]=
x[
i];
x.size(1);
647 }
else if (
x[
i].zero()) {
668 for (
int i=b.
size();
i--; )
671 else if (b[
i].zero())
677 }
else if (b.
size() == 2) {
679 }
else if (b.
size() == 3) {
681 }
else if (b.
size() == 4) {
693 return sizeof(*this);
704 }
else if (
x[
i].zero()) {
738 template<
class VX,
class VY>
746 template<
class VX,
class VY>
751 c.update(home,share,p.
c);
754 template<
class VX,
class VY>
757 assert(n_zero <
x.size());
767 assert(n_zero <
x.size());
771 template<
class VX,
class VY>
778 for (
int i=x.
size();
i--; )
782 for (
int i=x.
size();
i--; )
786 }
else if (x[
i].zero()) {
791 }
else if (x.
size() == 1) {
793 }
else if (x.
size() == 2) {
796 (void)
new (home)
NaryOr(home,x,y);
801 template<
class VX,
class VY>
807 template<
class VX,
class VY>
811 if (VX::zero(d) && (++n_zero <
x.size()))
817 template<
class VX,
class VY>
825 return sizeof(*this);
828 template<
class VX,
class VY>
835 for (
int i =
x.size();
i--; )
837 }
else if (n_zero ==
x.size()) {
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
void update(Space &, bool share, ViewArray< View > &a)
Update array to be a clone of array a.
TerOrTrue(Home home, BV b0, BV b1, BV b2)
Constructor for posting.
static ExecStatus post(Home home, BV b0, BV b1)
Post propagator.
ExecStatus ES_SUBSUMED(Propagator &p)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
bool one(const Gecode::FloatValArgs &a)
Check whether has only one coefficients.
ExecStatus resubscribe(Space &home, Propagator &p, VX &x0, ViewArray< VX > &x, VY &x1, ViewArray< VY > &y)
BV x2
Boolean view without subscription.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Mixed (n+1)-ary propagator.
A & advisor(void) const
Return advisor.
ExecStatus resubscribe(Space &home, BV &x0, BV x1)
Update subscription.
Base-class for propagators.
static ExecStatus post(Home home, BVA b0, BVB b1, BVC b2)
Post propagator .
Class to iterate over advisors of a council.
static ExecStatus post(Home home, BV b0, BV b1, BV b2, BV b3)
Post propagator .
Propagation has computed fixpoint.
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Quarternary Boolean disjunction propagator (true)
Base-class for both propagators and branchers.
Or(Home home, BVA b0, BVB b1, BVC b2)
Constructor for posting.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
NaryOrTrue(Home home, ViewArray< BV > &x)
Constructor for posting.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Gecode::FloatVal c(-8, 8)
Binary Boolean disjunction propagator (subsumed)
Ternary Boolean disjunction propagator (true)
int p
Number of positive literals for node type.
QuadOrTrue(Home home, BV b0, BV b1, BV b2, BV b3)
Constructor for posting.
Gecode::IntArgs i(4, 1, 2, 3, 4)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
int n
Number of negative literals for node type.
static ExecStatus post(Home home, BVA x0, BVB x1)
Post propagator .
Execution has resulted in failure.
const Gecode::PropCond PC_BOOL_NONE
Propagation condition to be ignored (convenience)
Council< Advisor > c
The advisor council.
void subscribe(Space &home, Propagator &p, PropCond pc, bool process=true)
Subscribe propagator p with propagation condition pc to variable.
bool shared(const Space &home) const
Test whether array contains shared views.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
ModEventDelta med
A set of modification events (used during propagation)
NaryOr(Home home, ViewArray< VX > &x, VY y)
Constructor for posting.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Boolean disjunction propagator.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
BinOrTrue(Home home, BVA b0, BVB b1)
Constructor for posting.
Boolean equality propagator.
BoolTest bool_test(const BoolView &b0, const BoolView &b1)
void drop_fst(int i)
Drop views from positions 0 to i-1 from array.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Same variable but complement.
void move_lst(int i)
Move view from position size()-1 to position i (truncate array by one)
BV x2
Boolean view without subscription.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary)
static ExecStatus post(Home home, BV b0, BV b1, BV b2)
Post propagator .
Boolean n-ary disjunction propagator (true)
static ExecStatus post(Home home, BVA b0, BVB b1)
Post propagator .
ViewArray< BV > x
Views not yet subscribed to.
Node * x
Pointer to corresponding Boolean expression node.
Generic domain change information to be supplied to advisors.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low unary)
Boolean n-ary disjunction propagator.
Binary Boolean disjunction propagator (true)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Propagation has not computed fixpoint.
static ExecStatus post(Home home, ViewArray< BV > &b)
Post propagator .
int size(void) const
Return size of array (number of elements)
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
BV x3
Boolean view without subscription.
static ExecStatus post(Home home, ViewArray< VX > &x, VY y)
Post propagator .
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
OrTrueSubsumed(Space &home, bool share, OrTrueSubsumed &p)
Constructor for cloning p.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
Base-class for ternary Boolean propagators.
Base-class for binary Boolean propagators.
int ModEventDelta
Modification event deltas.
Home class for posting propagators
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
#define GECODE_NEVER
Assert that this command is never executed.
#define GECODE_INT_STATUS(S0, S1)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)