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);
79 rel(*
this, x[
i] + x[
i+1] == x[
i+2]);
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) {}
149 Below(
int l) : limit(l) {}
160 Above(
int l) : limit(l) {}
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 c2t2("2t2", 2, true, 2)
Describe that event is above a certain limit.
double am(double t[], int n)
Compute arithmetic mean of n elements in t.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
Ass(bool share, Ass &s)
Constructor for cloning s.
bool start
Whether event has just started Initialize event.
Test for cumulatives constraint
bool pos(const View &x)
Test whether x is postive.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Cumulatives c3f_2("3f-2", 3, false,-2)
Cumulatives c3t_2("3t-2", 3, true,-2)
Cumulatives c1f1("1f1", 1, false, 1)
bool operator()(int val)
Test whether val is above limit
CumulativeAssignment(int n, const Gecode::IntSet &d)
Initialize assignments for n0 variables and values d0.
Cumulatives c3t2("3t2", 3, true, 2)
virtual void operator++(void)
Move to next assignment.
Gecode::IntVarArray x
Store task information.
Cumulatives(const std::string &s, int nt, bool am, int l)
Create and register test.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
void sort(TaskViewArray< TaskView > &t)
Sort task view array t according to sto and inc (increasing or decreasing)
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Class for generating reasonable assignments.
int ntasks
Number of tasks.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Cumulatives c2f3("2f3", 2, false, 3)
Script for generating assignments.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Cumulatives c1f2("1f2", 1, false, 2)
Cumulatives c3t_3("3t-3", 3, true,-3)
Cumulatives c3t3("3t3", 3, true, 3)
int limit
limit Initialize
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, IntConLevel cl)
Post propagators for the cumulatives constraint.
Cumulatives c1t1("1t1", 1, true, 1)
struct Gecode::Space::@52::@53 p
Data only available during propagation.
virtual Assignment * assignment(void) const
Create first assignment.
Cumulatives c3f2("3f2", 3, false, 2)
Cumulatives c2f1("2f1", 2, false, 1)
Cumulatives c3f_1("3f-1", 3, false,-1)
Cumulatives c2f2("2f2", 2, false, 2)
Passing integer variables.
bool operator()(int val)
Test whether val is below limit
Passing integer arguments.
virtual int operator[](int i) const
Return value for variable i.
Cumulatives c3t1("3t1", 3, true, 1)
Cumulatives c3f3("3f3", 3, false, 3)
Cumulatives c2t3("2t3", 2, true, 3)
Base class for assignments
T * next(void)
Return next solution (NULL, if none exists or search has been stopped)
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Cumulatives c2t1("2t1", 2, true, 1)
Cumulatives c3f_3("3f-3", 3, false,-3)
virtual ~CumulativeAssignment(void)
Destructor.
Cumulatives c1t3("1t3", 1, true, 3)
int limit
limit Initialize
Gecode toplevel namespace
virtual bool operator()(void) const
Test whether all assignments have been iterated
Cumulatives c1t2("1t2", 1, true, 2)
Ass(int n, const Gecode::IntSet &d)
Initialize model for assignments.
virtual Gecode::Space * copy(bool share)
Create copy during cloning.
bool operator<(const Event &e) const
Test whether this event is before event e
BrancherHandle 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 void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Cumulatives c3t_1("3t-1", 3, true,-1)
Cumulatives c3f1("3f1", 3, false, 1)
bool valid(std::vector< Event > e, C comp)
Check whether event e is valid.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
Depth-first search engine.
Describe that event is below a certain limit.
bool at_most
Whether to use atmost reasoning.
Cumulatives c1f3("1f3", 1, false, 3)