Go to the documentation of this file.
48 namespace Test {
namespace Int {
75 for (
int i = 0;
i <
n;
i += 4) {
76 rel(*
this,
x[
i+0] >= 0);
77 rel(*
this,
x[
i+1] >= 0);
78 rel(*
this,
x[
i+2] >= 0);
89 return new Ass(share,*
this);
107 nxt = cur = e->
next();
119 if (cur != NULL) nxt = e->
next();
123 assert((
i>=0) && (
i<
n) && (cur != NULL));
124 return cur->
x[
i].val();
128 delete cur;
delete nxt;
delete e;
137 Event(
int pos,
int height,
bool s) :
p(
pos), h(height), start(s) {}
170 bool valid(std::vector<Event> e, C comp) {
176 while (
i < e.size()) {
178 while (
i < e.size() && e[
i].p ==
p) {
180 n += (e[
i].start ? +1 : -1);
198 :
Test(
"Cumulatives::"+s,nt*4,-1,2), ntasks(nt), at_most(
am), limit(
l) {
203 assert(arity == 4*ntasks);
208 std::vector<Event> e;
209 for (
int i = 0;
i < ntasks; ++
i) {
212 if (
x[
p+0] < 0 ||
x[
p+1] < 1 ||
x[
p+2] < 1)
return false;
214 if (
x[
p+0] +
x[
p+1] !=
x[
p+2]) {
218 for (
int i = 0;
i < ntasks; ++
i) {
221 e.push_back(
Event(
x[
p+0], +
x[
p+3],
true));
222 e.push_back(
Event(
x[
p+2], -
x[
p+3],
false));
234 IntVarArgs s(ntasks),
d(ntasks), e(ntasks), h(ntasks);
235 for (
int i = 0;
i < ntasks; ++
i) {
247 Cumulatives
c1t1(
"1t1", 1,
true, 1);
248 Cumulatives
c1f1(
"1f1", 1,
false, 1);
249 Cumulatives
c1t2(
"1t2", 1,
true, 2);
250 Cumulatives
c1f2(
"1f2", 1,
false, 2);
251 Cumulatives
c1t3(
"1t3", 1,
true, 3);
252 Cumulatives
c1f3(
"1f3", 1,
false, 3);
253 Cumulatives
c2t1(
"2t1", 2,
true, 1);
254 Cumulatives
c2f1(
"2f1", 2,
false, 1);
255 Cumulatives
c2t2(
"2t2", 2,
true, 2);
256 Cumulatives
c2f2(
"2f2", 2,
false, 2);
257 Cumulatives
c2t3(
"2t3", 2,
true, 3);
258 Cumulatives
c2f3(
"2f3", 2,
false, 3);
259 Cumulatives
c3t1(
"3t1", 3,
true, 1);
260 Cumulatives
c3f1(
"3f1", 3,
false, 1);
261 Cumulatives
c3t2(
"3t2", 3,
true, 2);
262 Cumulatives
c3f2(
"3f2", 3,
false, 2);
263 Cumulatives
c3t3(
"3t3", 3,
true, 3);
264 Cumulatives
c3f3(
"3f3", 3,
false, 3);
265 Cumulatives
c3t_1(
"3t-1", 3,
true, -1);
266 Cumulatives
c3f_1(
"3f-1", 3,
false, -1);
267 Cumulatives
c3t_2(
"3t-2", 3,
true, -2);
268 Cumulatives
c3f_2(
"3f-2", 3,
false, -2);
269 Cumulatives
c3t_3(
"3t-3", 3,
true, -3);
270 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)
@ IRT_GQ
Greater or equal ( )
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.
double am(double t[], unsigned int n)
Compute arithmetic mean of n elements in t.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
Cumulatives c3f3("3f3", 3, false, 3)
struct Gecode::Space::@56::@57 p
Data only available during propagation or branching.
Gecode::IntArgs i(4, 1, 2, 3, 4)
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
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
virtual Gecode::Space * copy(bool share)
Create copy during cloning.
Class for generating reasonable assignments.
Cumulatives c1f2("1f2", 1, false, 2)
bool operator()(int val)
Test whether val is above limit
Test for cumulatives constraint
Cumulatives c3t3("3t3", 3, true, 3)
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
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.
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(bool share, Ass &s)
Constructor for cloning s.
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 .
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.
Passing integer arguments.
virtual bool solution(const Assignment &x) const
Test whether x is solution
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)
virtual bool operator()(void) const
Test whether all assignments have been iterated