45 template<
class TaskView,
bool inc>
49 bool operator ()(
const TaskView& t1,
const TaskView& t2)
const {
50 return inc ? (t1.c() < t2.c()) : (t2.c() < t1.c());
66 template<
class TaskView>
76 int* prec =
r.alloc<
int>(t.
size());
77 for (
int i=0; i<t.
size(); i++)
82 for (
int j=0; j<t.
size(); j++) {
84 (ol.
lenv() >
static_cast<long long int>(c)*t[j].lct())) {
86 prec[i] = std::max(prec[i], t[j].lct());
99 int* cap =
r.alloc<
int>(t.
size());
100 for (
int i=0; i<t.
size(); i++)
105 int* capacities =
r.alloc<
int>(t.
size());
106 int* capInv =
r.alloc<
int>(t.
size());
107 for (
int i=t.
size(); i--;) {
108 capacities[cap[i]] = t[i].c();
113 for (
int i=0, cur_c=INT_MIN; i<t.
size(); i++) {
114 if (capacities[i] != cur_c)
115 capacities[n_c++] = cur_c = capacities[i];
116 cap[capInv[i]] = n_c-1;
118 r.free<
int>(capInv, t.
size());
123 for (
int i=0; i<t.
size()*n_c; i++)
127 for (
int i=0; i<n_c; i++) {
128 eo.
init(capacities[i]);
130 for (
int j=t.
size(); j--;) {
132 static_cast<long long int>(c-capacities[i])*t[j].lct();
133 long long int eml =
plus(eo.
env(j), -lctj);
134 long long int diff_l;
139 static_cast<long long int>(capacities[i]));
142 u = std::max(u,diff);
150 int* precMap =
r.alloc<
int>(t.
size());
151 for (
int i=0; i<t.
size(); i++)
157 for (
int i=0; i<t.
size(); i++) {
159 while (curJ < t.
size() && t[curJ].lct() > prec[precMap[i]])
161 if (curJ >= t.
size())
166 if (t[locJ].lct() != t[precMap[i]].lct()) {
170 }
while (t[locJ].lct() == prec[precMap[i]] && locJ++ < t.
size() - 1);
Omega trees for computing ect of task sets.
long long int env(int i)
Compute update for task with index i.
void init(int ci)
Initialize tasks for current capacity ci.
Omega-lambda trees for computing ect of task sets.
int responsible(void) const
Return responsible task.
long long int lenv(void) const
Return energy envelope of all tasks excluding lambda tasks.
void shift(int i)
Shift task with index i from omega to lambda.
void lremove(int i)
Remove task with index i from lambda.
bool lempty(void) const
Whether has responsible task.
PrecOrder(int *prec0)
Constructor.
bool operator()(int i, int j) const
Sort order.
bool operator()(const TaskView &t1, const TaskView &t2) const
Sort order.
Sorting maps rather than tasks.
int size(void) const
Return size of array (number of elements)
void update(const NoOffset &)
Integer-precision integer scale view.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Scheduling for cumulative resources
ExecStatus edgefinding(Space &home, int c, TaskArray< Task > &t)
Propagate by edge-finding.
const int infinity
Infinity for integers.
const long long int llinfinity
Infinity for long long integers.
void sort(TaskViewArray< TaskView > &t)
Sort task view array t according to sto and inc (increasing or decreasing)
int plus(int x, int y)
Safe addition in case x is -Int::Limits::infinity.
IntType ceil_div_xx(IntType x, IntType y)
Compute .
void quicksort(Type *l, Type *r, Less &less)
Standard quick sort.
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
@ ES_OK
Execution is okay.