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>
93 template<
class ViewM,
class ViewP,
class ViewU,
class View>
106 return sizeof(*this);
109 template<
class ViewM,
class ViewP,
class ViewU,
class View>
115 template<
class ViewM,
class ViewP,
class ViewU,
class View>
125 template<
class ViewM,
class ViewP,
class ViewU,
class View>
152 Event(ev_t
_e,
int _task,
int _date,
int _inc = 0,
bool _first_prof =
false)
153 : e(_e), task(_task), date(_date), inc(_inc), first_prof(_first_prof)
161 if (date == ev.
date) {
166 return date < ev.
date;
170 template<
class ViewM,
class ViewP,
class ViewU,
class View>
175 int* prune_tasks,
int& prune_tasks_size) {
177 if (ntask > 0 && (
at_most ? su >
c[r] : su <
c[r])) {
182 while (pti != prune_tasks_size) {
183 int t = prune_tasks[pti];
191 (
at_most ? su-contribution[t] >
c[r]
192 : su-contribution[t] <
c[r])) {
209 : su-contribution[t]+
u[t].
max() <
c[r]) {
210 if (
e[t].
min() > low &&
217 int ptmin =
p[
t].min();
220 a(low-ptmin+1, up),
b(low+1, up+ptmin);
246 ?
u[t].lq(home,
c[r]-su+contribution[t])
247 :
u[t].gq(home,
c[r]-su+contribution[t]))) {
253 if (!
m[t].in(r) || (
e[t].
max() <= up+1)) {
254 prune_tasks[pti] = prune_tasks[--prune_tasks_size];
267 bool operator ()(
const C& lhs,
const C& rhs) {
273 template<
class ViewM,
class ViewP,
class ViewU,
class View>
278 for (
int t =
s.size();
t--; )
289 int *prune_tasks = region.
alloc<
int>(
s.size());
290 int prune_tasks_size;
291 int *contribution = region.
alloc<
int>(
s.size());
292 for (
int r =
c.
size();
r--; ) {
294 #define GECODE_PUSH_EVENTS(E) assert(events_size < s.size()*8); \ 295 events[events_size++] = E 298 for (
int t =
s.size();
t--; ) {
301 s[
t].max() <
e[
t].min()) {
335 #undef GECODE_PUSH_EVENTS 338 if (events_size == 0) {
352 prune_tasks_size = 0;
353 for (
int i =
s.size();
i--; ) contribution[
i] = 0;
356 while (ei < events_size) {
358 if (d != events[ei].date) {
361 contribution, prune_tasks, prune_tasks_size));
365 ntask += events[ei].
inc;
367 su += events[ei].
inc;
368 if(events[ei].first_prof)
370 ?
std::max(contribution[events[ei].task], events[ei].inc)
371 :
std::min(contribution[events[ei].task], events[ei].inc);
374 assert(prune_tasks_size<
s.size());
375 prune_tasks[prune_tasks_size++] = events[ei].
task;
382 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 reschedule(Space &home, Propagator &p, PropCond pc)
Re-schedule propagator p with propagation condition pc.
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
Range iterator for singleton range.
void update(Space &home, ViewArray< View > &a)
Update array to be a clone of array a.
ExecStatus ES_SUBSUMED(Propagator &p)
ev_t e
The type of the event.
Actor must always be disposed.
int date
The date of this event.
ExecStatus subsumed(Space &home, Propagator &p, int c, TaskArray< Task > &t)
Check for subsumption (all tasks must be assigned)
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.
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to variable.
Multi _c(Gecode::IntArgs(3, 1, 2, 3))
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.
Base-class for both propagators and branchers.
#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)
int size(void) const
Return number of elements.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
bool failed(void) const
Check whether space is failed.
virtual size_t dispose(Space &home)
Dispose propagator.
Val(Space &home, Val< ViewM, ViewP, ViewU, View > &p)
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
union Gecode::@585::NNF::@62 u
Union depending on nodetype t.
Propagator for the cumulatives constraint
void cancel(Space &home, Propagator &p, PropCond pc)
Cancel subscription of propagator p with propagation condition pc to all views.
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
An event collects the information for one evnet for the sweep-line.
Post propagator for SetVar SetOpType SetVar SetRelType r
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Event(ev_t _e, int _task, int _date, int _inc=0, bool _first_prof=false)
Simple constructor.
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low quadratic)
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
virtual size_t dispose(Space &home)
Delete actor and return its size.
bool assigned(View x, int v)
Whether x is assigned to value v.
void insertion(Type *l, Type *r, Less &less)
Standard insertion sort.
virtual void reschedule(Space &home)
Schedule function.
Propagation has not computed fixpoint.
bool operator<(const FloatVal &x, const FloatVal &y)
int inc
The quantity changed by this event (if any)
Gecode toplevel namespace
#define GECODE_PUSH_EVENTS(E)
Multi _e(Gecode::IntArgs(4, 4, 2, 3, 1))
int ModEventDelta
Modification event deltas.
Home class for posting propagators
virtual Actor * copy(Space &home)
Create copy during cloning.
bool me_failed(ModEvent me)
Check whether modification event me is failed.