42 #ifdef GECODE_HAS_SET_VARS
78 static void*
operator new(
size_t size);
80 static void operator delete(
void*
p,
size_t size);
90 SetExpr::Node::operator
new(
size_t size) {
94 SetExpr::Node::operator
delete(
void*
p, size_t) {
101 if ((
l != NULL) &&
l->decrement())
103 if ((
r != NULL) &&
r->decrement())
140 static NNF* nnf(Region&
r, Node* n,
bool neg);
142 void post(Home home, NodeType t, SetVarArgs&
b,
int&
i)
const;
153 static void*
operator new(
size_t s, Region&
r);
155 static void operator delete(
void*);
157 static void operator delete(
void*, Region&);
165 NNF::operator
delete(
void*) {}
168 NNF::operator
delete(
void*, Region&) {}
171 NNF::operator
new(
size_t s, Region&
r) {
191 rel(home,
u.a.x->x, srt, bc);
195 rel(home,
u.a.x->x, srt, s);
201 IntSetRanges sr(
u.a.x->s);
202 Set::RangesCompl<IntSetRanges> src(sr);
212 dom(home, s, srt, ss);
217 IntVar iv =
u.a.x->e.post(home,
ICL_DEF);
242 rel(home, bc, srt, s);
261 rel(home, bc, srt, s);
298 rel(home, br, srt, bc);
309 rel(home, br, srt, s);
336 rel(home,
u.a.x->x, srt, bc, b);
340 rel(home,
u.a.x->x, srt, s, b);
346 IntSetRanges sr(
u.a.x->s);
347 Set::RangesCompl<IntSetRanges> src(sr);
367 dom(home, s, invsrt, ss, b);
372 IntVar iv =
u.a.x->e.post(home,
ICL_DEF);
377 rel(home,ic,srt,s,b);
379 rel(home,iv,srt,s,b);
390 rel(home, br, srt, s, b);
401 rel(home, br, srt, s, b);
421 rel(home, br, srt, bc);
428 rel(home, br, srt, s, b);
461 u.b.l->post(home, t, b, i);
462 u.b.r->post(home, t, b, i);
469 post(home,srt,n->u.a.x->x);
475 default: n_srt = srt;
477 n->post(home,n_srt,
this);
491 post(home,srt,n->u.a.x->x,b);
497 default: n_srt = srt;
499 n->post(home,b,
true,n_srt,
this);
506 }
else if (srt ==
SRT_EQ) {
508 }
else if (srt ==
SRT_NQ) {
511 BoolVar nb(home,0,1);
513 post(home,nb,
true,srt,n);
518 NNF::nnf(Region&
r, Node* n,
bool neg) {
524 NNF*
x =
new (
r) NNF;
525 x->t = n->t; x->neg =
neg; x->u.a.x = n;
534 return nnf(r,n->l,!neg);
541 t = n->t; xneg =
neg; neg =
false;
547 NNF* x =
new (
r) NNF;
550 x->u.b.l = nnf(r,n->l,neg);
551 x->u.b.r = nnf(r,n->r,neg);
554 p_l=x->u.b.l->p; n_l=x->u.b.l->n;
560 p_r=x->u.b.r->p; n_r=x->u.b.r->n;
631 if (n != NULL && n->decrement())
640 if (n != NULL && n->decrement())
653 NNF::nnf(r,n,
false)->post(home,
SRT_EQ,s);
660 return NNF::nnf(r,n,
false)->post(home,srt,NNF::nnf(r,e.n,
false));
666 return NNF::nnf(r,n,
false)->post(home,b,t,srt,
667 NNF::nnf(r,e.n,
false));
700 for (
int i=1; i<x.
size(); i++)
709 for (
int i=1; i<x.
size(); i++)
718 for (
int i=1; i<x.
size(); i++)
723 namespace MiniModel {
740 IntVar m = result(home,ret);
759 if (t==SNLE_CARD && irt!=
IRT_NQ) {
764 static_cast<unsigned int>(
c));
769 static_cast<unsigned int>(c-1));
773 static_cast<unsigned int>(
c),
778 static_cast<unsigned int>(c+1),
783 static_cast<unsigned int>(
c),
784 static_cast<unsigned int>(c));
789 }
else if (t==SNLE_MIN && (irt==
IRT_GR || irt==
IRT_GQ)) {
790 c = (irt==
IRT_GQ ? c : c+1);
792 }
else if (t==SNLE_MAX && (irt==
IRT_LE || irt==
IRT_LQ)) {
793 c = (irt==
IRT_LQ ? c : c-1);
796 rel(home,
post(home,NULL,icl), irt, c);
802 c = (irt==
IRT_GQ ? c : c+1);
804 }
else if (t==SNLE_MAX && (irt==
IRT_LE || irt==
IRT_LQ)) {
805 c = (irt==
IRT_LQ ? c : c-1);
808 rel(home,
post(home,NULL,icl), irt, c, b);
struct Gecode::@534::NNF::@63::@65 a
For atomic nodes.
bool failed(void) const
Check whether corresponding space is failed.
FloatVal operator-(const FloatVal &x)
int same
Number of variables in subtree with same type (for INTER and UNION)
SetExpr singleton(const LinIntExpr &e)
Singleton expression.
SetRelType
Common relation types for sets.
IntConLevel
Consistency levels for integer propagators.
const SetExpr & operator=(const SetExpr &e)
Assignment operator.
SetExpr operator&(const SetExpr &l, const SetExpr &r)
Intersection of set expressions.
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
const int min
Smallest allowed integer in integer set.
void rfree(void *p)
Free memory block starting at p.
int size(void) const
Return size of array (number of elements)
LinIntExpr e
Possibly a linear expression.
bool neg
Is formula negative.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
virtual IntVar post(Home home, IntVar *ret, IntConLevel) const
Post expression.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Base class for non-linear expressions over integer variables.
void * ralloc(size_t s)
Allocate s bytes from heap.
SetVar x
Possibly a variable.
virtual void post(Home home, IntRelType irt, int c, BoolVar b, IntConLevel icl) const
Post reified expression to be in relation irt with c.
const unsigned int card
Maximum cardinality of an integer set.
const int max
Largest allowed integer in integer set.
Heap heap
The single global heap.
SetExpr setdunion(const SetVarArgs &x)
Disjoint union of set variables.
struct Gecode::@534::NNF::@63::@64 b
For binary nodes (and, or, eqv)
Gecode::FloatVal c(-8, 8)
bool same(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether two views are the same.
Gecode::IntArgs i(4, 1, 2, 3, 4)
union Gecode::@534::NNF::@63 u
Union depending on nodetype t.
int n
Number of negative literals for node type.
IntSet s
Possibly a constant.
IntRelType
Relation types for integers.
FloatVal operator+(const FloatVal &x)
NodeType t
Type of expression.
SetExpr(void)
Default constructor.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Node(void)
Default constructor.
virtual void post(Home home, IntRelType irt, int c, IntConLevel icl) const
Post expression to be in relation irt with c.
NodeType
Type of set expression.
SetExpr setunion(const SetVarArgs &x)
Union of set variables.
Integer valued set expressions.
Minimum element expression.
static const IntSet empty
Empty set.
Boolean integer variables.
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
SetExpr inter(const SetVarArgs &x)
Intersection of set variables.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
BoolVar expr(Home home, const BoolExpr &e, IntConLevel icl)
Post Boolean expression and return its value.
Linear expressions over integer variables.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
The default consistency for a constraint.
unsigned int use
Nodes are reference counted.
#define GECODE_MINIMODEL_EXPORT
SetExpr operator|(const SetExpr &l, const SetExpr &r)
Union of set expressions.
SetNonLinIntExprType
The expression type.
Gecode toplevel namespace
Maximum element expression.
Node * x
Pointer to corresponding Boolean expression node.
Home class for posting propagators
~SetExpr(void)
Destructor.
#define GECODE_NEVER
Assert that this command is never executed.
SetNonLinIntExpr(const SetExpr &e0, SetNonLinIntExprType t0)
Constructor.
bool decrement(void)
Decrement reference count and possibly free memory.
SetVar post(Home home) const
Post propagators for expression.
int p
Number of positive literals for node type.