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)),
182 c(c0), p(p0), u(u0), l(
st(c,p,u)/2), o(o0) {
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) {
239 int nn=(c >= 0) ? x.
size() : x.
size()-1;
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,
287 c(c0), _minP(minP), _maxP(maxP), u(u0), o(o0) {
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]);
355 rel(home, _minP <= px[i]);
356 rel(home, _maxP >= px[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,
398 c(c0), _minP(minP), _maxP(maxP), u(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--;) {
466 s[
i] =
expr(home, o+x[
i]);
468 rel(home, s[i]+px[i] == e[i]);
469 rel(home, _minP <= px[i]);
470 rel(home, _maxP >= px[i]);
473 for (
int i=0;
i<
n;
i++)
505 for (
int c=-7;
c<8;
c++) {
507 for (
int coff=0; coff<2; coff++) {
static int st(int c, const Gecode::IntArgs &p, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
void cumulative(Home home, Cap c, const TaskTypeArgs &t, const IntVarArgs &s, const IntArgs &p, const IntArgs &u, IntConLevel icl)
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
int size(void) const
Return size of array (number of elements)
int size(void) const
Return size of array (number of elements)
const FloatNum max
Largest allowed float value.
int size(void) const
Return number of variables.
static int st(int c, int maxP, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Gecode::IntArgs u
The resource usage.
Gecode::IntArgs u
The resource usage.
int _minP
Minimum processing time.
int _minP
Minimum processing time.
Gecode::IntSet dom
Domain of variables.
ManFixPCumulative(int c0, const Gecode::IntArgs &p0, const Gecode::IntArgs &u0, int o0)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
ConTestLevel contest
Whether to test for certain consistency.
const int max
Largest allowed integer value.
virtual Assignment * assignment(void) const
Create and register initial assignment.
Generate random selection of assignments.
const int min
Smallest allowed integer value.
static int st(int c, const Gecode::IntArgs &p, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
int _maxP
Maximum processing time.
int l
Limit for optional tasks.
static std::string str(Gecode::ExtensionalPropKind epk)
Map extensional propagation kind to string.
Gecode::IntArgs p2(4, 4, 3, 3, 5)
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
virtual Assignment * assignment(void) const
Create and register initial assignment.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
Generate random selection of assignments.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
unsigned int size(I &i)
Size of all ranges of range iterator i.
int _maxP
Maximum processing time.
Help class to create and register tests.
ArrayTraits< VarArgArray< Var > >::ArgsType slice(int start, int inc=1, int n=-1)
Test for cumulative constraint with optional tasks.
Passing integer variables.
OptFlexCumulative(int c0, int minP, int maxP, const Gecode::IntArgs &u0, int o0)
Create and register test.
Passing integer arguments.
Passing Boolean variables.
bool testfix
Whether to perform fixpoint test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Gecode::IntArgs u
The resource usage.
int c
Capacity of resource.
Test for cumulative constraint with mandatory tasks.
BoolVar expr(Home home, const BoolExpr &e, IntConLevel icl)
Post Boolean expression and return its value.
int c
Capacity of resource.
Node * x
Pointer to corresponding Boolean expression node.
bool testsearch
Whether to perform search test.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
Base class for assignments
static int st(int c, int maxP, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Gecode::IntArgs p
The processing times.
virtual Assignment * assignment(void) const
Create and register initial assignment.
int c
Capacity of resource.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
OptFixPCumulative(int c0, const Gecode::IntArgs &p0, const Gecode::IntArgs &u0, int o0)
Create and register test.
Test for cumulative constraint with optional flexible tasks.
Gecode toplevel namespace
ManFlexCumulative(int c0, int minP, int maxP, const Gecode::IntArgs &u0, int o0)
Create and register test.
Gecode::IntArgs u
The resource usage.
int c
Capacity of resource.
Create(void)
Perform creation and registration.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
int arity
Number of variables.
Gecode::IntArgs p3(6, 4, 2, 9, 3, 7, 5)
virtual Assignment * assignment(void) const
Create and register initial assignment.
Test for cumulative constraint with flexible mandatory tasks.
Gecode::IntArgs p1(4, 2, 2, 2, 2)
Domain propagation or consistency.
int l
Limit for optional tasks.
Gecode::IntArgs p
The processing times.