Go to the documentation of this file.
44 namespace Test {
namespace Int {
71 for (
int i = 0;
i <
n;
i += 4) {
72 rel(*
this,
x[
i+0] >= 0);
73 rel(*
this,
x[
i+1] >= 0);
74 rel(*
this,
x[
i+2] >= 0);
85 return new Ass(*
this);
103 nxt = cur = e->
next();
115 if (cur != NULL) nxt = e->
next();
119 assert((
i>=0) && (
i<
n) && (cur != NULL));
120 return cur->
x[
i].val();
124 delete cur;
delete nxt;
delete e;
133 Event(
int pos,
int height,
bool s) :
p(
pos), h(height), start(s) {}
166 bool valid(std::vector<Event> e, C comp) {
172 while (
i < e.
size()) {
174 while (
i < e.
size() && e[
i].p ==
p) {
176 n += (e[
i].start ? +1 : -1);
194 :
Test(
"Cumulatives::"+s,nt*4,-1,2), ntasks(nt), at_most(
am), limit(
l) {
199 assert(arity == 4*ntasks);
204 std::vector<Event> e;
205 for (
int i = 0;
i < ntasks; ++
i) {
208 if (
x[
p+0] < 0 ||
x[
p+1] < 1 ||
x[
p+2] < 1)
return false;
210 if (
x[
p+0] +
x[
p+1] !=
x[
p+2]) {
214 for (
int i = 0;
i < ntasks; ++
i) {
217 e.push_back(
Event(
x[
p+0], +
x[
p+3],
true));
218 e.push_back(
Event(
x[
p+2], -
x[
p+3],
false));
230 IntVarArgs s(ntasks),
d(ntasks), e(ntasks), h(ntasks);
231 for (
int i = 0;
i < ntasks; ++
i) {
243 Cumulatives
c1t1(
"1t1", 1,
true, 1);
244 Cumulatives
c1f1(
"1f1", 1,
false, 1);
245 Cumulatives
c1t2(
"1t2", 1,
true, 2);
246 Cumulatives
c1f2(
"1f2", 1,
false, 2);
247 Cumulatives
c1t3(
"1t3", 1,
true, 3);
248 Cumulatives
c1f3(
"1f3", 1,
false, 3);
249 Cumulatives
c2t1(
"2t1", 2,
true, 1);
250 Cumulatives
c2f1(
"2f1", 2,
false, 1);
251 Cumulatives
c2t2(
"2t2", 2,
true, 2);
252 Cumulatives
c2f2(
"2f2", 2,
false, 2);
253 Cumulatives
c2t3(
"2t3", 2,
true, 3);
254 Cumulatives
c2f3(
"2f3", 2,
false, 3);
255 Cumulatives
c3t1(
"3t1", 3,
true, 1);
256 Cumulatives
c3f1(
"3f1", 3,
false, 1);
257 Cumulatives
c3t2(
"3t2", 3,
true, 2);
258 Cumulatives
c3f2(
"3f2", 3,
false, 2);
259 Cumulatives
c3t3(
"3t3", 3,
true, 3);
260 Cumulatives
c3f3(
"3f3", 3,
false, 3);
261 Cumulatives
c3t_1(
"3t-1", 3,
true, -1);
262 Cumulatives
c3f_1(
"3f-1", 3,
false, -1);
263 Cumulatives
c3t_2(
"3t-2", 3,
true, -2);
264 Cumulatives
c3f_2(
"3f-2", 3,
false, -2);
265 Cumulatives
c3t_3(
"3t-3", 3,
true, -3);
266 Cumulatives
c3f_3(
"3f-3", 3,
false, -3);
Cumulatives c2f1("2f1", 2, false, 1)
virtual T * next(void)
Return next solution (NULL, if none exists or search has been stopped)
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
bool at_most
Whether to use atmost reasoning.
Cumulatives c3f_3("3f-3", 3, false, -3)
Cumulatives c3f_1("3f-1", 3, false, -1)
Cumulatives c2f3("2f3", 2, false, 3)
Passing integer variables.
Cumulatives(const std::string &s, int nt, bool am, int l)
Create and register test.
bool start
Whether event has just started Initialize event.
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
double am(double t[], unsigned int n)
Compute arithmetic mean of n elements in t.
Cumulatives c3f3("3f3", 3, false, 3)
virtual Assignment * assignment(void) const
Create first assignment.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Depth-first search engine.
Describe that event is below a certain limit.
Cumulatives c3t_3("3t-3", 3, true, -3)
Cumulatives c1t1("1t1", 1, true, 1)
Cumulatives c1f1("1f1", 1, false, 1)
Cumulatives c3t1("3t1", 3, true, 1)
int limit
limit Initialize
Gecode toplevel namespace
Class for generating reasonable assignments.
Cumulatives c1f2("1f2", 1, false, 2)
bool operator()(int val)
Test whether val is above limit
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
Test for cumulatives constraint
struct Gecode::Space::@61::@62 p
Data only available during propagation or branching.
Cumulatives c3t3("3t3", 3, true, 3)
Cumulatives c3t_1("3t-1", 3, true, -1)
CumulativeAssignment(int n, const Gecode::IntSet &d)
Initialize assignments for n0 variables and values d0.
Cumulatives c1t3("1t3", 1, true, 3)
bool valid(std::vector< Event > e, C comp)
Check whether event e is valid.
Cumulatives c2f2("2f2", 2, false, 2)
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
virtual int operator[](int i) const
Return value for variable i.
Ass(Ass &s)
Constructor for cloning s.
Describe that event is above a certain limit.
Script for generating assignments.
void sort(TaskViewArray< TaskView > &t)
Sort task view array t according to sto and inc (increasing or decreasing)
virtual void operator++(void)
Move to next assignment.
Cumulatives c2t3("2t3", 2, true, 3)
Cumulatives c3f2("3f2", 3, false, 2)
Ass(int n, const Gecode::IntSet &d)
Initialize model for assignments.
int ntasks
Number of tasks.
Cumulatives c3t2("3t2", 3, true, 2)
Base class for assignments
int limit
limit Initialize
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
int size(void) const
Return size of array (number of elements)
virtual ~CumulativeAssignment(void)
Destructor.
bool operator()(int val)
Test whether val is below limit
Cumulatives c3f_2("3f-2", 3, false, -2)
bool operator<(const Event &e) const
Test whether this event is before event e
Cumulatives c1f3("1f3", 1, false, 3)
Cumulatives c1t2("1t2", 1, true, 2)
Cumulatives c2t2("2t2", 2, true, 2)
Cumulatives c3f1("3f1", 3, false, 1)
int n
Number of negative literals for node type.
virtual Gecode::Space * copy(void)
Create copy during cloning.
Passing integer arguments.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Gecode::IntArgs i({1, 2, 3, 4})
bool pos(const View &x)
Test whether x is postive.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
void cumulatives(Home home, const IntArgs &m, const IntVarArgs &s, const IntArgs &p, const IntVarArgs &e, const IntArgs &u, const IntArgs &c, bool at_most, IntPropLevel cl)
Post propagators for the cumulatives constraint.
Cumulatives c3t_2("3t-2", 3, true, -2)
Gecode::IntVarArray x
Store task information.
Cumulatives c2t1("2t1", 2, true, 1)
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
virtual bool operator()(void) const
Test whether all assignments have been iterated