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