46 namespace Gecode {
namespace Int {
namespace Cumulative {
49 template<
class TaskView,
bool inc>
53 bool operator ()(
const TaskView& t1,
const TaskView& t2)
const {
54 return inc ? (t1.c() < t2.c()) : (t2.c() < t1.c());
70 template<
class TaskView>
73 sort<TaskView,STO_LCT,false>(
t);
80 int* prec = r.alloc<
int>(t.
size());
81 for (
int i=t.
size();
i--; )
86 for (
int j=0; j<t.
size(); j++) {
88 (ol.
lenv() >
static_cast<long long int>(
c)*t[j].lct())) {
103 int* cap = r.alloc<
int>(t.
size());
104 for (
int i=t.
size();
i--;)
109 int* capacities = r.alloc<
int>(t.
size());
110 int* capInv = r.alloc<
int>(t.
size());
111 for (
int i=t.
size();
i--;) {
112 capacities[cap[
i]] = t[
i].c();
117 for (
int i=0, cur_c=INT_MIN;
i<t.
size();
i++) {
118 if (capacities[
i] != cur_c)
119 capacities[n_c++] = cur_c = capacities[
i];
120 cap[capInv[
i]] = n_c-1;
122 r.free<
int>(capInv, t.
size());
126 int* update = r.alloc<
int>(t.
size()*n_c);
127 for (
int i=t.
size()*n_c;
i--;)
131 for (
int i=0;
i<n_c;
i++) {
132 eo.
init(capacities[
i]);
134 for (
int j=t.
size(); j--;) {
136 static_cast<long long int>(c-capacities[
i])*t[j].lct();
137 long long int eml =
plus(eo.
env(j), -lctj);
138 long long int diff_l;
143 static_cast<long long int>(capacities[i]));
147 update[i*t.
size()+j] =
u;
154 int* precMap = r.alloc<
int>(t.
size());
155 for (
int i=t.
size();
i--;)
161 for (
int i=0;
i<t.
size();
i++) {
163 while (curJ < t.
size() && t[curJ].lct() > prec[precMap[
i]])
165 if (curJ >= t.
size())
170 if (t[locJ].lct() != t[precMap[
i]].lct()) {
174 }
while (t[locJ].lct() == prec[precMap[
i]] && locJ++ < t.
size() - 1);