44namespace 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);
75 rel(*
this,
x[i] +
x[i+1] ==
x[i+2]);
76 branch(*
this,
x, INT_VAR_NONE(), INT_VAL_MIN());
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) {
239 cumulatives(home, m, s, d, e, h,
l,
at_most);
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Node * x
Pointer to corresponding Boolean expression node.
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)
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
Base class for assignments
Gecode::IntSet d
Domain for each variable.
int n
Number of variables.
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.
@ IRT_GQ
Greater or equal ( )
Gecode toplevel namespace
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)