set-expr.cpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Guido Tack <tack@gecode.org>
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Guido Tack, 2010
* Christian Schulte, 2004
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <gecode/minimodel.hh>
#ifdef GECODE_HAS_SET_VARS
namespace Gecode {
namespace {
static bool same(SetExpr::NodeType t0, SetExpr::NodeType t1) {
return (t0==t1) || (t1==SetExpr::NT_VAR) ||
(t1==SetExpr::NT_CONST) || (t1==SetExpr::NT_LEXP);
}
}
class SetExpr::Node {
public:
unsigned int use;
int same;
NodeType t;
Node *l, *r;
SetVar x;
IntSet s;
LinIntExpr e;
Node(void);
GECODE_MINIMODEL_EXPORT
bool decrement(void);
static void* operator new(size_t size);
static void operator delete(void* p, size_t size);
};
/*
* Operations for nodes
*
*/
SetExpr::Node::Node(void) : use(1) {}
void*
SetExpr::Node::operator new(size_t size) {
return heap.ralloc(size);
}
void
SetExpr::Node::operator delete(void* p, size_t) {
heap.rfree(p);
}
bool
SetExpr::Node::decrement(void) {
if (--use == 0) {
if ((l != nullptr) && l->decrement())
delete l;
if ((r != nullptr) && r->decrement())
delete r;
return true;
}
return false;
}
namespace {
class NNF {
public:
typedef SetExpr::NodeType NodeType;
typedef SetExpr::Node Node;
NodeType t;
int p;
int n;
union {
struct {
NNF* l;
NNF* r;
} b;
struct {
Node* x;
} a;
} u;
bool neg;
static NNF* nnf(Region& r, Node* n, bool neg);
void post(Home home, NodeType t, SetVarArgs& b, int& i) const;
void post(Home home, SetRelType srt, SetVar s) const;
void post(Home home, SetRelType srt, SetVar s, BoolVar b) const;
void post(Home home, SetRelType srt, const NNF* n) const;
void post(Home home, BoolVar b, bool t, SetRelType srt,
const NNF* n) const;
static void* operator new(size_t s, Region& r);
static void operator delete(void*);
static void operator delete(void*, Region&);
};
/*
* Operations for negation normalform
*
*/
forceinline void
NNF::operator delete(void*) {}
forceinline void
NNF::operator delete(void*, Region&) {}
forceinline void*
NNF::operator new(size_t s, Region& r) {
return r.ralloc(s);
}
void
NNF::post(Home home, SetRelType srt, SetVar s) const {
switch (t) {
case SetExpr::NT_VAR:
if (neg) {
switch (srt) {
case SRT_EQ:
rel(home, u.a.x->x, SRT_CMPL, s);
break;
case SRT_CMPL:
rel(home, u.a.x->x, SRT_EQ, s);
break;
default:
SetVar bc(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, s, SRT_CMPL, bc);
rel(home, u.a.x->x, srt, bc);
break;
}
} else
rel(home, u.a.x->x, srt, s);
break;
case SetExpr::NT_CONST:
{
IntSet ss;
if (neg) {
IntSetRanges sr(u.a.x->s);
Set::RangesCompl<IntSetRanges> src(sr);
ss = IntSet(src);
} else {
ss = u.a.x->s;
}
switch (srt) {
case SRT_SUB: srt = SRT_SUP; break;
case SRT_SUP: srt = SRT_SUB; break;
default: break;
}
dom(home, s, srt, ss);
}
break;
case SetExpr::NT_LEXP:
{
IntVar iv = u.a.x->e.post(home,IntPropLevels::def);
if (neg) {
SetVar ic(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, iv, SRT_CMPL, ic);
rel(home,ic,srt,s);
} else {
rel(home,iv,srt,s);
}
}
break;
case SetExpr::NT_INTER:
{
SetVarArgs bs(p+n);
int i=0;
post(home, SetExpr::NT_INTER, bs, i);
if (i == 2) {
rel(home, bs[0], SOT_INTER, bs[1], srt, s);
} else {
if (srt == SRT_EQ)
rel(home, SOT_INTER, bs, s);
else {
SetVar bc(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, SOT_INTER, bs, bc);
rel(home, bc, srt, s);
}
}
}
break;
case SetExpr::NT_UNION:
{
SetVarArgs bs(p+n);
int i=0;
post(home, SetExpr::NT_UNION, bs, i);
if (i == 2) {
rel(home, bs[0], SOT_UNION, bs[1], srt, s);
} else {
if (srt == SRT_EQ)
rel(home, SOT_UNION, bs, s);
else {
SetVar bc(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, SOT_UNION, bs, bc);
rel(home, bc, srt, s);
}
}
}
break;
case SetExpr::NT_DUNION:
{
SetVarArgs bs(p+n);
int i=0;
post(home, SetExpr::NT_DUNION, bs, i);
if (i == 2) {
if (neg) {
if (srt == SRT_CMPL) {
rel(home, bs[0], SOT_DUNION, bs[1], srt, s);
} else {
SetVar bc(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home,s,SRT_CMPL,bc);
rel(home, bs[0], SOT_DUNION, bs[1], srt, bc);
}
} else {
rel(home, bs[0], SOT_DUNION, bs[1], srt, s);
}
} else {
if (neg) {
if (srt == SRT_CMPL) {
rel(home, SOT_DUNION, bs, s);
} else {
SetVar br(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, SOT_DUNION, bs, br);
if (srt == SRT_EQ)
rel(home, br, SRT_CMPL, s);
else {
SetVar bc(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, br, srt, bc);
rel(home, bc, SRT_CMPL, s);
}
}
} else {
if (srt == SRT_EQ)
rel(home, SOT_DUNION, bs, s);
else {
SetVar br(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, SOT_DUNION, bs, br);
rel(home, br, srt, s);
}
}
}
}
break;
default:
GECODE_NEVER;
}
}
void
NNF::post(Home home, SetRelType srt, SetVar s, BoolVar b) const {
switch (t) {
case SetExpr::NT_VAR:
if (neg) {
switch (srt) {
case SRT_EQ:
rel(home, u.a.x->x, SRT_CMPL, s, b);
break;
case SRT_CMPL:
rel(home, u.a.x->x, SRT_EQ, s, b);
break;
default:
SetVar bc(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, s, SRT_CMPL, bc);
rel(home, u.a.x->x, srt, bc, b);
break;
}
} else
rel(home, u.a.x->x, srt, s, b);
break;
case SetExpr::NT_CONST:
{
IntSet ss;
if (neg) {
IntSetRanges sr(u.a.x->s);
Set::RangesCompl<IntSetRanges> src(sr);
ss = IntSet(src);
} else {
ss = u.a.x->s;
}
SetRelType invsrt;
switch (srt) {
case SRT_SUB: invsrt = SRT_SUP; break;
case SRT_SUP: invsrt = SRT_SUB; break;
case SRT_LQ: invsrt = SRT_GQ; break;
case SRT_LE: invsrt = SRT_GR; break;
case SRT_GQ: invsrt = SRT_LQ; break;
case SRT_GR: invsrt = SRT_LE; break;
case SRT_EQ:
case SRT_NQ:
case SRT_DISJ:
case SRT_CMPL:
invsrt = srt;
break;
default:
invsrt = srt;
GECODE_NEVER;
}
dom(home, s, invsrt, ss, b);
}
break;
case SetExpr::NT_LEXP:
{
IntVar iv = u.a.x->e.post(home,IntPropLevels::def);
if (neg) {
SetVar ic(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, iv, SRT_CMPL, ic);
rel(home,ic,srt,s,b);
} else {
rel(home,iv,srt,s,b);
}
}
break;
case SetExpr::NT_INTER:
{
SetVarArgs bs(p+n);
int i=0;
post(home, SetExpr::NT_INTER, bs, i);
SetVar br(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, SOT_INTER, bs, br);
rel(home, br, srt, s, b);
}
break;
case SetExpr::NT_UNION:
{
SetVarArgs bs(p+n);
int i=0;
post(home, SetExpr::NT_UNION, bs, i);
SetVar br(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, SOT_UNION, bs, br);
rel(home, br, srt, s, b);
}
break;
case SetExpr::NT_DUNION:
{
SetVarArgs bs(p+n);
int i=0;
post(home, SetExpr::NT_DUNION, bs, i);
if (neg) {
SetVar br(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, SOT_DUNION, bs, br);
if (srt == SRT_CMPL)
rel(home, br, SRT_EQ, s, b);
else if (srt == SRT_EQ)
rel(home, br, SRT_CMPL, s, b);
else {
SetVar bc(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, br, srt, bc);
rel(home, bc, SRT_CMPL, s, b);
}
} else {
SetVar br(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, SOT_DUNION, bs, br);
rel(home, br, srt, s, b);
}
}
break;
default:
GECODE_NEVER;
}
}
void
NNF::post(Home home, NodeType t, SetVarArgs& b, int& i) const {
if (this->t != t) {
switch (this->t) {
case SetExpr::NT_VAR:
if (neg) {
SetVar xc(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
rel(home, xc, SRT_CMPL, u.a.x->x);
b[i++]=xc;
} else {
b[i++]=u.a.x->x;
}
break;
default:
{
SetVar s(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
post(home,SRT_EQ,s);
b[i++] = s;
}
break;
}
} else {
u.b.l->post(home, t, b, i);
u.b.r->post(home, t, b, i);
}
}
void
NNF::post(Home home, SetRelType srt, const NNF* n) const {
if (n->t == SetExpr::NT_VAR && !n->neg) {
post(home,srt,n->u.a.x->x);
} else if (t == SetExpr::NT_VAR && !neg) {
SetRelType n_srt;
switch (srt) {
case SRT_SUB: n_srt = SRT_SUP; break;
case SRT_SUP: n_srt = SRT_SUB; break;
default: n_srt = srt;
}
n->post(home,n_srt,this);
} else {
SetVar nx(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
n->post(home,SRT_EQ,nx);
post(home,srt,nx);
}
}
void
NNF::post(Home home, BoolVar b, bool pt,
SetRelType srt, const NNF* n) const {
if (pt) {
if (n->t == SetExpr::NT_VAR && !n->neg) {
post(home,srt,n->u.a.x->x,b);
} else if (t == SetExpr::NT_VAR && !neg) {
SetRelType n_srt;
switch (srt) {
case SRT_SUB: n_srt = SRT_SUP; break;
case SRT_SUP: n_srt = SRT_SUB; break;
default: n_srt = srt;
}
n->post(home,b,true,n_srt,this);
} else {
SetVar nx(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
n->post(home,SRT_EQ,nx);
post(home,srt,nx,b);
}
} else if (srt == SRT_EQ) {
post(home,b,true,SRT_NQ,n);
} else if (srt == SRT_NQ) {
post(home,b,true,SRT_EQ,n);
} else {
BoolVar nb(home,0,1);
rel(home,b,IRT_NQ,nb);
post(home,nb,true,srt,n);
}
}
NNF*
NNF::nnf(Region& r, Node* n, bool neg) {
switch (n->t) {
case SetExpr::NT_VAR:
case SetExpr::NT_CONST:
case SetExpr::NT_LEXP:
{
NNF* x = new (r) NNF;
x->t = n->t; x->neg = neg; x->u.a.x = n;
if (neg) {
x->p = 0; x->n = 1;
} else {
x->p = 1; x->n = 0;
}
return x;
}
case SetExpr::NT_CMPL:
return nnf(r,n->l,!neg);
case SetExpr::NT_INTER:
case SetExpr::NT_UNION:
case SetExpr::NT_DUNION:
{
NodeType t; bool xneg;
if (n->t == SetExpr::NT_DUNION) {
t = n->t; xneg = neg; neg = false;
} else {
t = ((n->t == SetExpr::NT_INTER) == neg) ?
SetExpr::NT_UNION : SetExpr::NT_INTER;
xneg = false;
}
NNF* x = new (r) NNF;
x->neg = xneg;
x->t = t;
x->u.b.l = nnf(r,n->l,neg);
x->u.b.r = nnf(r,n->r,neg);
int p_l, n_l;
if ((x->u.b.l->t == t) || (x->u.b.l->t == SetExpr::NT_VAR)) {
p_l=x->u.b.l->p; n_l=x->u.b.l->n;
} else {
p_l=1; n_l=0;
}
int p_r, n_r;
if ((x->u.b.r->t == t) || (x->u.b.r->t == SetExpr::NT_VAR)) {
p_r=x->u.b.r->p; n_r=x->u.b.r->n;
} else {
p_r=1; n_r=0;
}
x->p = p_l+p_r;
x->n = n_l+n_r;
return x;
}
default:
GECODE_NEVER;
}
GECODE_NEVER;
return nullptr;
}
}
SetExpr::SetExpr(const SetVar& x) : n(new Node) {
n->same = 1;
n->t = NT_VAR;
n->l = nullptr;
n->r = nullptr;
n->x = x;
}
SetExpr::SetExpr(const IntSet& s) : n(new Node) {
n->same = 1;
n->t = NT_CONST;
n->l = nullptr;
n->r = nullptr;
n->s = s;
}
SetExpr::SetExpr(const LinIntExpr& e) : n(new Node) {
n->same = 1;
n->t = NT_LEXP;
n->l = nullptr;
n->r = nullptr;
n->e = e;
}
SetExpr::SetExpr(const SetExpr& l, NodeType t, const SetExpr& r)
: n(new Node) {
int ls = same(t,l.n->t) ? l.n->same : 1;
int rs = same(t,r.n->t) ? r.n->same : 1;
n->same = ls+rs;
n->t = t;
n->l = l.n;
n->l->use++;
n->r = r.n;
n->r->use++;
}
SetExpr::SetExpr(const SetExpr& l, NodeType t) {
(void) t;
assert(t == NT_CMPL);
if (l.n->t == NT_CMPL) {
n = l.n->l;
n->use++;
} else {
n = new Node;
n->same = 1;
n->t = NT_CMPL;
n->l = l.n;
n->l->use++;
n->r = nullptr;
}
}
const SetExpr&
SetExpr::operator =(const SetExpr& e) {
if (this != &e) {
if (n != nullptr && n->decrement())
delete n;
n = e.n;
n->use++;
}
return *this;
}
SetExpr::~SetExpr(void) {
if (n != nullptr && n->decrement())
delete n;
}
SetExpr::SetExpr(const SetExpr& e) : n(e.n) {
n->use++;
}
SetVar
SetExpr::post(Home home) const {
Region r;
SetVar s(home,IntSet::empty,
IntSet(Set::Limits::min,Set::Limits::max));
NNF::nnf(r,n,false)->post(home,SRT_EQ,s);
return s;
}
void
SetExpr::post(Home home, SetRelType srt, const SetExpr& e) const {
Region r;
return NNF::nnf(r,n,false)->post(home,srt,NNF::nnf(r,e.n,false));
}
void
SetExpr::post(Home home, BoolVar b, bool t,
SetRelType srt, const SetExpr& e) const {
Region r;
return NNF::nnf(r,n,false)->post(home,b,t,srt,
NNF::nnf(r,e.n,false));
}
SetExpr
operator &(const SetExpr& l, const SetExpr& r) {
return SetExpr(l,SetExpr::NT_INTER,r);
}
SetExpr
operator |(const SetExpr& l, const SetExpr& r) {
return SetExpr(l,SetExpr::NT_UNION,r);
}
SetExpr
operator +(const SetExpr& l, const SetExpr& r) {
return SetExpr(l,SetExpr::NT_DUNION,r);
}
SetExpr
operator -(const SetExpr& e) {
return SetExpr(e,SetExpr::NT_CMPL);
}
SetExpr
operator -(const SetExpr& l, const SetExpr& r) {
return SetExpr(l,SetExpr::NT_INTER,-r);
}
SetExpr
singleton(const LinIntExpr& e) {
return SetExpr(e);
}
SetExpr
inter(const SetVarArgs& x) {
if (x.size() == 0)
return SetExpr(IntSet(Set::Limits::min,Set::Limits::max));
SetExpr r(x[0]);
for (int i=1; i<x.size(); i++)
r = (r & x[i]);
return r;
}
SetExpr
setunion(const SetVarArgs& x) {
if (x.size() == 0)
return SetExpr(IntSet::empty);
SetExpr r(x[0]);
for (int i=1; i<x.size(); i++)
r = (r | x[i]);
return r;
}
SetExpr
setdunion(const SetVarArgs& x) {
if (x.size() == 0)
return SetExpr(IntSet::empty);
SetExpr r(x[0]);
for (int i=1; i<x.size(); i++)
r = (r + x[i]);
return r;
}
namespace MiniModel {
class GECODE_MINIMODEL_EXPORT SetNonLinIntExpr : public NonLinIntExpr {
public:
enum SetNonLinIntExprType {
SNLE_CARD,
SNLE_MIN,
SNLE_MAX
} t;
SetExpr e;
SetNonLinIntExpr(const SetExpr& e0, SetNonLinIntExprType t0)
: t(t0), e(e0) {}
virtual IntVar post(Home home, IntVar* ret,
const IntPropLevels&) const {
IntVar m = result(home,ret);
switch (t) {
case SNLE_CARD:
cardinality(home, e.post(home), m);
break;
case SNLE_MIN:
min(home, e.post(home), m);
break;
case SNLE_MAX:
max(home, e.post(home), m);
break;
default:
GECODE_NEVER;
break;
}
return m;
}
virtual void post(Home home, IntRelType irt, int c,
const IntPropLevels& ipls) const {
if (t==SNLE_CARD && irt!=IRT_NQ) {
switch (irt) {
case IRT_LQ:
cardinality(home, e.post(home),
0U,
static_cast<unsigned int>(c));
break;
case IRT_LE:
cardinality(home, e.post(home),
0U,
static_cast<unsigned int>(c-1));
break;
case IRT_GQ:
cardinality(home, e.post(home),
static_cast<unsigned int>(c),
Set::Limits::card);
break;
case IRT_GR:
cardinality(home, e.post(home),
static_cast<unsigned int>(c+1),
Set::Limits::card);
break;
case IRT_EQ:
cardinality(home, e.post(home),
static_cast<unsigned int>(c),
static_cast<unsigned int>(c));
break;
default:
GECODE_NEVER;
}
} else if (t==SNLE_MIN && (irt==IRT_GR || irt==IRT_GQ)) {
c = (irt==IRT_GQ ? c : c+1);
dom(home, e.post(home), SRT_SUB, c, Set::Limits::max);
} else if (t==SNLE_MAX && (irt==IRT_LE || irt==IRT_LQ)) {
c = (irt==IRT_LQ ? c : c-1);
dom(home, e.post(home), SRT_SUB, Set::Limits::min, c);
} else {
rel(home, post(home,nullptr,ipls), irt, c);
}
}
virtual void post(Home home, IntRelType irt, int c,
BoolVar b,
const IntPropLevels& ipls) const {
if (t==SNLE_MIN && (irt==IRT_GR || irt==IRT_GQ)) {
c = (irt==IRT_GQ ? c : c+1);
dom(home, e.post(home), SRT_SUB, c, Set::Limits::max, b);
} else if (t==SNLE_MAX && (irt==IRT_LE || irt==IRT_LQ)) {
c = (irt==IRT_LQ ? c : c-1);
dom(home, e.post(home), SRT_SUB, Set::Limits::min, c, b);
} else {
rel(home, post(home,nullptr,ipls), irt, c, b);
}
}
};
}
LinIntExpr
cardinality(const SetExpr& e) {
return LinIntExpr(new MiniModel::SetNonLinIntExpr(e,
MiniModel::SetNonLinIntExpr::SNLE_CARD));
}
LinIntExpr
min(const SetExpr& e) {
return LinIntExpr(new MiniModel::SetNonLinIntExpr(e,
MiniModel::SetNonLinIntExpr::SNLE_MIN));
}
LinIntExpr
max(const SetExpr& e) {
return LinIntExpr(new MiniModel::SetNonLinIntExpr(e,
MiniModel::SetNonLinIntExpr::SNLE_MAX));
}
/*
* Posting set expressions
*
*/
SetVar
expr(Home home, const SetExpr& e) {
PostInfo pi(home);
if (!home.failed())
return e.post(home);
SetVar x(home,IntSet::empty,IntSet::empty);
return x;
}
}
#endif
// STATISTICS: minimodel-any
Gecode::ArgArrayBase::size
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1607
Gecode::BoolVar
Boolean integer variables.
Definition int.hh:512
Gecode::FloatVal::x
FloatValImpType x
Implementation of float value.
Definition float.hh:425
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::Home::failed
bool failed(void) const
Check whether corresponding space is failed.
Definition core.hpp:4048
Gecode::IntPropLevels
Class for specifying integer propagation levels used by minimodel.
Definition minimodel.hh:101
Gecode::IntPropLevels::def
static const IntPropLevels def
Default propagation levels for all constraints.
Definition minimodel.hh:197
Gecode::IntSet
Integer sets.
Definition int.hh:174
Gecode::IntSet::empty
static const IntSet empty
Empty set.
Definition int.hh:283
Gecode::IntVar
Integer variables.
Definition int.hh:371
Gecode::LinIntExpr
Linear expressions over integer variables.
Definition minimodel.hh:245
Gecode::MiniModel::SetNonLinIntExpr
Integer valued set expressions.
Definition set-expr.cpp:725
Gecode::MiniModel::SetNonLinIntExpr::t
enum Gecode::MiniModel::SetNonLinIntExpr::SetNonLinIntExprType t
Gecode::MiniModel::SetNonLinIntExpr::post
virtual void post(Home home, IntRelType irt, int c, const IntPropLevels &ipls) const
Post expression to be in relation irt with c.
Definition set-expr.cpp:758
Gecode::MiniModel::SetNonLinIntExpr::post
virtual void post(Home home, IntRelType irt, int c, BoolVar b, const IntPropLevels &ipls) const
Post reified expression to be in relation irt with c.
Definition set-expr.cpp:800
Gecode::MiniModel::SetNonLinIntExpr::SetNonLinIntExpr
SetNonLinIntExpr(const SetExpr &e0, SetNonLinIntExprType t0)
Constructor.
Definition set-expr.cpp:736
Gecode::MiniModel::SetNonLinIntExpr::e
SetExpr e
The expression.
Definition set-expr.cpp:734
Gecode::MiniModel::SetNonLinIntExpr::SetNonLinIntExprType
SetNonLinIntExprType
The expression type.
Definition set-expr.cpp:728
Gecode::MiniModel::SetNonLinIntExpr::SNLE_MAX
@ SNLE_MAX
Maximum element expression.
Definition set-expr.cpp:731
Gecode::MiniModel::SetNonLinIntExpr::SNLE_MIN
@ SNLE_MIN
Minimum element expression.
Definition set-expr.cpp:730
Gecode::MiniModel::SetNonLinIntExpr::SNLE_CARD
@ SNLE_CARD
Cardinality expression.
Definition set-expr.cpp:729
Gecode::MiniModel::SetNonLinIntExpr::post
virtual IntVar post(Home home, IntVar *ret, const IntPropLevels &) const
Post expression.
Definition set-expr.cpp:739
Gecode::NonLinIntExpr
Base class for non-linear expressions over integer variables.
Definition minimodel.hh:215
Gecode::NonLinIntExpr::result
static IntVar result(Home home, IntVar *x)
Return fresh variable if x is null, x otherwise.
Definition int-expr.hpp:40
Gecode::PostInfo
Class to set group information when a post function is executed.
Definition core.hpp:948
Gecode::Region
Handle to region.
Definition region.hpp:55
Gecode::SetExpr::Node
Node for set expression
Definition set-expr.cpp:51
Gecode::SetExpr::Node::same
int same
Number of variables in subtree with same type (for INTER and UNION).
Definition set-expr.cpp:56
Gecode::SetExpr::Node::t
NodeType t
Type of expression.
Definition set-expr.cpp:58
Gecode::SetExpr::Node::decrement
bool decrement(void)
Decrement reference count and possibly free memory.
Definition set-expr.cpp:95
Gecode::SetExpr::Node::x
SetVar x
Possibly a variable.
Definition set-expr.cpp:62
Gecode::SetExpr::Node::Node
Node(void)
Default constructor.
Definition set-expr.cpp:83
Gecode::SetExpr::Node::e
LinIntExpr e
Possibly a linear expression.
Definition set-expr.cpp:66
Gecode::SetExpr::Node::use
unsigned int use
Nodes are reference counted.
Definition set-expr.cpp:54
Gecode::SetExpr::Node::l
Node * l
Subexpressions.
Definition set-expr.cpp:60
Gecode::SetExpr::Node::s
IntSet s
Possibly a constant.
Definition set-expr.cpp:64
Gecode::SetExpr::Node::r
Node * r
Definition set-expr.cpp:60
Gecode::SetExpr
Set expressions
Definition minimodel.hh:1164
Gecode::SetExpr::SetExpr
SetExpr(void)
Default constructor.
Definition set-expr.hpp:44
Gecode::SetExpr::post
SetVar post(Home home) const
Post propagators for expression.
Definition set-expr.cpp:649
Gecode::SetExpr::~SetExpr
~SetExpr(void)
Destructor.
Definition set-expr.cpp:639
Gecode::SetExpr::NodeType
NodeType
Type of set expression.
Definition minimodel.hh:1167
Gecode::SetExpr::NT_CMPL
@ NT_CMPL
Complement.
Definition minimodel.hh:1171
Gecode::SetExpr::NT_INTER
@ NT_INTER
Intersection.
Definition minimodel.hh:1172
Gecode::SetExpr::NT_DUNION
@ NT_DUNION
Disjoint union.
Definition minimodel.hh:1174
Gecode::SetExpr::NT_UNION
@ NT_UNION
Union.
Definition minimodel.hh:1173
Gecode::SetExpr::NT_VAR
@ NT_VAR
Variable.
Definition minimodel.hh:1168
Gecode::SetExpr::NT_LEXP
@ NT_LEXP
Linear expression.
Definition minimodel.hh:1170
Gecode::SetExpr::NT_CONST
@ NT_CONST
Constant.
Definition minimodel.hh:1169
Gecode::SetExpr::operator=
const SetExpr & operator=(const SetExpr &e)
Assignment operator.
Definition set-expr.cpp:629
Gecode::SetVarArgs
Passing set variables.
Definition set.hh:488
Gecode::SetVar
Set variables
Definition set.hh:127
pi
const int * pi[]
Definition photo.cpp:14262
Gecode::Float::Linear::post
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition post.cpp:238
Gecode::heap
Heap heap
The single global heap.
Definition heap.cpp:44
Gecode::rel
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
Definition rel.cpp:68
Gecode::IntRelType
IntRelType
Relation types for integers.
Definition int.hh:925
Gecode::IRT_EQ
@ IRT_EQ
Equality ( ).
Definition int.hh:926
Gecode::IRT_NQ
@ IRT_NQ
Disequality ( ).
Definition int.hh:927
Gecode::IRT_GQ
@ IRT_GQ
Greater or equal ( ).
Definition int.hh:930
Gecode::IRT_LE
@ IRT_LE
Less ( ).
Definition int.hh:929
Gecode::IRT_GR
@ IRT_GR
Greater ( ).
Definition int.hh:931
Gecode::IRT_LQ
@ IRT_LQ
Less or equal ( ).
Definition int.hh:928
Gecode::SetRelType
SetRelType
Common relation types for sets.
Definition set.hh:643
Gecode::SOT_DUNION
@ SOT_DUNION
Disjoint union.
Definition set.hh:662
Gecode::SOT_UNION
@ SOT_UNION
Union.
Definition set.hh:661
Gecode::SOT_INTER
@ SOT_INTER
Intersection
Definition set.hh:663
Gecode::SRT_GQ
@ SRT_GQ
Greater or equal ( ).
Definition set.hh:652
Gecode::SRT_CMPL
@ SRT_CMPL
Complement.
Definition set.hh:649
Gecode::SRT_GR
@ SRT_GR
Greater ( ).
Definition set.hh:653
Gecode::SRT_LQ
@ SRT_LQ
Less or equal ( ).
Definition set.hh:650
Gecode::SRT_NQ
@ SRT_NQ
Disequality ( ).
Definition set.hh:645
Gecode::SRT_LE
@ SRT_LE
Less ( ).
Definition set.hh:651
Gecode::SRT_EQ
@ SRT_EQ
Equality ( ).
Definition set.hh:644
Gecode::SRT_SUP
@ SRT_SUP
Superset ( ).
Definition set.hh:647
Gecode::SRT_DISJ
@ SRT_DISJ
Disjoint ( ).
Definition set.hh:648
Gecode::SRT_SUB
@ SRT_SUB
Subset ( ).
Definition set.hh:646
minimodel.hh
GECODE_MINIMODEL_EXPORT
#define GECODE_MINIMODEL_EXPORT
Definition minimodel.hh:78
Gecode::Float::Arithmetic::neg
bool neg(const View &x)
Test whether x is negative.
Definition mult.hpp:47
Gecode::Set::Limits::min
const int min
Smallest allowed integer in integer set.
Definition set.hh:99
Gecode::Set::Limits::card
const unsigned int card
Maximum cardinality of an integer set.
Definition set.hh:101
Gecode::Set::Limits::max
const int max
Largest allowed integer in integer set.
Definition set.hh:97
Gecode
Gecode toplevel namespace
Gecode::operator-
FloatVal operator-(const FloatVal &x)
Definition val.hpp:168
Gecode::operator+
FloatVal operator+(const FloatVal &x)
Definition val.hpp:164
Gecode::expr
IntVar expr(Home home, const LinIntExpr &e, const IntPropLevels &ipls=IntPropLevels::def)
Post linear expression and return its value.
Definition int-expr.cpp:915
Gecode::operator&
SetExpr operator&(const SetExpr &, const SetExpr &)
Intersection of set expressions.
Definition set-expr.cpp:671
Gecode::min
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition arithmetic.cpp:67
Gecode::neg
IntRelType neg(IntRelType irt)
Return negated relation type of irt.
Definition irt.hpp:52
Gecode::dom
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition dom.cpp:40
Gecode::inter
SetExpr inter(const SetVarArgs &)
Intersection of set variables.
Definition set-expr.cpp:696
Gecode::same
bool same(VarArgArray< Var > x, VarArgArray< Var > y)
Definition array.hpp:1937
Gecode::setdunion
SetExpr setdunion(const SetVarArgs &)
Disjoint union of set variables.
Definition set-expr.cpp:714
Gecode::setunion
SetExpr setunion(const SetVarArgs &)
Union of set variables.
Definition set-expr.cpp:705
Gecode::singleton
SetExpr singleton(const LinIntExpr &)
Singleton expression.
Definition set-expr.cpp:691
Gecode::max
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition arithmetic.cpp:49
Gecode::operator|
SetExpr operator|(const SetExpr &, const SetExpr &)
Union of set expressions.
Definition set-expr.cpp:675
Gecode::cardinality
LinIntExpr cardinality(const SetExpr &)
Cardinality of set expression.
Definition set-expr.cpp:817
Test::Float::Arithmetic::b
Gecode::FloatVal b(9, 12)
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})
Test::Int::Dom::r
const int r[4][2]
Definition dom.cpp:152
forceinline
#define forceinline
Definition config.hpp:187
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition macros.hpp:56