61 for (
int i=
p.size(); i--; )
62 e +=
static_cast<double>(
p[i])*
u[i];
63 return e / std::max(1,std::abs(
c));
74 :
Test(
"Cumulative::Man::Fix::"+
str(o0)+
"::"+
76 (c0 >= 0) ? p0.size():p0.size()+1,0,
st(c0,p0,u0),false,ipl0),
77 c(c0),
p(p0),
u(u0),
o(o0) {
88 int cmax = (
c >= 0) ?
c : x[x.size()-1];
89 int n = (
c >= 0) ? x.size() : x.size()-1;
91 if (
c < 0 && x[n] > -
c)
96 for (
int i=0; i<n; i++)
97 t = std::max(t,x[i]+std::max(1,
p[i]));
99 int* used =
new int[t];
100 for (
int i=0; i<t; i++)
102 for (
int i=0; i<n; i++)
103 for (
int t=0; t<
p[i]; t++)
104 used[x[i]+t] +=
u[i];
106 for (
int i=0; i<t; i++)
107 if (used[i] > cmax) {
112 for (
int i=0; i<t; i++)
114 for (
int i=0; i<n; i++) {
115 for (
int t=1; t<
p[i]; t++) {
116 used[x[i]+t] +=
u[i];
120 for (
int i=0; i<n; i++)
121 if (used[x[i]]+
u[i] > cmax) {
130 int n = (
c >= 0) ? x.size() : x.size()-1;
166 for (
int i=
p.size(); i--; )
167 e +=
static_cast<double>(
p[i])*
u[i];
168 return e / std::max(1,std::abs(
c));
177 :
Test(
"Cumulative::Opt::Fix::"+
str(o0)+
"::"+
179 (c0 >= 0) ? 2*p0.size() : 2*p0.size()+1,0,
st(c0,p0,u0),
192 int nn = (
c >= 0) ? x.size() : x.size()-1;
193 int cmax = (
c >= 0) ?
c : x[nn];
195 if (
c < 0 && x[nn] > -
c)
201 for (
int i=0; i<n; i++)
202 t = std::max(t,x[i]+std::max(1,
p[i]));
204 int* used =
new int[t];
205 for (
int i=0; i<t; i++)
207 for (
int i=0; i<n; i++)
209 for (
int t=0; t<
p[i]; t++)
210 used[x[i]+t] +=
u[i];
212 for (
int i=0; i<t; i++) {
213 if (used[i] > cmax) {
219 for (
int i=0; i<t; i++)
221 for (
int i=0; i<n; i++)
223 for (
int t=1; t<
p[i]; t++)
224 used[x[i]+t] +=
u[i];
227 for (
int i=0; i<n; i++)
229 if (used[x[i]]+
u[i] > cmax) {
238 int nn=(
c >= 0) ? x.size() : x.size()-1;
243 for (
int i=0; i<n; i++) {
271 for (
int i=
u.size(); i--; )
272 e +=
static_cast<double>(maxP)*
u[i];
273 return e / std::max(1,std::abs(
c));
283 :
Test(
"Cumulative::Man::Flex::"+
str(o0)+
"::"+
286 (c0 >= 0) ? 2*u0.size() : 2*u0.size()+1,
287 0,
std::max(maxP,
st(c0,maxP,u0)),false,ipl0),
301 int nn = (
c >= 0) ? x.size() : x.size()-1;
303 int cmax = (
c >= 0) ?
c : x[n];
304 int pstart = (
c >= 0) ? n : n+1;
311 for (
int i=0; i<n; i++) {
312 t = std::max(t,x[i]+std::max(1,x[pstart+i]));
315 int* used =
new int[t];
316 for (
int i=0; i<t; i++)
318 for (
int i=0; i<n; i++)
319 for (
int t=0; t<x[pstart+i]; t++)
320 used[x[i]+t] +=
u[i];
322 for (
int i=0; i<t; i++)
323 if (used[i] > cmax) {
328 for (
int i=0; i<t; i++)
330 for (
int i=0; i<n; i++) {
331 for (
int t=1; t<x[pstart+i]; t++)
332 used[x[i]+t] +=
u[i];
335 for (
int i=0; i<n; i++)
336 if (used[x[i]]+
u[i] > cmax) {
345 int nn = (
c >= 0) ? x.size() : x.size()-1;
347 int pstart = (
c >= 0) ? n : n+1;
353 for (
int i=s.
size(); i--;) {
355 rel(home, s[i]+px[i] == e[i]);
356 rel(home,
_minP <= px[i]);
357 rel(home,
_maxP >= px[i]);
362 rel(home, x[n] <= -
c);
386 for (
int i=
u.size(); i--; )
387 e +=
static_cast<double>(maxP)*
u[i];
388 return e / std::max(1,std::abs(
c));
396 :
Test(
"Cumulative::Opt::Flex::"+
str(o0)+
"::"+
399 (c0 >= 0) ? 3*u0.size() : 3*u0.size()+1,
400 0,
std::max(maxP,
st(c0,maxP,u0)), false,ipl0),
402 l(
std::max(maxP,
st(c0,maxP,u0))/2),
o(o0) {
415 int nn = (
c >= 0) ? x.size() : x.size()-1;
417 int cmax = (
c >= 0) ?
c : x[2*n];
418 int pstart = (
c >= 0) ? 2*n : 2*n+1;
425 for (
int i=0; i<n; i++)
426 t = std::max(t,x[i]+std::max(1,x[pstart+i]));
428 int* used =
new int[t];
429 for (
int i=0; i<t; i++)
431 for (
int i=0; i<n; i++)
433 for (
int t=0; t<x[pstart+i]; t++)
434 used[x[i]+t] +=
u[i];
436 for (
int i=0; i<t; i++)
437 if (used[i] > cmax) {
442 for (
int i=0; i<t; i++)
444 for (
int i=0; i<n; i++)
446 for (
int t=1; t<x[pstart+i]; t++)
447 used[x[i]+t] +=
u[i];
449 for (
int i=0; i<n; i++)
450 if (x[n+i] >
l && used[x[i]]+
u[i] > cmax) {
459 int nn = (
c >= 0) ? x.size() : x.size()-1;
461 int pstart= (
c >= 0) ? 2*n : 2*n+1;
468 for (
int i=n; i--;) {
469 s[i] = expr(home,
o+x[i]);
471 rel(home, s[i]+px[i] == e[i]);
472 rel(home,
_minP <= px[i]);
473 rel(home,
_maxP >= px[i]);
476 for (
int i=0; i<n; i++)
509 for (
int c=-7;
c<8;
c++) {
511 for (
int coff=0; coff<2; coff++) {
int size(void) const
Return size of array (number of elements)
Passing Boolean variables.
Passing integer arguments.
Passing integer variables.
Base class for assignments
Help class to create and register tests.
Create(void)
Perform creation and registration.
Test for cumulative constraint with mandatory tasks.
virtual Assignment * assignment(void) const
Create and register initial assignment.
ManFixPCumulative(int c0, const Gecode::IntArgs &p0, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
Gecode::IntArgs u
The resource usage.
Gecode::IntArgs p
The processing times.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
int c
Capacity of resource.
static int st(int c, const Gecode::IntArgs &p, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
Test for cumulative constraint with flexible mandatory tasks.
virtual Assignment * assignment(void) const
Create and register initial assignment.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Gecode::IntArgs u
The resource usage.
int c
Capacity of resource.
static int st(int c, int maxP, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
int _maxP
Maximum processing time.
ManFlexCumulative(int c0, int minP, int maxP, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
int _minP
Minimum processing time.
Test for cumulative constraint with optional tasks.
int l
Limit for optional tasks.
Gecode::IntArgs p
The processing times.
Gecode::IntArgs u
The resource usage.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
int c
Capacity of resource.
virtual Assignment * assignment(void) const
Create and register initial assignment.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
static int st(int c, const Gecode::IntArgs &p, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
OptFixPCumulative(int c0, const Gecode::IntArgs &p0, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
Test for cumulative constraint with optional flexible tasks.
int _maxP
Maximum processing time.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
Gecode::IntArgs u
The resource usage.
OptFlexCumulative(int c0, int minP, int maxP, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
static int st(int c, int maxP, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
int _minP
Minimum processing time.
int c
Capacity of resource.
int l
Limit for optional tasks.
virtual Assignment * assignment(void) const
Create and register initial assignment.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Iterator for basic and advanced integer propagation levels.
Generate random selection of assignments.
Generate random selection of assignments.
bool testsearch
Whether to perform search test.
bool testfix
Whether to perform fixpoint test.
Gecode::IntPropLevel ipl
Propagation level.
int arity
Number of variables.
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
Gecode::IntSet dom
Domain of variables.
ConTestLevel contest
Whether to test for certain consistency.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
IntPropLevel
Propagation levels for integer propagators.
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
const int min
Smallest allowed integer value.
const int max
Largest allowed integer value.
Gecode toplevel namespace
IntVar expr(Home home, const LinIntExpr &e, const IntPropLevels &ipls=IntPropLevels::def)
Post linear expression and return its value.
void cumulative(Home home, int c, const TaskTypeArgs &t, const IntVarArgs &flex, const IntArgs &fix, const IntArgs &u, IntPropLevel ipl=IPL_DEF)
Post propagators for scheduling tasks on cumulative resources.
Tests for cumulative scheduling constraints.
Testing finite domain integers.
@ CTL_NONE
No consistency-test.