40 namespace Gecode {
namespace Float {
namespace Linear {
46 template<
class P,
class N, PropCond pc>
50 x.subscribe(home,*
this,pc);
51 y.subscribe(home,*
this,pc);
54 template<
class P,
class N, PropCond pc>
58 x.update(home,share,
p.x);
59 y.update(home,share,
p.y);
62 template<
class P,
class N, PropCond pc>
68 template<
class P,
class N, PropCond pc>
71 x.cancel(home,*
this,pc);
72 y.cancel(home,*
this,pc);
73 (void) Propagator::dispose(home);
128 for (
int i =
n;
i--; ) {
130 c -=
x[
i].val();
x[
i] =
x[--
n];
142 for (
int i =
n;
i--; ) {
144 c += y[
i].val(); y[
i] = y[--
n];
162 template<
class P,
class N>
167 template<
class P,
class N>
175 template<
class P,
class N>
180 template<
class P,
class N>
183 return new (home)
Eq<P,N>(home,share,*
this);
186 template<
class P,
class N>
191 eliminate_p<P>(med,
x,
c);
192 eliminate_n<N>(med, y,
c);
210 for (
int i =
x.size();
i--; ) {
213 for (
int j =
x.size(); j--; ) {
214 if (
i == j)
continue;
215 sl =
r.sub_up(sl,
x[j].
min());
217 for (
int j = y.size(); j--; )
218 sl =
r.add_up(sl,y[j].max());
228 for (
int i = y.
size();
i--; ) {
231 for (
int j =
x.size(); j--; )
232 sl =
r.add_down(sl,
x[j].min());
233 for (
int j = y.size(); j--; ) {
234 if (
i == j)
continue;
235 sl =
r.sub_down(sl,y[j].
max());
247 for (
int i =
x.size();
i--; ) {
250 for (
int j =
x.size(); j--; ) {
251 if (
i == j)
continue;
252 su =
r.sub_down(su,
x[j].
max());
254 for (
int j = y.size(); j--; )
255 su =
r.add_down(su,y[j].min());
265 for (
int i = y.
size();
i--; ) {
268 for (
int j =
x.size(); j--; )
269 su =
r.add_up(su,
x[j].max());
270 for (
int j = y.size(); j--; ) {
271 if (
i == j)
continue;
272 su =
r.sub_up(su,y[j].
min());
292 template<
class P,
class N>
297 template<
class P,
class N>
304 template<
class P,
class N>
309 template<
class P,
class N>
312 return new (home)
Lq<P,N>(home,share,*
this);
315 template<
class P,
class N>
324 for (
int i =
x.size();
i--; ) {
326 c -=
x[
i].val();
x.move_lst(
i);
328 sl =
r.sub_up(sl,
x[
i].
min());
331 for (
int i = y.
size();
i--; ) {
333 c += y[
i].val(); y.move_lst(
i);
335 sl =
r.add_up(sl,y[
i].
max());
338 if ((
x.size() + y.size()) <= 1) {
350 for (
int i =
x.size();
i--; )
351 sl =
r.sub_up(sl,
x[
i].min());
352 for (
int i = y.
size();
i--; )
353 sl =
r.add_up(sl,y[
i].max());
356 sl =
r.add_up(sl,
c.
max());
360 for (
int i =
x.size();
i--; ) {
372 for (
int i = y.
size();
i--; ) {
Propagator for bounds consistent n-ary linear equality
Lq(Space &home, bool share, Lq &p)
Constructor for cloning p.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatNum c)
Post propagator for .
int size(void) const
Return size of array (number of elements)
ExecStatus ES_SUBSUMED(Propagator &p)
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Propagator for bounds consistent n-ary linear less or equal
int ModEvent
Type for modification events.
Base-class for n-ary linear propagators.
Base-class for propagators.
const Gecode::ModEvent ME_FLOAT_FAILED
Domain operation has resulted in failure.
bool infty(const FloatNum &n)
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
const Gecode::ModEvent ME_FLOAT_VAL
Domain operation has resulted in a value (assigned variable)
Propagation has computed fixpoint.
bool in(FloatNum n) const
Test whether n is included.
Base-class for both propagators and branchers.
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, FloatVal c)
Post propagator for .
Execution has resulted in failure.
Eq(Space &home, bool share, Eq &p)
Constructor for cloning p.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Floating point rounding policy.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
const int infinity
Infinity for integers.
Node * x
Pointer to corresponding Boolean expression node.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
bool assigned(View x, int v)
Whether x is assigned to value v.
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
Propagation has not computed fixpoint.
Lin(Space &home, bool share, Lin< P, N, pc > &p)
Constructor for cloning p.
void eliminate_p(ModEventDelta med, ViewArray< View > &x, FloatVal &c)
const Gecode::PropCond PC_FLOAT_BND
Propagate when minimum or maximum of a view changes.
void eliminate_n(ModEventDelta med, ViewArray< View > &y, FloatVal &c)
Gecode toplevel namespace
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, FloatVal c)
Post propagator for .
friend FloatVal max(const FloatVal &x, const FloatVal &y)
int size(void) const
Return size of array (number of elements)
int ModEventDelta
Modification event deltas.
friend FloatVal min(const FloatVal &x, const FloatVal &y)
Home class for posting propagators
double FloatNum
Floating point number base type.
bool me_failed(ModEvent me)
Check whether modification event me is failed.