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) {
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--; )
386 for (
int i = n_n;
i--; )
391 post_nary<int,IntScaleView>(home,
x,
y,irt,
c);
397 for (
int i = n_p;
i--; )
400 for (
int i = n_n;
i--; )
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--; )
848 for (
int i = n_n;
i--; )
850 post_nary<int,IntScaleView>(home,
x,
y,irt,
c,
r);
854 for (
int i = n_p;
i--; )
857 for (
int i = n_n;
i--; )
859 post_nary<long long int,LLongScaleView>(home,
x,
y,irt,
d,
r);
Scale integer view (template)
Propagator for bounds consistent binary linear disequality
IntPropLevel vbd(IntPropLevel ipl)
Extract value, bounds, or domain propagation from propagation level.
Propagator for bounds consistent n-ary linear equality
Inverse implication for reification.
Exception: Value out of limits
void eliminate(Term< BoolView > *t, int &n, long long int &d)
Eliminate assigned views.
Binary domain consistent equality propagator.
Propagator for reified bounds consistent n-ary linear less or equal
bool one(const Gecode::FloatValArgs &a)
Check whether has only one coefficients.
Propagator for bounds consistent n-ary linear disequality
Propagator for domain consistent n-ary linear equality
bool assigned(void) const
Test whether view is assigned.
Propagator for bounds consistent ternary linear equality
Reified less or equal with integer propagator.
Propagator for bounds consistent binary linear equality
const int max
Largest allowed integer value.
const int min
Smallest allowed integer value.
Propagator for bounds consistent ternary linear less or equal
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Gecode::FloatVal c(-8, 8)
Exception: Unknown relation passed as argument
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
IntRelType
Relation types for integers.
int gcd(int a, int b)
Compute the greatest common divisor of a and b.
Simple propagation levels.
Propagator for bounds consistent binary linear less or equal
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.
Reification specification.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
void rewrite(IntRelType &r, long long int &d)
Rewrite non-strict relations.
bool overflow_add(int n, int m)
Check whether adding n and m would overflow.
IntType floor_div_xp(IntType x, IntType y)
Compute where y is non-negative.
Propagator for reified bounds consistent n-ary linear equality
Propagator for reified bounds consistent binary linear less or equal
#define GECODE_INT_PL_BIN(CLASS)
Macro for posting binary special cases for linear constraints.
Post propagator for SetVar SetOpType SetVar SetRelType r
Reified bounds consistent equality with integer propagator.
IntPropLevel
Propagation levels for integer propagators.
Integer view for integer variables.
Post propagator for SetVar SetOpType SetVar y
bool overflow_sub(int n, int m)
Check whether subtracting m from n would overflow.
ScaleView< int, unsigned int > IntScaleView
Integer-precision integer scale view.
#define GECODE_INT_PL_TER(CLASS)
Macro for posting ternary special cases for linear constraints.
Domain propagation Preferences: prefer speed or memory.
Propagator for reified bounds consistent binary linear equality
Post propagator for SetVar x
#define GECODE_ME_FAIL(me)
Check whether modification event me is failed, and fail space home.
void fail(void)
Mark space as failed.
Class for describing linear term .
void posteqint(Home home, IntView &x, int c, CtrlView b, ReifyMode rm, IntPropLevel ipl)
void post_nary(Home home, ViewArray< View > &x, ViewArray< View > &y, IntRelType irt, Val c)
Posting n-ary propagators.
Gecode toplevel namespace
Propagator for bounds consistent n-ary linear less or equal
Implication for reification.
void post(Home home, Term< BoolView > *t, int n, IntRelType irt, IntView x, int c, IntPropLevel)
Post propagator for linear constraint over Booleans.
ScaleView< long long int, unsigned long long int > LLongScaleView
Long long-precision integer scale view.
Propagator for bounds consistent ternary linear disquality
Reified domain consistent equality with integer propagator.
void check(int n, const char *l)
Check whether n is in range, otherwise throw out of limits with information l.
Home class for posting propagators
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
ReifyMode
Mode for reification.
#define GECODE_NEVER
Assert that this command is never executed.
Equivalence for reification (default)
IntRelType swap(IntRelType irt)
Return swapped relation type of irt.
Boolean view for Boolean variables.