Go to the documentation of this file.
40 namespace Gecode {
namespace Int {
namespace Linear {
47 long long int ax =
t[
i].a *
static_cast<long long int>(
t[
i].x.val());
85 for (
int i=0;
i<n_p;
i++) {
87 t_p[
i].
a *
static_cast<long long int>(t_p[
i].
x.min());
92 t_p[
i].
a *
static_cast<long long int>(t_p[
i].
x.max());
97 for (
int i=0;
i<n_n;
i++) {
99 t_n[
i].
a *
static_cast<long long int>(t_n[
i].
x.max());
103 long long int axmin =
104 t_n[
i].
a *
static_cast<long long int>(t_n[
i].
x.min());
121 for (
int i=0;
i<n_p;
i++) {
122 long long int axmin =
123 t_p[
i].
a *
static_cast<long long int>(t_p[
i].
x.min());
128 long long int axmax =
129 t_p[
i].
a *
static_cast<long long int>(t_p[
i].
x.max());
135 for (
int i=0;
i<n_n;
i++) {
136 long long int axmin =
137 t_n[
i].
a *
static_cast<long long int>(t_n[
i].
x.min());
142 long long int axmax =
143 t_n[
i].
a *
static_cast<long long int>(t_n[
i].
x.max());
156 template<
class Val,
class View>
176 #define GECODE_INT_PL_BIN(CLASS) \
179 GECODE_ES_FAIL((CLASS<int,IntView,IntView>::post \
180 (home,t_p[0].x,t_p[1].x,c))); \
183 GECODE_ES_FAIL((CLASS<int,IntView,MinusView>::post \
184 (home,t_p[0].x,MinusView(t_n[0].x),c))); \
187 GECODE_ES_FAIL((CLASS<int,MinusView,MinusView>::post \
188 (home,MinusView(t_n[0].x),MinusView(t_n[1].x),c))); \
190 default: GECODE_NEVER; \
194 #define GECODE_INT_PL_TER(CLASS) \
197 GECODE_ES_FAIL((CLASS<int,IntView,IntView,IntView>::post \
198 (home,t_p[0].x,t_p[1].x,t_p[2].x,c))); \
201 GECODE_ES_FAIL((CLASS<int,IntView,IntView,MinusView>::post \
202 (home,t_p[0].x,t_p[1].x, \
203 MinusView(t_n[0].x),c))); \
206 GECODE_ES_FAIL((CLASS<int,IntView,MinusView,MinusView>::post \
208 MinusView(t_n[0].x),MinusView(t_n[1].x),c))); \
211 GECODE_ES_FAIL((CLASS<int,MinusView,MinusView,MinusView>::post \
212 (home,MinusView(t_n[0].x), \
213 MinusView(t_n[1].x),MinusView(t_n[2].x),c))); \
215 default: GECODE_NEVER; \
230 bool is_unit = normalize<IntView>(
t,
n,t_p,n_p,t_n,n_n,
gcd);
238 if ((
d %
gcd) != 0) {
268 LLongScaleView
y(t_p[0].
a,t_p[0].
x);
276 LLongScaleView
y(t_n[0].
a,t_n[0].
x);
288 if ((
n == 2) && is_unit &&
318 if (is_unit && is_ip &&
321 c =
static_cast<int>(
d);
338 for (
int i=0;
i<n_p;
i++)
341 for (
int i=0;
i<n_n;
i++)
343 post_nary<int,IntView>(home,
x,
y,irt,
c);
346 if ((
n==2) && is_unit &&
350 c =
static_cast<int>(
d);
376 c =
static_cast<int>(
d);
378 for (
int i=0;
i<n_p;
i++)
379 x[
i] = IntScaleView(t_p[
i].
a,t_p[
i].
x);
381 for (
int i=0;
i<n_n;
i++)
382 y[
i] = IntScaleView(t_n[
i].
a,t_n[
i].
x);
386 post_nary<int,IntScaleView>(home,
x,
y,irt,
c);
392 for (
int i=0;
i<n_p;
i++)
393 x[
i] = LLongScaleView(t_p[
i].
a,t_p[
i].
x);
395 for (
int i=0;
i<n_n;
i++)
396 y[
i] = LLongScaleView(t_n[
i].
a,t_n[
i].
x);
401 post_nary<long long int,LLongScaleView>(home,
x,
y,irt,
d);
406 #undef GECODE_INT_PL_BIN
407 #undef GECODE_INT_PL_TER
414 template<
class Val,
class View>
478 template<
class CtrlView>
528 bool is_unit = normalize<IntView>(
t,
n,t_p,n_p,t_n,n_n,
gcd);
536 if ((
d %
gcd) != 0) {
544 if ((
d %
gcd) != 0) {
561 case IRT_EQ: fail = (
d != 0);
break;
562 case IRT_NQ: fail = (
d == 0);
break;
563 case IRT_LQ: fail = (0 >
d);
break;
578 if (is_unit && is_ip) {
579 c =
static_cast<int>(
d);
584 posteqint<BoolView>(home,t_p[0].
x,
c,
r.var(),
r.mode(),ipl);
586 posteqint<BoolView>(home,t_p[0].
x,-
c,
r.var(),
r.mode(),ipl);
599 posteqint<NegBoolView>(home,t_p[0].
x,
c,nb,rm,ipl);
601 posteqint<NegBoolView>(home,t_p[0].
x,-
c,nb,rm,ipl);
610 post(home,t_p[0].
x,
c,
r.var())));
614 post(home,t_p[0].
x,
c,
r.var())));
618 post(home,t_p[0].
x,
c,
r.var())));
627 post(home,t_n[0].
x,-
c-1,nb)));
631 post(home,t_n[0].
x,-
c-1,nb)));
635 post(home,t_n[0].
x,-
c-1,nb)));
651 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
655 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
659 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
688 post(home,t_n[0].
x,t_n[1].
x,-
c,
r.var())));
692 post(home,t_n[0].
x,t_n[1].
x,-
c,
r.var())));
696 post(home,t_n[0].
x,t_n[1].
x,-
c,
r.var())));
712 post(home,t_p[0].
x,t_p[1].
x,
c,nb)));
716 post(home,t_p[0].
x,t_p[1].
x,
c,nb)));
720 post(home,t_p[0].
x,t_p[1].
x,
c,nb)));
746 post(home,t_p[0].
x,t_p[1].
x,-
c,nb)));
750 post(home,t_p[0].
x,t_p[1].
x,-
c,nb)));
754 post(home,t_p[0].
x,t_p[1].
x,-
c,nb)));
769 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
773 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
777 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
829 for (
int i=0;
i<n_p;
i++)
832 for (
int i=0;
i<n_n;
i++)
834 post_nary<int,IntView>(home,
x,
y,irt,
c,
r);
838 c =
static_cast<int>(
d);
840 for (
int i=0;
i<n_p;
i++)
841 x[
i] = IntScaleView(t_p[
i].
a,t_p[
i].
x);
843 for (
int i=0;
i<n_n;
i++)
844 y[
i] = IntScaleView(t_n[
i].
a,t_n[
i].
x);
845 post_nary<int,IntScaleView>(home,
x,
y,irt,
c,
r);
849 for (
int i=0;
i<n_p;
i++)
850 x[
i] = LLongScaleView(t_p[
i].
a,t_p[
i].
x);
852 for (
int i=0;
i<n_n;
i++)
853 y[
i] = LLongScaleView(t_n[
i].
a,t_n[
i].
x);
854 post_nary<long long int,LLongScaleView>(home,
x,
y,irt,
d,
r);
void rewrite(IntRelType &r, long long int &d)
Rewrite non-strict relations.
Propagator for bounds consistent binary linear less or equal
Post propagator for SetVar x
IntRelType
Relation types for integers.
bool zero(void) const
Test whether view is assigned to be zero.
Post propagator for SetVar SetOpType SetVar y
@ RM_PMI
Inverse implication for reification.
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Class for describing linear term .
Reified less or equal with integer propagator.
@ IRT_GQ
Greater or equal ( )
Reified domain consistent equality with integer propagator.
Propagator for bounds consistent n-ary linear less or equal
bool overflow_sub(int n, int m)
Check whether subtracting m from n would overflow.
@ RM_IMP
Implication for reification.
bool one(void) const
Test whether view is assigned to be one.
bool overflow_add(int n, int m)
Check whether adding n and m would overflow.
void check(int n, const char *l)
Check whether n is in range, otherwise throw out of limits with information l.
IntPropLevel
Propagation levels for integer propagators.
IntType floor_div_xp(IntType x, IntType y)
Compute where y is non-negative.
bool assigned(void) const
Test whether view is assigned.
void post_nary(Home home, ViewArray< View > &x, ViewArray< View > &y, IntRelType irt, Val c)
Posting n-ary propagators.
void eliminate(Term< BoolView > *t, int &n, long long int &d)
Eliminate assigned views.
Propagator for bounds consistent ternary linear disquality
Boolean view for Boolean variables.
Gecode toplevel namespace
Propagator for bounds consistent n-ary linear equality
int gcd(int a, int b)
Compute the greatest common divisor of a and b.
IntPropLevel vbd(IntPropLevel ipl)
Extract value, bounds, or domain propagation from propagation level.
Binary domain consistent equality propagator.
Reification specification.
@ RM_EQV
Equivalence for reification (default)
Propagator for bounds consistent n-ary linear disequality
Home class for posting propagators
Post propagator for SetVar SetOpType SetVar SetRelType r
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
IntRelType swap(IntRelType irt)
Return swapped relation type of irt.
Propagator for reified bounds consistent n-ary linear less or equal
bool one(const Gecode::FloatValArgs &a)
Check whether has only one coefficients.
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
const int max
Largest allowed integer value.
Propagator for bounds consistent binary linear disequality
Propagator for reified bounds consistent binary linear equality
Propagator for domain consistent n-ary linear equality
#define GECODE_INT_PL_TER(CLASS)
Macro for posting ternary special cases for linear constraints.
#define GECODE_NEVER
Assert that this command is never executed.
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
Propagator for bounds consistent ternary linear equality
void fail(void)
Mark space as failed.
@ IPL_DEF
Simple propagation levels.
ReifyMode
Mode for reification.
void posteqint(Home home, IntView &x, int c, CtrlView b, ReifyMode rm, IntPropLevel ipl)
#define GECODE_INT_PL_BIN(CLASS)
Macro for posting binary special cases for linear constraints.
Integer view for integer variables.
bool precision(Term< IntView > *t_p, int n_p, Term< IntView > *t_n, int n_n, long long int d)
Decide the required precision and check for overflow.
Reified bounds consistent equality with integer propagator.
Propagator for reified bounds consistent n-ary linear equality
#define GECODE_ME_FAIL(me)
Check whether modification event me is failed, and fail space home.
Propagator for bounds consistent ternary linear less or equal
Propagator for reified bounds consistent binary linear less or equal
const int min
Smallest allowed integer value.
Exception: Unknown relation passed as argument
Propagator for bounds consistent binary linear equality
void post(Home home, Term< BoolView > *t, int n, IntRelType irt, IntView x, int c, IntPropLevel)
Post propagator for linear constraint over Booleans.
Exception: Value out of limits
Gecode::FloatVal c(-8, 8)
int n
Number of negative literals for node type.
Gecode::IntArgs i({1, 2, 3, 4})
@ IRT_LQ
Less or equal ( )