42 namespace Test {
namespace Int {
45 namespace Cumulative {
66 e += static_cast<double>(
p[
i])*
u[
i];
78 :
Test(
"Cumulative::Man::Fix::"+
str(o0)+
"::"+
80 (c0 >= 0) ? p0.
size():p0.
size()+1,0,
st(c0,p0,u0),false,ipl0),
81 c(c0),
p(p0),
u(u0),
o(o0) {
92 int cmax = (
c >= 0) ?
c :
x[
x.size()-1];
93 int n = (
c >= 0) ?
x.size() :
x.size()-1;
95 if (
c < 0 &&
x[
n] > -
c)
100 for (
int i=0;
i<
n;
i++)
103 int* used =
new int[
t];
104 for (
int i=0;
i<
t;
i++)
106 for (
int i=0;
i<
n;
i++)
107 for (
int t=0;
t<
p[
i];
t++)
108 used[
x[
i]+
t] +=
u[
i];
110 for (
int i=0;
i<
t;
i++)
111 if (used[
i] > cmax) {
116 for (
int i=0;
i<
t;
i++)
118 for (
int i=0;
i<
n;
i++) {
119 for (
int t=1;
t<
p[
i];
t++) {
120 used[
x[
i]+
t] +=
u[
i];
124 for (
int i=0;
i<
n;
i++)
125 if (used[
x[
i]]+
u[
i] > cmax) {
134 int n = (
c >= 0) ?
x.size() :
x.size()-1;
171 e += static_cast<double>(
p[
i])*
u[
i];
181 :
Test(
"Cumulative::Opt::Fix::"+
str(o0)+
"::"+
183 (c0 >= 0) ? 2*p0.
size() : 2*p0.
size()+1,0,
st(c0,p0,u0),
196 int nn = (
c >= 0) ?
x.size() :
x.size()-1;
197 int cmax = (
c >= 0) ?
c :
x[nn];
199 if (
c < 0 &&
x[nn] > -
c)
205 for (
int i=0;
i<
n;
i++)
208 int* used =
new int[
t];
209 for (
int i=0;
i<
t;
i++)
211 for (
int i=0;
i<
n;
i++)
213 for (
int t=0;
t<
p[
i];
t++)
214 used[
x[
i]+
t] +=
u[
i];
216 for (
int i=0;
i<
t;
i++) {
217 if (used[
i] > cmax) {
223 for (
int i=0;
i<
t;
i++)
225 for (
int i=0;
i<
n;
i++)
227 for (
int t=1;
t<
p[
i];
t++)
228 used[
x[
i]+
t] +=
u[
i];
231 for (
int i=0;
i<
n;
i++)
233 if (used[
x[
i]]+
u[
i] > cmax) {
242 int nn=(
c >= 0) ?
x.size() :
x.size()-1;
247 for (
int i=0;
i<
n;
i++) {
276 e += static_cast<double>(maxP)*
u[
i];
287 :
Test(
"Cumulative::Man::Flex::"+
str(o0)+
"::"+
290 (c0 >= 0) ? 2*u0.
size() : 2*u0.
size()+1,
291 0,
std::
max(maxP,
st(c0,maxP,u0)),false,ipl0),
305 int nn = (
c >= 0) ?
x.size() :
x.size()-1;
307 int cmax = (
c >= 0) ?
c :
x[
n];
308 int pstart = (
c >= 0) ?
n :
n+1;
310 if (c < 0 && cmax > -
c)
315 for (
int i=0;
i<
n;
i++) {
319 int* used =
new int[
t];
320 for (
int i=0;
i<
t;
i++)
322 for (
int i=0;
i<
n;
i++)
323 for (
int t=0;
t<
x[pstart+
i];
t++)
324 used[
x[
i]+
t] +=
u[
i];
326 for (
int i=0;
i<
t;
i++)
327 if (used[
i] > cmax) {
332 for (
int i=0;
i<
t;
i++)
334 for (
int i=0;
i<
n;
i++) {
335 for (
int t=1;
t<
x[pstart+
i];
t++)
336 used[
x[
i]+
t] +=
u[
i];
339 for (
int i=0;
i<
n;
i++)
340 if (used[
x[
i]]+
u[
i] > cmax) {
349 int nn = (
c >= 0) ?
x.size() :
x.size()-1;
351 int pstart = (
c >= 0) ?
n :
n+1;
357 for (
int i=s.
size();
i--;) {
359 rel(home, s[
i]+px[
i] == e[
i]);
391 e += static_cast<double>(maxP)*
u[
i];
400 :
Test(
"Cumulative::Opt::Flex::"+
str(o0)+
"::"+
403 (c0 >= 0) ? 3*u0.
size() : 3*u0.
size()+1,
404 0,
std::
max(maxP,
st(c0,maxP,u0)), false,ipl0),
419 int nn = (
c >= 0) ?
x.size() :
x.size()-1;
421 int cmax = (
c >= 0) ?
c :
x[2*
n];
422 int pstart = (
c >= 0) ? 2*
n : 2*
n+1;
424 if (c < 0 && cmax > -
c)
429 for (
int i=0;
i<
n;
i++)
432 int* used =
new int[
t];
433 for (
int i=0;
i<
t;
i++)
435 for (
int i=0;
i<
n;
i++)
437 for (
int t=0;
t<
x[pstart+
i];
t++)
438 used[
x[
i]+
t] +=
u[
i];
440 for (
int i=0;
i<
t;
i++)
441 if (used[
i] > cmax) {
446 for (
int i=0;
i<
t;
i++)
448 for (
int i=0;
i<
n;
i++)
450 for (
int t=1;
t<
x[pstart+
i];
t++)
451 used[
x[
i]+
t] +=
u[
i];
453 for (
int i=0;
i<
n;
i++)
454 if (
x[
n+
i] >
l && used[
x[
i]]+
u[
i] > cmax) {
463 int nn = (
c >= 0) ?
x.size() :
x.size()-1;
465 int pstart= (
c >= 0) ? 2*
n : 2*
n+1;
472 for (
int i=
n;
i--;) {
475 rel(home, s[
i]+px[
i] == e[
i]);
480 for (
int i=0;
i<
n;
i++)
513 for (
int c=-7;
c<8;
c++) {
515 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.
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
int size(void) const
Return size of array (number of elements)
const FloatNum max
Largest allowed float value.
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.
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.
Iterator for basic and advanced integer propagation levels.
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.
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.
ManFixPCumulative(int c0, const Gecode::IntArgs &p0, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
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.
Test for cumulative constraint with optional tasks.
Gecode::IntPropLevel ipl
Propagation level.
Passing integer variables.
Passing integer arguments.
Passing Boolean variables.
BoolVar expr(Home home, const BoolExpr &e, IntPropLevel ipl)
Post Boolean expression and return its value.
bool testfix
Whether to perform fixpoint test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
IntPropLevel
Propagation levels for integer propagators.
Gecode::IntArgs u
The resource usage.
int c
Capacity of resource.
Test for cumulative constraint with mandatory tasks.
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.
Domain propagation Preferences: prefer speed or memory.
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.
Test for cumulative constraint with optional flexible tasks.
Gecode toplevel namespace
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.
void cumulative(Home home, int c, const TaskTypeArgs &t, const IntVarArgs &s, const IntArgs &p, const IntArgs &u, IntPropLevel ipl)
Post propagators for scheduling tasks on cumulative resources.
virtual Assignment * assignment(void) const
Create and register initial assignment.
Test for cumulative constraint with flexible mandatory tasks.
OptFixPCumulative(int c0, const Gecode::IntArgs &p0, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
OptFlexCumulative(int c0, int minP, int maxP, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
ManFlexCumulative(int c0, int minP, int maxP, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
int l
Limit for optional tasks.
Gecode::IntArgs p
The processing times.