Go to the documentation of this file.
44 namespace Gecode {
namespace Int {
namespace Linear {
51 long long int ax =
t[
i].a *
static_cast<long long int>(
t[
i].x.val());
89 for (
int i = n_p;
i--; ) {
91 t_p[
i].
a *
static_cast<long long int>(t_p[
i].
x.min());
96 t_p[
i].
a *
static_cast<long long int>(t_p[
i].
x.max());
101 for (
int i = n_n;
i--; ) {
102 long long int axmax =
103 t_n[
i].
a *
static_cast<long long int>(t_n[
i].
x.max());
107 long long int axmin =
108 t_n[
i].
a *
static_cast<long long int>(t_n[
i].
x.min());
125 for (
int i = n_p;
i--; ) {
126 long long int axmin =
127 t_p[
i].
a *
static_cast<long long int>(t_p[
i].
x.min());
132 long long int axmax =
133 t_p[
i].
a *
static_cast<long long int>(t_p[
i].
x.max());
139 for (
int i = n_n;
i--; ) {
140 long long int axmin =
141 t_n[
i].
a *
static_cast<long long int>(t_n[
i].
x.min());
146 long long int axmax =
147 t_n[
i].
a *
static_cast<long long int>(t_n[
i].
x.max());
160 template<
class Val,
class View>
180 #define GECODE_INT_PL_BIN(CLASS) \
183 GECODE_ES_FAIL((CLASS<int,IntView,IntView>::post \
184 (home,t_p[0].x,t_p[1].x,c))); \
187 GECODE_ES_FAIL((CLASS<int,IntView,MinusView>::post \
188 (home,t_p[0].x,MinusView(t_n[0].x),c))); \
191 GECODE_ES_FAIL((CLASS<int,MinusView,MinusView>::post \
192 (home,MinusView(t_n[0].x),MinusView(t_n[1].x),c))); \
194 default: GECODE_NEVER; \
198 #define GECODE_INT_PL_TER(CLASS) \
201 GECODE_ES_FAIL((CLASS<int,IntView,IntView,IntView>::post \
202 (home,t_p[0].x,t_p[1].x,t_p[2].x,c))); \
205 GECODE_ES_FAIL((CLASS<int,IntView,IntView,MinusView>::post \
206 (home,t_p[0].x,t_p[1].x, \
207 MinusView(t_n[0].x),c))); \
210 GECODE_ES_FAIL((CLASS<int,IntView,MinusView,MinusView>::post \
212 MinusView(t_n[0].x),MinusView(t_n[1].x),c))); \
215 GECODE_ES_FAIL((CLASS<int,MinusView,MinusView,MinusView>::post \
216 (home,MinusView(t_n[0].x), \
217 MinusView(t_n[1].x),MinusView(t_n[2].x),c))); \
219 default: GECODE_NEVER; \
234 bool is_unit = normalize<IntView>(
t,
n,t_p,n_p,t_n,n_n,
gcd);
242 if ((
d %
gcd) != 0) {
272 LLongScaleView
y(t_p[0].
a,t_p[0].
x);
280 LLongScaleView
y(t_n[0].
a,t_n[0].
x);
293 if (is_unit && is_ip &&
296 c =
static_cast<int>(
d);
313 for (
int i = n_p;
i--; )
316 for (
int i = n_n;
i--; )
318 post_nary<int,IntView>(home,
x,
y,irt,
c);
321 if ((
n==2) && is_unit &&
325 c =
static_cast<int>(
d);
381 c =
static_cast<int>(
d);
383 for (
int i = n_p;
i--; )
384 x[
i] = IntScaleView(t_p[
i].
a,t_p[
i].
x);
386 for (
int i = n_n;
i--; )
387 y[
i] = IntScaleView(t_n[
i].
a,t_n[
i].
x);
391 post_nary<int,IntScaleView>(home,
x,
y,irt,
c);
397 for (
int i = n_p;
i--; )
398 x[
i] = LLongScaleView(t_p[
i].
a,t_p[
i].
x);
400 for (
int i = n_n;
i--; )
401 y[
i] = LLongScaleView(t_n[
i].
a,t_n[
i].
x);
406 post_nary<long long int,LLongScaleView>(home,
x,
y,irt,
d);
411 #undef GECODE_INT_PL_BIN
412 #undef GECODE_INT_PL_TER
419 template<
class Val,
class View>
483 template<
class CtrlView>
533 bool is_unit = normalize<IntView>(
t,
n,t_p,n_p,t_n,n_n,
gcd);
541 if ((
d %
gcd) != 0) {
549 if ((
d %
gcd) != 0) {
566 case IRT_EQ: fail = (
d != 0);
break;
567 case IRT_NQ: fail = (
d == 0);
break;
568 case IRT_LQ: fail = (0 >
d);
break;
583 if (is_unit && is_ip) {
584 c =
static_cast<int>(
d);
589 posteqint<BoolView>(home,t_p[0].
x,
c,
r.var(),
r.mode(),ipl);
591 posteqint<BoolView>(home,t_p[0].
x,-
c,
r.var(),
r.mode(),ipl);
604 posteqint<NegBoolView>(home,t_p[0].
x,
c,nb,rm,ipl);
606 posteqint<NegBoolView>(home,t_p[0].
x,-
c,nb,rm,ipl);
615 post(home,t_p[0].
x,
c,
r.var())));
619 post(home,t_p[0].
x,
c,
r.var())));
623 post(home,t_p[0].
x,
c,
r.var())));
632 post(home,t_n[0].
x,-
c-1,nb)));
636 post(home,t_n[0].
x,-
c-1,nb)));
640 post(home,t_n[0].
x,-
c-1,nb)));
656 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
660 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
664 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
693 post(home,t_n[0].
x,t_n[1].
x,-
c,
r.var())));
697 post(home,t_n[0].
x,t_n[1].
x,-
c,
r.var())));
701 post(home,t_n[0].
x,t_n[1].
x,-
c,
r.var())));
717 post(home,t_p[0].
x,t_p[1].
x,
c,nb)));
721 post(home,t_p[0].
x,t_p[1].
x,
c,nb)));
725 post(home,t_p[0].
x,t_p[1].
x,
c,nb)));
751 post(home,t_p[0].
x,t_p[1].
x,-
c,nb)));
755 post(home,t_p[0].
x,t_p[1].
x,-
c,nb)));
759 post(home,t_p[0].
x,t_p[1].
x,-
c,nb)));
774 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
778 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
782 post(home,t_p[0].
x,t_p[1].
x,
c,
r.var())));
834 for (
int i = n_p;
i--; )
837 for (
int i = n_n;
i--; )
839 post_nary<int,IntView>(home,
x,
y,irt,
c,
r);
843 c =
static_cast<int>(
d);
845 for (
int i = n_p;
i--; )
846 x[
i] = IntScaleView(t_p[
i].
a,t_p[
i].
x);
848 for (
int i = n_n;
i--; )
849 y[
i] = IntScaleView(t_n[
i].
a,t_n[
i].
x);
850 post_nary<int,IntScaleView>(home,
x,
y,irt,
c,
r);
854 for (
int i = n_p;
i--; )
855 x[
i] = LLongScaleView(t_p[
i].
a,t_p[
i].
x);
857 for (
int i = n_n;
i--; )
858 y[
i] = LLongScaleView(t_n[
i].
a,t_n[
i].
x);
859 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.
Gecode::IntArgs i(4, 1, 2, 3, 4)
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
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
Post propagator for SetVar SetOpType SetVar SetRelType r
@ IPL_DOM
Domain propagation Preferences: prefer speed or memory.
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.
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.
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.
@ IRT_LQ
Less or equal ( )