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);
236 rewrite(irt,d,t_p,n_p,t_n,n_n);
242 if ((d % gcd) != 0) {
292 if ((n == 2) && is_unit &&
294 (irt ==
IRT_EQ) && (d == 0)) {
320 bool is_ip =
precision(t_p,n_p,t_n,n_n,d);
322 if (is_unit && is_ip &&
325 c =
static_cast<int>(
d);
342 for (
int i = n_p;
i--; )
345 for (
int i = n_n;
i--; )
347 post_nary<int,IntView>(home,
x,
y,irt,
c);
350 if ((n==2) && is_unit &&
354 c =
static_cast<int>(
d);
380 c =
static_cast<int>(
d);
382 for (
int i = n_p;
i--; )
385 for (
int i = n_n;
i--; )
390 post_nary<int,IntScaleView>(home,
x,
y,irt,
c);
396 for (
int i = n_p;
i--; )
399 for (
int i = n_n;
i--; )
403 ::
post(home,x,y,d)));
405 post_nary<long long int,LLongScaleView>(home,
x,
y,irt,
d);
410 #undef GECODE_INT_PL_BIN 411 #undef GECODE_INT_PL_TER 418 template<
class Val,
class View>
447 post(home,x,y,c,
n)));
451 post(home,x,y,c,
n)));
455 post(home,x,y,c,
n)));
482 template<
class CtrlView>
532 bool is_unit = normalize<IntView>(
t,
n,t_p,n_p,t_n,n_n,
gcd);
534 rewrite(irt,d,t_p,n_p,t_n,n_n);
540 if ((d % gcd) != 0) {
548 if ((d % gcd) != 0) {
565 case IRT_EQ: fail = (d != 0);
break;
566 case IRT_NQ: fail = (d == 0);
break;
567 case IRT_LQ: fail = (0 >
d);
break;
580 bool is_ip =
precision(t_p,n_p,t_n,n_n,d);
582 if (is_unit && is_ip) {
583 c =
static_cast<int>(
d);
588 posteqint<BoolView>(home,t_p[0].x,
c,r.
var(),r.
mode(),ipl);
590 posteqint<BoolView>(home,t_p[0].x,-
c,r.
var(),r.
mode(),ipl);
603 posteqint<NegBoolView>(home,t_p[0].x,
c,nb,rm,ipl);
605 posteqint<NegBoolView>(home,t_p[0].x,-
c,nb,rm,ipl);
618 post(home,t_p[0].x,c,r.
var())));
622 post(home,t_p[0].x,c,r.
var())));
631 post(home,t_n[0].
x,-c-1,nb)));
635 post(home,t_n[0].x,-c-1,nb)));
639 post(home,t_n[0].x,-c-1,nb)));
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())));
663 post(home,t_p[0].x,t_p[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())));
700 post(home,t_n[0].x,t_n[1].x,-c,r.
var())));
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)));
724 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)));
758 post(home,t_p[0].x,t_p[1].x,-c,nb)));
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())));
781 post(home,t_p[0].x,t_p[1].x,c,r.
var())));
833 for (
int i = n_p;
i--; )
836 for (
int i = n_n;
i--; )
838 post_nary<int,IntView>(home,
x,
y,irt,
c,
r);
842 c =
static_cast<int>(
d);
844 for (
int i = n_p;
i--; )
847 for (
int i = n_n;
i--; )
849 post_nary<int,IntScaleView>(home,
x,
y,irt,
c,
r);
853 for (
int i = n_p;
i--; )
856 for (
int i = n_n;
i--; )
858 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
ReifyMode mode(void) const
Return reification mode.
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
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.
ModEvent lq(Space &home, Val n)
Restrict domain values to be less or equal than n.
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.
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.
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
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.
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
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 Options: basic versus advanced propagation.
Propagator for reified bounds consistent binary linear equality
BoolVar var(void) const
Return Boolean control variable.
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
ModEvent nq(Space &home, Val n)
Restrict domain values to be different from n.
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.
ModEvent eq(Space &home, Val n)
Restrict domain values to be equal to n.
ModEvent gq(Space &home, Val n)
Restrict domain values to be greater or equal than n.
Equivalence for reification (default)
IntRelType swap(IntRelType irt)
Return swapped relation type of irt.
Boolean view for Boolean variables.