36#ifdef GECODE_HAS_FLOAT_VARS
77 static void*
operator new(
size_t size);
79 static void operator delete(
void* p,
size_t size);
106 LinFloatExpr::Node::operator
new(
size_t size) {
107 return heap.ralloc(size);
111 LinFloatExpr::Node::operator
delete(
void* p, size_t) {
118 if ((
l !=
nullptr) &&
l->decrement())
120 if ((
r !=
nullptr) &&
r->decrement())
139 return n->t ==
NT_NONLIN ? n->sum.ne :
nullptr;
153 if (home.
failed())
return;
156 n->r->sum.ne->post(home,frt,-n->c);
165 n->r->sum.ne->post(home,frt,n->c);
168 n->l !=
nullptr && n->l->t==
NT_VAR
170 (void) n->r->sum.ne->post(home,&n->l->x_float);
175 (void) n->l->sum.ne->post(home,&n->r->x_float);
186 if (home.
failed())
return;
189 n->r->sum.ne->post(home,frt,-n->c,b);
198 n->r->sum.ne->post(home,frt,n->c,b);
215 if ((n->n_float == 1) && (c == 0) && (fts[0].
a == 1))
220 fts[n->n_float].
x =
x; fts[n->n_float].
a = -1;
230 n->l = n->r =
nullptr;
238 n->l = n->r =
nullptr;
248 n->l = n->r =
nullptr;
257 n->l = n->r =
nullptr;
264 n->n_float =
x.size();
266 n->l = n->r =
nullptr;
268 n->sum.tf = heap.alloc<Float::Linear::Term>(x.size());
269 for (int i=x.size(); i--; ) {
270 n->sum.tf[i].x = x[i];
271 n->sum.tf[i].a = 1.0;
278 if (a.
size() !=
x.size())
280 n->n_float =
x.size();
282 n->l = n->r =
nullptr;
284 n->sum.tf = heap.alloc<Float::Linear::Term>(x.size());
285 for (int i=x.size(); i--; ) {
286 n->sum.tf[i].x = x[i];
287 n->sum.tf[i].a = a[i];
296 n->l = e0.n; n->
l->
use++;
297 n->r = e1.n; n->
r->
use++;
305 n->r = e.n; n->
r->
use++;
313 n->l = e.n; n->
l->
use++;
322 n->l = n->r =
nullptr;
357 tf->a=m;
tf->x=
sum.ne->post(home,
nullptr);
tf++;
362 tf[i].x =
sum.tf[i].x;
tf[i].a = m*
sum.tf[i].a;
371 l->fill(home,
tf,m,d);
373 r->fill(home,
tf,m,d);
380 l->fill(home,
tf,m,d);
382 r->fill(home,
tf,-m,d);
386 l->fill(home,
tf,m*
a,d);
424 else if (
y.assigned())
474 else if (
y.assigned())
514 else if (
x.assigned() &&
524 else if (
x.assigned() &&
Boolean integer variables.
FloatNum size(void) const
Return size of float value (distance between maximum and minimum)
Exception: Arguments are of different size
Class for describing linear term .
Home class for posting propagators
bool failed(void) const
Check whether corresponding space is failed.
Nodes for linear expressions.
NonLinFloatExpr * ne
Non-linear expression.
NodeType t
Type of expression.
FloatVal a
Coefficient and offset.
FloatVar x_float
Float variable (potentially)
unsigned int use
Nodes are reference counted.
int n_float
Float variables in tree.
Node(void)
Default constructor.
void fill(Home home, Float::Linear::Term *&tf, FloatVal m, FloatVal &d) const
Generate linear terms from expression.
bool decrement(void)
Decrement reference count and possibly free memory.
union Gecode::LinFloatExpr::Node::@376342227101025165247025300170136171251040003310 sum
Sum of integer or Boolean variables, or non-linear expression.
Float::Linear::Term * tf
Integer views and coefficients.
NonLinFloatExpr * nlfe(void) const
Return non-linear expression inside, or null if not non-linear.
LinFloatExpr(void)
Default constructor.
const LinFloatExpr & operator=(const LinFloatExpr &e)
Assignment operator.
~LinFloatExpr(void)
Destructor.
void post(Home home, FloatRelType frt) const
Post propagator.
NodeType
Type of linear expression.
@ NT_VAR
Linear term with variable.
@ NT_CONST
Float value constant.
@ NT_SUM
Sum of float variables.
@ NT_NONLIN
Non-linear expression.
@ NT_ADD
Addition of linear terms.
@ NT_MUL
Multiplication by coefficient.
@ NT_SUB
Subtraction of linear terms.
Base class for non-linear float expressions.
Class to set group information when a post function is executed.
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Heap heap
The single global heap.
double FloatNum
Floating point number base type.
FloatRelType
Relation types for floats.
@ FRT_LQ
Less or equal ( )
@ FRT_GQ
Greater or equal ( )
#define GECODE_MINIMODEL_EXPORT
const FloatNum max
Largest allowed float value.
bool valid(const FloatVal &n)
Return whether float n is a valid number.
const FloatNum min
Smallest allowed float value.
void check(const FloatVal &n, const char *l)
Check whether float n is a valid number, otherwise throw out of limits exception with information l.
void estimate(Term *t, int n, FloatVal c, FloatNum &l, FloatNum &u)
Estimate lower and upper bounds.
Gecode toplevel namespace
FloatVal operator-(const FloatVal &x)
FloatVal operator+(const FloatVal &x)
Post propagator for SetVar SetOpType SetVar SetRelType r
IntVar expr(Home home, const LinIntExpr &e, const IntPropLevels &ipls=IntPropLevels::def)
Post linear expression and return its value.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar SetOpType SetVar y
LinIntExpr sum(const IntVarArgs &x)
Construct linear expression as sum of integer variables.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
FloatVal operator*(const FloatVal &x, const FloatVal &y)
Post propagator for SetVar x
#define GECODE_NEVER
Assert that this command is never executed.