45 template<
class ViewM,
class ViewP,
class ViewU,
class View>
66 template<
class ViewM,
class ViewP,
class ViewU,
class View>
77 template<
class ViewM,
class ViewP,
class ViewU,
class View>
89 template<
class ViewM,
class ViewP,
class ViewU,
class View>
102 return sizeof(*this);
105 template<
class ViewM,
class ViewP,
class ViewU,
class View>
111 template<
class ViewM,
class ViewP,
class ViewU,
class View>
121 template<
class ViewM,
class ViewP,
class ViewU,
class View>
160 template<
class ViewM,
class ViewP,
class ViewU,
class View>
165 int* prune_tasks,
int& prune_tasks_size) {
167 if (ntask > 0 && (
at_most ? su >
c[r] : su <
c[r])) {
172 while (pti != prune_tasks_size) {
173 int t = prune_tasks[pti];
181 (
at_most ? su-contribution[t] >
c[r]
182 : su-contribution[t] <
c[r])) {
197 :
u[t].
max() < std::max(0,
c[r])) {
199 : su-contribution[t]+
u[t].
max() <
c[r]) {
200 if (
e[t].
min() > low &&
206 }
else if (
m[t].assigned()) {
207 int ptmin =
p[t].min();
210 a(low-ptmin+1, up), b(low+1, up+ptmin);
230 if (
m[t].assigned() &&
236 ?
u[t].lq(home,
c[r]-su+contribution[t])
237 :
u[t].gq(home,
c[r]-su+contribution[t]))) {
243 if (!
m[t].in(r) || (
e[t].
max() <= up+1)) {
244 prune_tasks[pti] = prune_tasks[--prune_tasks_size];
257 bool operator ()(
const C& lhs,
const C& rhs) {
263 template<
class ViewM,
class ViewP,
class ViewU,
class View>
267 bool subsumed =
true;
268 for (
int t=0; t<
s.size(); t++)
269 if (!(
p[t].assigned() &&
e[t].assigned() &&
270 m[t].assigned() &&
s[t].assigned() &&
279 int *prune_tasks = region.
alloc<
int>(
s.size());
280 int prune_tasks_size;
281 int *contribution = region.
alloc<
int>(
s.size());
282 for (
int r =
c.size(); r--; ) {
284#define GECODE_PUSH_EVENTS(E) assert(events_size < s.size()*8); \
285 events[events_size++] = E
288 for (
int t =
s.size(); t--; ) {
289 if (
m[t].assigned() &&
293 ?
u[t].
min() > std::min(0,
c[r])
294 :
u[t].
max() < std::max(0,
c[r])) {
317 if (!(
m[t].assigned() &&
325#undef GECODE_PUSH_EVENTS
328 if (events_size == 0) {
342 prune_tasks_size = 0;
343 for (
int i =
s.size(); i--; ) contribution[i] = 0;
346 while (ei < events_size) {
348 if (d != events[ei].date) {
351 contribution, prune_tasks, prune_tasks_size));
355 ntask += events[ei].
inc;
357 su += events[ei].
inc;
358 contribution[events[ei].
task] += events[ei].inc;
361 assert(prune_tasks_size<
s.size());
362 prune_tasks[prune_tasks_size++] = events[ei].
task;
369 contribution, prune_tasks, prune_tasks_size));
Base-class for both propagators and branchers.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Home class for posting propagators
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
An event collects the information for one event for the sweep-line.
int date
The date of this event.
int task
The task this event refers to.
Event(ev_t _e, int _task, int _date, int _inc=0)
Simple constructor.
ev_t e
The type of the event.
bool operator<(const Event &ev) const
Order events based on date.
int inc
The quantity changed by this event (if any).
Propagator for the cumulatives constraint
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
ExecStatus prune(Space &home, int low, int up, int r, int ntask, int su, int *contribution, int *prune_tasks, int &prune_tasks_size)
virtual Actor * copy(Space &home)
Create copy during cloning.
virtual void reschedule(Space &home)
Schedule function.
Val(Space &home, Val< ViewM, ViewP, ViewU, View > &p)
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low quadratic).
virtual size_t dispose(Space &home)
Dispose propagator.
Range iterator for singleton range.
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
Propagator(Home home)
Constructor for posting.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
Shared array with arbitrary number of elements.
ExecStatus ES_SUBSUMED(Propagator &p)
Propagator p is subsumed
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
int ModEventDelta
Modification event deltas.
bool failed(void) const
Check whether space is failed.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
@ AP_DISPOSE
Actor must always be disposed.
#define GECODE_PUSH_EVENTS(E)
ev_t
Types of events for the sweep-line.
ModEvent prune(Space &home, View x, int v)
Exclude value v from variable view x.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
void insertion(Type *l, Type *r, Less &less)
Standard insertion sort.
Gecode toplevel namespace
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
@ ES_OK
Execution is okay.
@ 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 .