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);
75 rel(*
this,
x[i] +
x[i+1] ==
x[i+2]);
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) {
167 std::sort(e.begin(), e.end());
172 while (i < e.
size()) {
174 while (i < e.
size() && e[i].p == p) {
176 n += (e[i].start ? +1 : -1);
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));
231 for (
int i = 0; i <
ntasks; ++i) {
int size(void) const
Return size of array (number of elements)
Depth-first search engine.
Passing integer arguments.
Passing integer variables.
Base class for assignments
Gecode::IntSet d
Domain for each variable.
int n
Number of variables.
Assignment(int n0, const Gecode::IntSet &d0)
Initialize assignments for n0 variables and values d0.
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.
virtual Gecode::Space * copy(void)
Create copy during cloning.
Ass(int n, const Gecode::IntSet &d)
Initialize model for assignments.
Gecode::IntVarArray x
Store task information.
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 void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual Assignment * assignment(void) const
Create first assignment.
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)
bool testsearch
Whether to perform search test.
int arity
Number of variables.
Gecode::IntSet dom
Domain of variables.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
@ IRT_GQ
Greater or equal ( )
Space(void)
Default constructor.
Gecode toplevel namespace
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
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 ipl=IPL_DEF)
Post propagators for the cumulatives constraint.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Post propagator for SetVar x
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)
Testing finite domain integers.