36namespace Gecode {
namespace Float {
namespace Linear {
42 template<
class P,
class N, PropCond pc>
50 template<
class P,
class N, PropCond pc>
58 template<
class P,
class N, PropCond pc>
64 template<
class P,
class N, PropCond pc>
67 x.reschedule(home,*
this,pc);
68 y.reschedule(home,*
this,pc);
71 template<
class P,
class N, PropCond pc>
74 x.cancel(home,*
this,pc);
75 y.cancel(home,*
this,pc);
87 for (
int i =
n;
i--; ) {
101 for (
int i =
n;
i--; ) {
103 c +=
y[
i].val();
y[
i] =
y[--
n];
121 template<
class P,
class N>
126 template<
class P,
class N>
134 template<
class P,
class N>
139 template<
class P,
class N>
142 return new (home)
Eq<P,N>(home,*
this);
145 template<
class P,
class N>
150 eliminate_p<P>(med,
x,
c);
151 eliminate_n<N>(med,
y,
c);
169 for (
int i =
x.size();
i--; ) {
172 for (
int j =
x.size(); j--; ) {
173 if (
i == j)
continue;
174 sl =
r.sub_up(sl,
x[j].
min());
176 for (
int j =
y.size(); j--; )
177 sl =
r.add_up(sl,
y[j].
max());
187 for (
int i =
y.size();
i--; ) {
190 for (
int j =
x.size(); j--; )
191 sl =
r.add_down(sl,
x[j].
min());
192 for (
int j =
y.size(); j--; ) {
193 if (
i == j)
continue;
194 sl =
r.sub_down(sl,
y[j].
max());
206 for (
int i =
x.size();
i--; ) {
209 for (
int j =
x.size(); j--; ) {
210 if (
i == j)
continue;
211 su =
r.sub_down(su,
x[j].
max());
213 for (
int j =
y.size(); j--; )
214 su =
r.add_down(su,
y[j].
min());
224 for (
int i =
y.size();
i--; ) {
227 for (
int j =
x.size(); j--; )
228 su =
r.add_up(su,
x[j].
max());
229 for (
int j =
y.size(); j--; ) {
230 if (
i == j)
continue;
231 su =
r.sub_up(su,
y[j].
min());
251 template<
class P,
class N>
256 template<
class P,
class N>
263 template<
class P,
class N>
268 template<
class P,
class N>
271 return new (home)
Lq<P,N>(home,*
this);
274 template<
class P,
class N>
283 for (
int i =
x.size();
i--; ) {
285 c -=
x[
i].val();
x.move_lst(
i);
287 sl =
r.sub_up(sl,
x[
i].
min());
290 for (
int i =
y.size();
i--; ) {
292 c +=
y[
i].val();
y.move_lst(
i);
294 sl =
r.add_up(sl,
y[
i].
max());
297 if ((
x.size() +
y.size()) <= 1) {
309 for (
int i =
x.size();
i--; )
310 sl =
r.sub_up(sl,
x[
i].
min());
311 for (
int i =
y.size();
i--; )
312 sl =
r.add_up(sl,
y[
i].
max());
315 sl =
r.add_up(sl,
c.
max());
319 for (
int i =
x.size();
i--; ) {
331 for (
int i =
y.size();
i--; ) {
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
Base-class for both propagators and branchers.
virtual size_t dispose(Space &home)
Delete actor and return its size.
bool in(FloatNum n) const
Test whether n is included.
friend FloatVal max(const FloatVal &x, const FloatVal &y)
friend FloatVal min(const FloatVal &x, const FloatVal &y)
Propagator for bounds consistent n-ary linear equality
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, FloatVal c)
Post propagator for .
virtual Actor * copy(Space &home)
Create copy during cloning.
Eq(Space &home, Eq &p)
Constructor for cloning p.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Base-class for n-ary linear propagators.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear)
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Lin(Space &home, Lin< P, N, pc > &p)
Constructor for cloning p.
ViewArray< P > x
Array of positive views.
virtual void reschedule(Space &home)
Schedule function.
ViewArray< N > y
Array of negative views.
Propagator for bounds consistent n-ary linear less or equal
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, FloatVal c)
Post propagator for .
virtual Actor * copy(Space &home)
Create copy during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Lq(Space &home, Lq &p)
Constructor for cloning p.
Floating point rounding policy.
Home class for posting propagators
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
Base-class for propagators.
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
void update(Space &home, ViewArray< View > &a)
Update array to be a clone of array a.
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to variable.
ExecStatus ES_SUBSUMED(Propagator &p)
int ModEventDelta
Modification event deltas.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
double FloatNum
Floating point number base type.
void eliminate_n(ModEventDelta med, ViewArray< View > &y, FloatVal &c)
void eliminate_p(ModEventDelta med, ViewArray< View > &x, FloatVal &c)
bool infty(const FloatNum &n)
const Gecode::ModEvent ME_FLOAT_VAL
Domain operation has resulted in a value (assigned variable)
const Gecode::ModEvent ME_FLOAT_FAILED
Domain operation has resulted in failure.
const Gecode::PropCond PC_FLOAT_BND
Propagate when minimum or maximum of a view changes.
const int infinity
Infinity for integers.
bool assigned(View x, int v)
Whether x is assigned to value v.
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar SetOpType SetVar y
@ ES_OK
Execution is okay.
@ ES_FIX
Propagation has computed fixpoint.
@ ES_FAILED
Execution has resulted in failure.
@ ES_NOFIX
Propagation has not computed fixpoint.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar x
int ModEvent
Type for modification events.
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i({1, 2, 3, 4})