76 for (
int i=0; i<
n; i++)
101 IntVar x =
a[0].post(home, ipls);
106 abs(home, x, y, ipls.
abs());
114 IntVar x0 =
a[0].post(home, ipls);
115 IntVar x1 =
a[1].post(home, ipls);
118 else if (x1.
max() <= x0.
min())
122 min(home, x0, x1, y, ipls.
min2());
127 x[i] =
a[i].
post(home, ipls);
129 min(home, x, y, ipls.
min());
136 IntVar x0 =
a[0].post(home, ipls);
137 IntVar x1 =
a[1].post(home, ipls);
140 else if (x1.
max() <= x0.
min())
144 max(home, x0, x1, y, ipls.
max2());
149 x[i] =
a[i].
post(home, ipls);
151 max(home, x, y, ipls.
max());
157 IntVar x0 =
a[0].post(home, ipls);
158 IntVar x1 =
a[1].post(home, ipls);
176 IntVar x0 =
a[0].post(home, ipls);
177 IntVar x1 =
a[1].post(home, ipls);
185 div(home, x0, x1, y, ipls.
div());
192 IntVar x0 =
a[0].post(home, ipls);
193 IntVar x1 =
a[1].post(home, ipls);
195 mod(home, x0, x1, y, ipls.
mod());
201 IntVar x =
a[0].post(home, ipls);
206 sqr(home, x, y, ipls.
sqr());
213 IntVar x =
a[0].post(home, ipls);
225 IntVar x =
a[0].post(home, ipls);
227 ((x.
val() == 0) || (x.
val() == 1)))
238 IntVar x =
a[0].post(home, ipls);
240 ((x.
val() == 0) || (x.
val() == 1)))
252 y =
result(home,ret,
a[z.
val()].post(home, ipls));
255 bool assigned =
true;
256 for (
int i=
n-1; i--;) {
257 x[i] =
a[i].post(home, ipls);
258 if (!x[i].assigned())
264 for (
int i=
n-1; i--;)
277 IntVar x0 =
a[0].post(home, ipls);
278 IntVar x1 =
a[1].post(home, ipls);
280 ite(home, c, x0, x1, y, ipls.
ite());
294 x[i] =
a[i].
post(home, ipls);
295 rel(home, x, irt, c);
297 rel(home,
post(home,
nullptr,ipls), irt, c);
302 rel(home,
post(home,
nullptr,ipls), irt, c,
b);
332 if (hasType(e, ArithNonLinIntExpr::ANLE_ABS))
334 ArithNonLinIntExpr* ae =
335 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_ABS,1);
336 ArithNonLinIntExprGuard g(ae);
347 if (hasType(e0, ArithNonLinIntExpr::ANLE_MIN))
348 n +=
static_cast<ArithNonLinIntExpr*
>(e0.
nle())->n;
351 if (hasType(e1, ArithNonLinIntExpr::ANLE_MIN))
352 n +=
static_cast<ArithNonLinIntExpr*
>(e1.
nle())->n;
355 ArithNonLinIntExpr* ae =
356 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_MIN,n);
357 ArithNonLinIntExprGuard g(ae);
359 if (hasType(e0, ArithNonLinIntExpr::ANLE_MIN)) {
360 ArithNonLinIntExpr* e0e =
static_cast<ArithNonLinIntExpr*
>(e0.
nle());
361 for (; i<e0e->
n; i++)
362 ae->a[i] = e0e->a[i];
366 if (hasType(e1, ArithNonLinIntExpr::ANLE_MIN)) {
367 ArithNonLinIntExpr* e1e =
static_cast<ArithNonLinIntExpr*
>(e1.
nle());
369 for (; i<curN+e1e->
n; i++)
370 ae->
a[i] = e1e->a[i-curN];
383 if (hasType(e0, ArithNonLinIntExpr::ANLE_MAX))
384 n +=
static_cast<ArithNonLinIntExpr*
>(e0.
nle())->n;
387 if (hasType(e1, ArithNonLinIntExpr::ANLE_MAX))
388 n +=
static_cast<ArithNonLinIntExpr*
>(e1.
nle())->n;
391 ArithNonLinIntExpr* ae =
392 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_MAX,n);
393 ArithNonLinIntExprGuard g(ae);
395 if (hasType(e0, ArithNonLinIntExpr::ANLE_MAX)) {
396 ArithNonLinIntExpr* e0e =
static_cast<ArithNonLinIntExpr*
>(e0.
nle());
397 for (; i<e0e->
n; i++)
398 ae->a[i] = e0e->a[i];
402 if (hasType(e1, ArithNonLinIntExpr::ANLE_MAX)) {
403 ArithNonLinIntExpr* e1e =
static_cast<ArithNonLinIntExpr*
>(e1.
nle());
405 for (; i<curN+e1e->
n; i++)
406 ae->
a[i] = e1e->a[i-curN];
418 ArithNonLinIntExpr* ae =
419 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_MIN,x.
size());
420 ArithNonLinIntExprGuard g(ae);
421 for (
int i=x.
size(); i--;)
431 ArithNonLinIntExpr* ae =
432 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_MAX,x.
size());
433 ArithNonLinIntExprGuard g(ae);
434 for (
int i=x.
size(); i--;)
444 ArithNonLinIntExpr* ae =
445 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_MULT,2);
446 ArithNonLinIntExprGuard g(ae);
457 ArithNonLinIntExpr* ae =
458 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_SQR,1);
459 ArithNonLinIntExprGuard g(ae);
469 ArithNonLinIntExpr* ae =
470 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_SQRT,1);
471 ArithNonLinIntExprGuard g(ae);
481 ArithNonLinIntExpr* ae =
482 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_POW,1,n);
483 ArithNonLinIntExprGuard g(ae);
493 ArithNonLinIntExpr* ae =
494 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_NROOT,1,n);
495 ArithNonLinIntExprGuard g(ae);
505 ArithNonLinIntExpr* ae =
506 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_DIV,2);
507 ArithNonLinIntExprGuard g(ae);
518 ArithNonLinIntExpr* ae =
519 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_MOD,2);
520 ArithNonLinIntExprGuard g(ae);
531 ArithNonLinIntExpr* ae =
532 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_ELMNT,x.
size()+1);
533 ArithNonLinIntExprGuard g(ae);
534 for (
int i=x.
size(); i--;)
545 ArithNonLinIntExpr* ae =
546 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_ELMNT,x.
size()+1);
547 ArithNonLinIntExprGuard g(ae);
548 for (
int i=x.
size(); i--;)
559 ArithNonLinIntExpr* ae =
560 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_ITE,2,b);
561 ArithNonLinIntExprGuard g(ae);
int size(void) const
Return size of array (number of elements).
Boolean integer variables.
Home class for posting propagators
Passing integer arguments.
Class for specifying integer propagation levels used by minimodel.
IntPropLevel div(void) const
Return integer propagation level for division constraints.
IntPropLevel element(void) const
Return integer propagation level for element constraints.
IntPropLevel mod(void) const
Return integer propagation level for modulo constraints.
IntPropLevel max2(void) const
Return integer propagation level for binary maximum constraints.
IntPropLevel ite(void) const
Return integer propagation level for if-then-else constraints.
IntPropLevel mult(void) const
Return integer propagation level for multiplication constraints.
IntPropLevel min(void) const
Return integer propagation level for non-binary minimum constraints.
IntPropLevel nroot(void) const
Return integer propagation level for root constraints.
IntPropLevel abs(void) const
Return integer propagation level for absolute value constraints.
IntPropLevel sqrt(void) const
Return integer propagation level for square root constraints.
IntPropLevel min2(void) const
Return integer propagation level for binary minimum constraints.
IntPropLevel pow(void) const
Return integer propagation level for power constraints.
IntPropLevel max(void) const
Return integer propagation level for non-binary maximum constraints.
IntPropLevel sqr(void) const
Return integer propagation level for square constraints.
Passing integer variables.
int min(void) const
Return minimum of domain.
int val(void) const
Return assigned value.
int max(void) const
Return maximum of domain.
Linear expressions over integer variables.
NonLinIntExpr * nle(void) const
Return non-linear expression inside, or null if not non-linear.
ArithNonLinIntExprGuard(ArithNonLinIntExpr *e0)
~ArithNonLinIntExprGuard(void)
Non-linear arithmetic expressions over integer variables.
static LinIntExpr * allocate(int n)
Allocate internal expression slots without public default nodes.
virtual void post(Home home, IntRelType irt, int c, const IntPropLevels &ipls) const
Post expression to be in relation irt with c.
BoolExpr b
Boolean expression argument (used in ite for example).
ArithNonLinIntExpr(ArithNonLinIntExprType t0, int n0)
Constructor.
int aInt
Integer argument (used in nroot for example).
~ArithNonLinIntExpr(void)
Destructor.
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.
enum Gecode::MiniModel::ArithNonLinIntExpr::ArithNonLinIntExprType t
ArithNonLinIntExpr(ArithNonLinIntExprType t0, int n0, int a0)
Constructor.
ArithNonLinIntExprType
The expression type.
@ ANLE_NROOT
Nroot expression.
@ ANLE_MAX
Maximum expression.
@ ANLE_ELMNT
Element expression.
@ ANLE_MULT
Multiplication expression.
@ ANLE_MOD
Modulo expression.
@ ANLE_DIV
Division expression.
@ ANLE_SQRT
Square root expression.
@ ANLE_MIN
Minimum expression.
@ ANLE_ABS
Absolute value expression.
@ ANLE_SQR
Square expression.
@ ANLE_ITE
If-then-else expression.
@ ANLE_POW
Pow expression.
virtual IntVar post(Home home, IntVar *ret, const IntPropLevels &ipls) const
Post expression.
LinIntExpr * a
Expressions.
ArithNonLinIntExpr(ArithNonLinIntExprType t0, int n0, const BoolExpr &b0)
Constructor.
int n
Size of variable array.
Base class for non-linear expressions over integer variables.
static IntVar result(Home home, IntVar *x)
Return fresh variable if x is null, x otherwise.
bool assigned(void) const
Test whether view is assigned.
Heap heap
The single global heap.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
void ite(Home home, BoolVar b, FloatVar x, FloatVar y, FloatVar z)
Post propagator for if-then-else constraint.
IntRelType
Relation types for integers.
@ IRT_GQ
Greater or equal ( ).
@ IRT_LQ
Less or equal ( ).
#define GECODE_MINIMODEL_EXPORT
Minimalistic modeling support.
bool hasType(const LinFloatExpr &e, ArithNonLinFloatExpr::ArithNonLinFloatExprType t)
Check if e is of type t.
Gecode toplevel namespace
FloatVal operator/(const FloatVal &x, const FloatVal &y)
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl=IPL_DEF)
Post propagator for .
void sqr(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
void div(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void element(Home home, IntSharedArray n, IntVar x0, IntVar x1, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for .
void mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void sqrt(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void pow(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for .
FloatVal operator*(const FloatVal &x, const FloatVal &y)
void nroot(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for .
LinIntExpr operator%(const LinIntExpr &x, const LinIntExpr &y)
Return expression for .
#define GECODE_NEVER
Assert that this command is never executed.