40namespace Gecode {
namespace Int {
namespace Linear {
47 long long int ax =
t[i].a *
static_cast<long long int>(
t[i].x.val());
70 std::swap(n_p,n_n); std::swap(t_p,t_n); d = -d;
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; \
232 rewrite(irt,d,t_p,n_p,t_n,n_n);
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 &&
290 (irt ==
IRT_EQ) && (d == 0)) {
316 bool is_ip =
precision(t_p,n_p,t_n,n_n,d);
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++)
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);
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);
406#undef GECODE_INT_PL_BIN
407#undef GECODE_INT_PL_TER
414 template<
class Val,
class View>
478 template<
class CtrlView>
530 rewrite(irt,d,t_p,n_p,t_n,n_n);
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;
576 bool is_ip =
precision(t_p,n_p,t_n,n_n,d);
578 if (is_unit && is_ip) {
579 c =
static_cast<int>(d);
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++)
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);
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);
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Home class for posting propagators
void fail(void)
Mark space as failed.
Boolean view for Boolean variables.
bool zero(void) const
Test whether view is assigned to be zero.
bool one(void) const
Test whether view is assigned to be one.
Integer view for integer variables.
Propagator for domain consistent n-ary linear equality
Propagator for bounds consistent binary linear equality
Propagator for bounds consistent ternary linear equality
Propagator for bounds consistent n-ary linear equality
Propagator for bounds consistent binary linear less or equal
Propagator for bounds consistent ternary linear less or equal
Propagator for bounds consistent n-ary linear less or equal
Propagator for bounds consistent binary linear disequality
Propagator for bounds consistent ternary linear disquality
Propagator for bounds consistent n-ary linear disequality
Propagator for reified bounds consistent binary linear equality
Propagator for reified bounds consistent n-ary linear equality
Propagator for reified bounds consistent binary linear less or equal
Propagator for reified bounds consistent n-ary linear less or equal
Class for describing linear term .
Exception: Value out of limits
Binary domain consistent equality propagator.
Reified bounds consistent equality with integer propagator.
Reified domain consistent equality with integer propagator.
Reified less or equal with integer propagator.
Exception: Unknown relation passed as argument
Reification specification.
bool assigned(void) const
Test whether view is assigned.
void post(Home home, Term< IntView > *t, int n, IntRelType irt, int c, IntPropLevel=IPL_DEF)
Post propagator for linear constraint over integers.
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
#define GECODE_ME_FAIL(me)
Check whether modification event me is failed, and fail space home.
IntRelType
Relation types for integers.
ReifyMode
Mode for reification.
IntPropLevel
Propagation levels for integer propagators.
@ IRT_GQ
Greater or equal ( )
@ IRT_LQ
Less or equal ( )
@ RM_IMP
Implication for reification.
@ RM_PMI
Inverse implication for reification.
@ RM_EQV
Equivalence for reification (default)
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
@ IPL_DEF
Simple propagation levels.
#define GECODE_INT_PL_TER(CLASS)
Macro for posting ternary special cases for linear constraints.
#define GECODE_INT_PL_BIN(CLASS)
Macro for posting binary special cases for linear constraints.
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.
const int min
Smallest allowed integer value.
const int max
Largest allowed integer value.
bool overflow_sub(int n, int m)
Check whether subtracting m from n would overflow.
void eliminate(Term< BoolView > *t, int &n, long long int &d)
Eliminate assigned views.
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.
void posteqint(Home home, IntView &x, int c, CtrlView b, ReifyMode rm, IntPropLevel ipl)
void rewrite(IntRelType &r, long long int &d)
Rewrite non-strict relations.
int gcd(int a, int b)
Compute the greatest common divisor of a and b.
bool normalize(Term< View > *t, int &n, Term< View > *&t_p, int &n_p, Term< View > *&t_n, int &n_n, int &g)
Normalize linear integer constraints.
void post_nary(Home home, ViewArray< View > &x, ViewArray< View > &y, IntRelType irt, Val c)
Posting n-ary propagators.
IntType floor_div_xp(IntType x, IntType y)
Compute where y is non-negative.
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
IntPropLevel vbd(IntPropLevel ipl)
Extract value, bounds, or domain propagation from propagation level.
Post propagator for SetVar SetOpType SetVar y
Post propagator for SetVar x
#define GECODE_NEVER
Assert that this command is never executed.