Go to the documentation of this file.
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);
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,
IPL_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);
370 dom(home, s, invsrt, ss,
b);
375 IntVar iv =
u.a.x->e.post(home,
IPL_DEF);
380 rel(home,ic,srt,s,
b);
382 rel(home,iv,srt,s,
b);
393 rel(home, br, srt, s,
b);
404 rel(home, br, srt, s,
b);
424 rel(home, br, srt, bc);
431 rel(home, br, srt, s,
b);
464 u.b.l->post(home,
t,
b,
i);
465 u.b.r->post(home,
t,
b,
i);
472 post(home,srt,
n->u.a.x->x);
478 default: n_srt = srt;
480 n->post(home,n_srt,
this);
494 post(home,srt,
n->u.a.x->x,
b);
500 default: n_srt = srt;
502 n->post(home,
b,
true,n_srt,
this);
509 }
else if (srt ==
SRT_EQ) {
511 }
else if (srt ==
SRT_NQ) {
514 BoolVar nb(home,0,1);
516 post(home,nb,
true,srt,n);
521 NNF::nnf(Region&
r, Node* n,
bool neg) {
527 NNF*
x =
new (
r) NNF;
537 return nnf(
r,
n->l,!
neg);
550 NNF*
x =
new (
r) NNF;
553 x->u.b.l = nnf(
r,
n->l,
neg);
554 x->u.b.r = nnf(
r,
n->r,
neg);
557 p_l=
x->u.b.l->p; n_l=
x->u.b.l->n;
563 p_r=
x->u.b.r->p; n_r=
x->u.b.r->n;
605 int ls =
same(
t,
l.n->t) ?
l.n->same : 1;
634 if (
n != NULL &&
n->decrement())
643 if (
n != NULL &&
n->decrement())
656 NNF::nnf(
r,
n,
false)->post(home,
SRT_EQ,s);
663 return NNF::nnf(
r,
n,
false)->post(home,srt,NNF::nnf(
r,e.n,
false));
669 return NNF::nnf(
r,
n,
false)->post(home,
b,
t,srt,
670 NNF::nnf(
r,e.n,
false));
703 for (
int i=1;
i<
x.size();
i++)
712 for (
int i=1;
i<
x.size();
i++)
721 for (
int i=1;
i<
x.size();
i++)
726 namespace MiniModel {
743 IntVar m = result(home,ret);
762 if (
t==SNLE_CARD && irt!=
IRT_NQ) {
767 static_cast<unsigned int>(
c));
772 static_cast<unsigned int>(
c-1));
776 static_cast<unsigned int>(
c),
781 static_cast<unsigned int>(
c+1),
786 static_cast<unsigned int>(
c),
787 static_cast<unsigned int>(
c));
799 rel(home,
post(home,NULL,ipl), irt,
c);
811 rel(home,
post(home,NULL,ipl), irt,
c,
b);
Post propagator for SetVar x
IntRelType
Relation types for integers.
Node(void)
Default constructor.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
@ IRT_GQ
Greater or equal ( )
const SetExpr & operator=(const SetExpr &e)
Assignment operator.
struct Gecode::@597::NNF::@67::@68 b
For binary nodes (and, or, eqv)
BoolVar expr(Home home, const BoolExpr &e, IntPropLevel ipl)
Post Boolean expression and return its value.
unsigned int size(I &i)
Size of all ranges of range iterator i.
SetNonLinIntExprType
The expression type.
static const IntSet empty
Empty set.
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.
@ NT_LEXP
Linear expression.
bool decrement(void)
Decrement reference count and possibly free memory.
Gecode::IntArgs i(4, 1, 2, 3, 4)
virtual IntVar post(Home home, IntVar *ret, IntPropLevel) const
Post expression.
bool same(const Item &i, const Item &j)
Whether two items are the same.
int p
Number of positive literals for node type.
bool same(const VarImpVar< VarImp > &y) const
Test whether variable is the same as y.
void * ralloc(size_t s)
Allocate s bytes from heap.
int same
Number of variables in subtree with same type (for INTER and UNION)
Linear expressions over integer variables.
IntPropLevel
Propagation levels for integer propagators.
@ SRT_LQ
Less or equal ( )
@ SRT_GQ
Greater or equal ( )
FloatVal operator+(const FloatVal &x)
SetExpr operator|(const SetExpr &l, const SetExpr &r)
Union of set expressions.
SetExpr singleton(const LinIntExpr &e)
Singleton expression.
Integer valued set expressions.
virtual void post(Home home, IntRelType irt, int c, IntPropLevel ipl) const
Post expression to be in relation irt with c.
Gecode toplevel namespace
VarImp * x
Pointer to variable implementation.
const int max
Largest allowed integer in integer set.
const unsigned int card
Maximum cardinality of an integer set.
@ SNLE_CARD
Cardinality expression.
Home class for posting propagators
SetNonLinIntExpr(const SetExpr &e0, SetNonLinIntExprType t0)
Constructor.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Post propagator for SetVar SetOpType SetVar SetRelType r
Boolean integer variables.
int n
Number of negative literals for node type.
SetExpr(void)
Default constructor.
Base class for non-linear expressions over integer variables.
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
LinIntExpr e
Possibly a linear expression.
Class to set group information when a post function is executed.
SetRelType
Common relation types for sets.
SetExpr operator&(const SetExpr &l, const SetExpr &r)
Intersection of set expressions.
SetExpr setunion(const SetVarArgs &x)
Union of set variables.
NodeType
Type of set expression.
@ SNLE_MIN
Minimum element expression.
#define GECODE_NEVER
Assert that this command is never executed.
virtual void post(Home home, IntRelType irt, int c, BoolVar b, IntPropLevel ipl) const
Post reified expression to be in relation irt with c.
SetVar x
Possibly a variable.
FloatVal operator-(const FloatVal &x)
Heap heap
The single global heap.
NodeType t
Type of expression.
IntRelType neg(IntRelType irt)
Return negated relation type of irt.
@ SOT_DUNION
Disjoint union.
bool failed(void) const
Check whether corresponding space is failed.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
@ SNLE_MAX
Maximum element expression.
@ IPL_DEF
Simple propagation levels.
#define GECODE_MINIMODEL_EXPORT
SetExpr setdunion(const SetVarArgs &x)
Disjoint union of set variables.
@ NT_DUNION
Disjoint union.
IntSet s
Possibly a constant.
struct Gecode::@597::NNF::@67::@69 a
For atomic nodes.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Gecode::FloatVal c(-8, 8)
int n
Number of negative literals for node type.
void rfree(void *p)
Free memory block starting at p.
SetVar post(Home home) const
Post propagators for expression.
SetExpr inter(const SetVarArgs &x)
Intersection of set variables.
~SetExpr(void)
Destructor.
@ IRT_LQ
Less or equal ( )
union Gecode::@597::NNF::@67 u
Union depending on nodetype t.
unsigned int use
Nodes are reference counted.