43namespace Gecode {
namespace Int {
namespace Cumulatives {
45 template<
class ViewM,
class ViewP,
class ViewU,
class View>
56 m(_m), s(_s),
p(_p), e(
_e),
u(_u),
c(
_c), at_most(_at_most) {
66 template<
class ViewM,
class ViewP,
class ViewU,
class View>
73 (void)
new (home)
Val(home, m,s,
p,e,
u,
c,at_most);
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>
148 Event(
ev_t _e,
int _task,
int _date,
int _inc = 0,
bool _first_prof =
false)
166 template<
class ViewM,
class ViewP,
class ViewU,
class View>
171 int* prune_tasks,
int& prune_tasks_size) {
173 if (ntask > 0 && (at_most ? su >
c[
r] : su <
c[
r])) {
178 while (pti != prune_tasks_size) {
179 int t = prune_tasks[pti];
185 (at_most ?
u[
t].
min() < 0
187 (at_most ? su-contribution[
t] >
c[
r]
188 : su-contribution[
t] <
c[
r])) {
204 if (at_most ? su-contribution[
t]+
u[
t].
min() >
c[
r]
205 : su-contribution[
t]+
u[
t].
max() <
c[
r]) {
206 if (e[
t].
min() > low &&
213 int ptmin =
p[
t].min();
216 a(low-ptmin+1, up),
b(low+1, up+ptmin);
242 ?
u[
t].lq(home,
c[
r]-su+contribution[
t])
243 :
u[
t].gq(home,
c[
r]-su+contribution[
t]))) {
249 if (!m[
t].in(
r) || (e[
t].
max() <= up+1)) {
250 prune_tasks[pti] = prune_tasks[--prune_tasks_size];
263 bool operator ()(
const C& lhs,
const C& rhs) {
269 template<
class ViewM,
class ViewP,
class ViewU,
class View>
274 for (
int t=0;
t<s.size();
t++)
285 int *prune_tasks = region.
alloc<
int>(s.size());
286 int prune_tasks_size;
287 int *contribution = region.
alloc<
int>(s.size());
288 for (
int r =
c.
size();
r--; ) {
290#define GECODE_PUSH_EVENTS(E) assert(events_size < s.size()*8); \
291 events[events_size++] = E
294 for (
int t = s.size();
t--; ) {
297 s[
t].max() < e[
t].min()) {
331#undef GECODE_PUSH_EVENTS
334 if (events_size == 0) {
348 prune_tasks_size = 0;
349 for (
int i = s.
size();
i--; ) contribution[
i] = 0;
352 while (ei < events_size) {
354 if (
d != events[ei].date) {
357 contribution, prune_tasks, prune_tasks_size));
361 ntask += events[ei].
inc;
363 su += events[ei].
inc;
364 if(events[ei].first_prof)
365 contribution[events[ei].
task] = at_most
366 ?
std::max(contribution[events[ei].task], events[ei].inc)
367 :
std::min(contribution[events[ei].task], events[ei].inc);
370 assert(prune_tasks_size<s.size());
371 prune_tasks[prune_tasks_size++] = events[ei].
task;
378 contribution, prune_tasks, prune_tasks_size));
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
union Gecode::@603::NNF::@65 u
Union depending on nodetype t.
int p
Number of positive literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Base-class for both propagators and branchers.
virtual size_t dispose(Space &home)
Delete actor and return its size.
int size(void) const
Return size of array (number of elements)
FloatNum size(void) const
Return size of float value (distance between maximum and minimum)
Home class for posting propagators
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
An event collects the information for one evnet for the sweep-line.
int date
The date of this event.
Event(ev_t _e, int _task, int _date, int _inc=0, bool _first_prof=false)
Simple constructor.
int task
The task this event refers to.
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.
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, 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.
Base-class for propagators.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
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)
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)
ExecStatus prune(Home home, ViewArray< VX > &x, VX y)
Prune that y is the union of x.
ExecStatus subsumed(Space &home, Propagator &p, int c, TaskArray< Task > &t)
Check for subsumption (all tasks must be assigned)
ev_t
Types of events for the sweep-line.
bool assigned(View x, int v)
Whether x is assigned to value v.
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
Post propagator for SetVar SetOpType SetVar SetRelType r
FloatVal max(const FloatNum &x, const FloatVal &y)
FloatVal min(const FloatNum &x, const FloatVal &y)
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 .
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i({1, 2, 3, 4})
Multi _e(Gecode::IntArgs({4, 2, 3, 1}))
Multi _c(Gecode::IntArgs({1, 2, 3}))