42 namespace Test {
namespace Int {
45 namespace Cumulative {
65 for (
int i=p.
size();
i--; )
66 e += static_cast<double>(p[
i])*u[
i];
77 :
Test(
"Cumulative::Man::Fix::"+
str(o0)+
"::"+
79 (c0 >= 0) ? p0.
size():p0.
size()+1,0,
st(c0,p0,u0)),
80 c(c0),
p(p0),
u(u0),
o(o0) {
91 int cmax = (
c >= 0) ?
c : x[x.
size()-1];
94 if (
c < 0 && x[n] > -
c)
99 for (
int i=0;
i<n;
i++)
102 int* used =
new int[t];
103 for (
int i=0; i<t; i++)
105 for (
int i=0; i<n; i++)
106 for (
int t=0; t<
p[
i]; t++)
107 used[x[i]+t] +=
u[i];
109 for (
int i=0; i<t; i++)
110 if (used[i] > cmax) {
115 for (
int i=0; i<t; i++)
117 for (
int i=0; i<n; i++) {
118 for (
int t=1; t<p[
i]; t++) {
119 used[x[
i]+t] +=
u[
i];
123 for (
int i=0; i<n; i++)
124 if (used[x[i]]+
u[i] > cmax) {
133 int n = (
c >= 0) ? x.
size() : x.
size()-1;
169 for (
int i=p.
size();
i--; )
170 e += static_cast<double>(p[
i])*u[
i];
179 :
Test(
"Cumulative::Opt::Fix::"+
str(o0)+
"::"+
181 (c0 >= 0) ? 2*p0.
size() : 2*p0.
size()+1,0,
st(c0,p0,u0)),
193 int nn = (
c >= 0) ? x.
size() : x.
size()-1;
194 int cmax = (
c >= 0) ?
c : x[nn];
196 if (
c < 0 && x[nn] > -
c)
202 for (
int i=0;
i<n;
i++)
205 int* used =
new int[t];
206 for (
int i=0; i<t; i++)
208 for (
int i=0; i<n; i++)
210 for (
int t=0; t<
p[
i]; t++)
211 used[x[i]+t] +=
u[i];
213 for (
int i=0; i<t; i++) {
214 if (used[i] > cmax) {
220 for (
int i=0; i<t; i++)
222 for (
int i=0; i<n; i++)
224 for (
int t=1; t<p[
i]; t++)
225 used[x[i]+t] +=
u[i];
228 for (
int i=0; i<n; i++)
230 if (used[x[i]]+
u[i] > cmax) {
244 for (
int i=0;
i<n;
i++) {
272 for (
int i=u.
size();
i--; )
273 e += static_cast<double>(maxP)*u[
i];
283 :
Test(
"Cumulative::Man::Flex::"+
str(o0)+
"::"+
285 (c0 >= 0) ? 2*u0.
size() : 2*u0.
size()+1,
286 0,std::
max(maxP,
st(c0,maxP,u0))),
300 int nn = (
c >= 0) ? x.
size() : x.
size()-1;
302 int cmax = (
c >= 0) ?
c : x[n];
303 int pstart = (
c >= 0) ? n : n+1;
305 if (c < 0 && cmax > -
c)
310 for (
int i=0;
i<n;
i++) {
314 int* used =
new int[t];
315 for (
int i=0;
i<t;
i++)
317 for (
int i=0;
i<n;
i++)
318 for (
int t=0; t<x[pstart+
i]; t++)
319 used[x[
i]+t] +=
u[
i];
321 for (
int i=0;
i<t;
i++)
322 if (used[
i] > cmax) {
327 for (
int i=0;
i<t;
i++)
329 for (
int i=0;
i<n;
i++) {
330 for (
int t=1; t<x[pstart+
i]; t++)
331 used[x[
i]+t] +=
u[
i];
334 for (
int i=0;
i<n;
i++)
335 if (used[x[
i]]+
u[
i] > cmax) {
344 int nn = (
c >= 0) ? x.
size() : x.
size()-1;
346 int pstart = (
c >= 0) ? n : n+1;
352 for (
int i=s.
size();
i--;) {
354 rel(home, s[i]+px[i] == e[i]);
361 rel(home, x[n] <= -
c);
385 for (
int i=u.
size();
i--; )
386 e += static_cast<double>(maxP)*u[
i];
394 :
Test(
"Cumulative::Opt::Flex::"+
str(o0)+
"::"+
396 (c0 >= 0) ? 3*u0.
size() : 3*u0.
size()+1,
397 0,std::
max(maxP,
st(c0,maxP,u0))),
399 l(std::
max(maxP,
st(c0,maxP,u0))/2),
o(o0) {
412 int nn = (
c >= 0) ? x.
size() : x.
size()-1;
414 int cmax = (
c >= 0) ?
c : x[2*n];
415 int pstart = (
c >= 0) ? 2*n : 2*n+1;
417 if (c < 0 && cmax > -
c)
422 for (
int i=0;
i<n;
i++)
425 int* used =
new int[t];
426 for (
int i=0;
i<t;
i++)
428 for (
int i=0;
i<n;
i++)
430 for (
int t=0; t<x[pstart+
i]; t++)
431 used[x[
i]+t] +=
u[
i];
433 for (
int i=0;
i<t;
i++)
434 if (used[
i] > cmax) {
439 for (
int i=0;
i<t;
i++)
441 for (
int i=0;
i<n;
i++)
443 for (
int t=1; t<x[pstart+
i]; t++)
444 used[x[
i]+t] +=
u[
i];
446 for (
int i=0;
i<n;
i++)
447 if (x[n+
i] >
l && used[x[
i]]+
u[
i] > cmax) {
456 int nn = (
c >= 0) ? x.
size() : x.
size()-1;
458 int pstart= (
c >= 0) ? 2*n : 2*n+1;
465 for (
int i=n;
i--;) {
468 rel(home, s[i]+px[i] == e[i]);
473 for (
int i=0;
i<n;
i++)
489 using namespace Gecode;
499 for (
int c=-7;
c<8;
c++) {
501 for (
int coff=0; coff<2; coff++) {