38 namespace Test {
namespace Int {
41 namespace Cumulative {
61 for (
int i=p.
size();
i--; )
62 e += static_cast<double>(p[
i])*u[
i];
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];
91 if (c < 0 && x[n] > -c)
96 for (
int i=0;
i<
n;
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];
177 :
Test(
"Cumulative::Opt::Fix::"+
str(o0)+
"::"+
179 (c0 >= 0) ? 2*p0.
size() : 2*p0.
size()+1,0,
st(c0,p0,u0),
181 c(c0), p(p0), u(u0), l(
st(c,p,u)/2), o(o0) {
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++)
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];
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),
288 c(c0), _minP(minP), _maxP(maxP), u(u0), o(o0) {
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;
306 if (c < 0 && cmax > -c)
311 for (
int i=0;
i<
n;
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];
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),
401 c(c0), _minP(minP), _maxP(maxP), u(u0),
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;
420 if (c < 0 && cmax > -c)
425 for (
int i=0;
i<
n;
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++) {
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)
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.
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.
ArrayTraits< VarArgArray< Var > >::ArgsType slice(int start, int inc=1, int n=-1)
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 Options: basic versus advanced propagation.
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.