47 namespace Gecode {
namespace Int {
namespace Cumulatives {
49 template<
class ViewM,
class ViewP,
class ViewU,
class View>
60 m(_m), s(_s),
p(_p), e(_e),
u(_u),
c(_c), at_most(_at_most) {
70 template<
class ViewM,
class ViewP,
class ViewU,
class View>
77 (void)
new (home)
Val(home, m,s,p,e,u,c,at_most);
81 template<
class ViewM,
class ViewP,
class ViewU,
class View>
85 :
Propagator(home,share,vp), at_most(vp.at_most) {
87 s.update(home, share, vp.
s);
89 e.update(home, share, vp.
e);
94 template<
class ViewM,
class ViewP,
class ViewU,
class View>
107 return sizeof(*this);
110 template<
class ViewM,
class ViewP,
class ViewU,
class View>
116 template<
class ViewM,
class ViewP,
class ViewU,
class View>
143 Event(
ev_t _e,
int _task,
int _date,
int _inc = 0,
bool _first_prof =
false)
161 template<
class ViewM,
class ViewP,
class ViewU,
class View>
166 int* prune_tasks,
int& prune_tasks_size) {
168 if (ntask > 0 && (at_most ? su >
c[r] : su <
c[r])) {
173 while (pti != prune_tasks_size) {
174 int t = prune_tasks[pti];
180 (at_most ?
u[t].
min() < 0
182 (at_most ? su-contribution[t] >
c[r]
183 : su-contribution[t] <
c[r])) {
199 if (at_most ? su-contribution[t]+
u[t].
min() >
c[r]
200 : su-contribution[t]+
u[t].
max() <
c[r]) {
201 if (e[t].
min() > low &&
208 int ptmin =
p[
t].min();
211 a(low-ptmin+1, up),
b(low+1, up+ptmin);
237 ?
u[t].lq(home,
c[r]-su+contribution[t])
238 :
u[t].gq(home,
c[r]-su+contribution[t]))) {
244 if (!m[t].in(r) || (e[t].
max() <= up+1)) {
245 prune_tasks[pti] = prune_tasks[--prune_tasks_size];
258 bool operator ()(
const C& lhs,
const C& rhs) {
264 template<
class ViewM,
class ViewP,
class ViewU,
class View>
269 for (
int t = s.size();
t--; )
280 int *prune_tasks = region.
alloc<
int>(s.size());
281 int prune_tasks_size;
282 int *contribution = region.
alloc<
int>(s.size());
283 for (
int r =
c.
size();
r--; ) {
285 #define GECODE_PUSH_EVENTS(E) assert(events_size < s.size()*8); \
286 events[events_size++] = E
289 for (
int t = s.size();
t--; ) {
292 s[
t].max() < e[
t].min()) {
326 #undef GECODE_PUSH_EVENTS
329 if (events_size == 0) {
343 prune_tasks_size = 0;
344 for (
int i = s.
size();
i--; ) contribution[
i] = 0;
347 while (ei < events_size) {
349 if (d != events[ei].date) {
352 contribution, prune_tasks, prune_tasks_size));
356 ntask += events[ei].
inc;
358 su += events[ei].
inc;
359 if(events[ei].first_prof)
360 contribution[events[ei].
task] = at_most
361 ?
std::max(contribution[events[ei].task], events[ei].inc)
362 :
std::min(contribution[events[ei].task], events[ei].inc);
365 assert(prune_tasks_size<s.size());
366 prune_tasks[prune_tasks_size++] = events[ei].
task;
373 contribution, prune_tasks, prune_tasks_size));
FloatVal max(const FloatNum &x, const FloatVal &y)
ExecStatus prune(Space &home, int low, int up, int r, int ntask, int su, int *contribution, int *prune_tasks, int &prune_tasks_size)
void update(Space &, bool share, ViewArray< View > &a)
Update array to be a clone of array a.
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
bool operator<(const Event &ev) const
Order events based on date.
Range iterator for singleton range.
ExecStatus ES_SUBSUMED(Propagator &p)
union Gecode::@512::NNF::@54 u
Union depending on nodetype t.
ev_t e
The type of the event.
Actor must always be disposed.
int size(void) const
Return size of array (number of elements)
int date
The date of this event.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
ev_t
Types of events for the sweep-line.
Base-class for propagators.
static ExecStatus post(Home home, const ViewArray< ViewM > &, const ViewArray< View > &, const ViewArray< ViewP > &, const ViewArray< View > &, const ViewArray< ViewU > &, const SharedArray< int > &, bool)
Post propagator.
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
bool failed(void) const
Check whether space is failed.
Base-class for both propagators and branchers.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low quadratic)
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int task
The task this event refers to.
Execution has resulted in failure.
FloatVal min(const FloatNum &x, const FloatVal &y)
void subscribe(Space &home, Propagator &p, PropCond pc, bool process=true)
Subscribe propagator p with propagation condition pc to variable.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
virtual size_t dispose(Space &home)
Dispose propagator.
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
struct Gecode::@512::NNF::@54::@55 b
For binary nodes (and, or, eqv)
Val(Space &home, bool share, Val< ViewM, ViewP, ViewU, View > &p)
Propagator for the cumulatives constraint
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
An event collects the information for one evnet for the sweep-line.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void update(Space &home, bool share, SharedHandle &sh)
Updating during cloning.
Event(ev_t _e, int _task, int _date, int _inc=0, bool _first_prof=false)
Simple constructor.
ExecStatus subsumed(Space &home, Propagator &p, TaskArray< Task > &t)
Check tasks t for subsumption.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Multi _e(Gecode::IntArgs(4, 4, 2, 3, 1))
bool assigned(View x, int v)
Whether x is assigned to value v.
void insertion(Type *l, Type *r, Less &less)
Standard insertion sort.
Propagation has not computed fixpoint.
FloatNum size(void) const
Return size of float value (distance between maximum and minimum)
int inc
The quantity changed by this event (if any)
#define GECODE_PUSH_EVENTS(E)
struct Gecode::@512::NNF::@54::@56 a
For atomic nodes.
int ModEventDelta
Modification event deltas.
Home class for posting propagators
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Multi _c(Gecode::IntArgs(3, 1, 2, 3))