39 namespace Test {
namespace Int {
59 :
Test(
"NoOverlap::Int::2::"+
str(m)+
"::"+
str(w0)+
"::"+
str(h0),
65 int n = xy.
size() / 2;
66 for (
int i=0;
i<
n;
i++) {
67 int xi=xy[2*
i+0], yi=xy[2*
i+1];
68 for (
int j=
i+1; j<
n; j++) {
69 int xj=xy[2*j+0], yj=xy[2*j+1];
70 if (!((xi + w[
i] <= xj) || (xj + w[j] <= xi) ||
71 (yi + h[
i] <= yj) || (yj + h[j] <= yi)))
80 int n = xy.
size() / 2;
82 for (
int i=0;
i<
n;
i++) {
83 x[
i]=xy[2*
i+0]; y[
i]=xy[2*
i+1];
98 :
Test(
"NoOverlap::Int::Opt::2::"+
str(m)+
"::"+
str(w0)+
"::"+
str(h0),
99 3*w0.
size(), 0, m-1), w(w0), h(h0) {}
102 int n = xyo.
size() / 3;
103 for (
int i=0;
i<
n;
i++) {
104 int xi=xyo[3*
i+0], yi=xyo[3*
i+1];
106 for (
int j=
i+1; j<
n; j++) {
107 int xj=xyo[3*j+0], yj=xyo[3*j+1];
109 if ((oi > 0) && (oj > 0) &&
110 !((xi + w[
i] <= xj) || (xj + w[j] <= xi) ||
111 (yi + h[
i] <= yj) || (yj + h[j] <= yi)))
120 int n = xyo.
size() / 3;
123 for (
int i=0;
i<
n;
i++) {
124 x[
i]=xyo[3*
i+0]; y[
i]=xyo[3*
i+1];
125 o[
i]=
expr(home, xyo[3*
i+2] > 0);
136 :
Test(
"NoOverlap::Var::2::"+
str(m)+
"::"+
str(n), 4*n, 0, m) {}
139 int n = xwyh.
size() / 4;
140 for (
int i=0;
i<
n;
i++) {
141 int xi=xwyh[4*
i+0], yi=xwyh[4*
i+2];
142 int wi=xwyh[4*
i+1], hi=xwyh[4*
i+3];
143 for (
int j=
i+1; j<
n; j++) {
144 int xj=xwyh[4*j+0], yj=xwyh[4*j+2];
145 int wj=xwyh[4*j+1], hj=xwyh[4*j+3];
146 if (!((xi + wi <= xj) || (xj + wj <= xi) ||
147 (yi + hi <= yj) || (yj + hj <= yi)))
156 int n = xwyh.
size() / 4;
158 for (
int i=0;
i<
n;
i++) {
159 x0[
i]=xwyh[4*
i+0];
w[
i]=xwyh[4*
i+1];
161 y0[
i]=xwyh[4*i+2];
h[
i]=xwyh[4*i+3];
162 y1[
i]=
expr(home, y0[i] +
h[i]);
173 :
Test(
"NoOverlap::Var::Opt::2::"+
str(m)+
"::"+
str(n), 5*n, 0, m) {
178 int n = xwyho.
size() / 5;
179 for (
int i=0;
i<
n;
i++) {
180 int xi=xwyho[5*
i+0], yi=xwyho[5*
i+2];
181 int wi=xwyho[5*
i+1], hi=xwyho[5*
i+3];
183 for (
int j=
i+1; j<
n; j++) {
184 int xj=xwyho[5*j+0], yj=xwyho[5*j+2];
185 int wj=xwyho[5*j+1], hj=xwyho[5*j+3];
187 if ((oi > 0) && (oj > 0) &&
188 !((xi + wi <= xj) || (xj + wj <= xi) ||
189 (yi + hi <= yj) || (yj + hj <= yi)))
198 int n = xwyho.
size() / 5;
201 for (
int i=0;
i<
n;
i++) {
202 x0[
i]=xwyho[5*
i+0];
w[
i]=xwyho[5*
i+1];
204 y0[
i]=xwyho[5*i+2];
h[
i]=xwyho[5*i+3];
205 y1[
i]=
expr(home, y0[i] +
h[i]);
206 o[
i]=
expr(home, xwyho[5*i+4] > 0);
217 :
Test(
"NoOverlap::Var::Opt::Shared::2::"+
218 str(m)+
"::"+
str(n), 2*n+2, 0, m) {
223 int n = (xwyho.
size() - 2) / 2;
224 for (
int i=0;
i<
n;
i++) {
225 int xi=xwyho[2*
i+0], yi=xwyho[2*
i+0];
226 int wi=xwyho[2*
i+1], hi=xwyho[2*
i+1];
227 int oi=xwyho[2*n + (
i % 2)];
228 for (
int j=
i+1; j<
n; j++) {
229 int xj=xwyho[2*j+0], yj=xwyho[2*j+0];
230 int wj=xwyho[2*j+1], hj=xwyho[2*j+1];
231 int oj=xwyho[2*n + (j % 2)];
232 if ((oi > 0) && (oj > 0) &&
233 !((xi + wi <= xj) || (xj + wj <= xi) ||
234 (yi + hi <= yj) || (yj + hj <= yi)))
243 int n = (xwyho.
size() - 2) / 2;
246 for (
int i=0;
i<
n;
i++) {
247 x0[
i]=xwyho[2*
i+0];
w[
i]=xwyho[2*
i+1];
249 y0[
i]=xwyho[2*i+0];
h[
i]=xwyho[2*i+1];
250 y1[
i]=
expr(home, y0[i] +
h[i]);
251 o[
i]=
expr(home, xwyho[2*n + (i % 2)] > 0);
270 for (
int m=2; m<3; m++) {
271 (void)
new Int2(m, s1, s1);
272 (void)
new Int2(m, s2, s2);
273 (void)
new Int2(m, s3, s3);
274 (void)
new Int2(m, s2, s3);
275 (void)
new Int2(m, s4, s4);
276 (void)
new Int2(m, s4, s2);
281 (void)
new Var2(2, 2);
282 (void)
new Var2(3, 2);
283 (void)
new Var2(1, 3);
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
virtual bool solution(const Assignment &xwyh) const
Test whether xwyh is solution
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xy)
Post constraint on xy.
int size(void) const
Return size of array (number of elements)
virtual bool solution(const Assignment &xyo) const
Test whether xyo is solution
int size(void) const
Return number of variables.
void nooverlap(Home home, const IntVarArgs &x0, const IntVarArgs &w, const IntVarArgs &x1, const IntVarArgs &y0, const IntVarArgs &h, const IntVarArgs &y1, const BoolVarArgs &m, IntPropLevel)
Post propagator for rectangle packing.
Help class to create and register tests.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xwyh)
Post constraint on xwyh.
unsigned int size(I &i)
Size of all ranges of range iterator i.
virtual bool solution(const Assignment &xwyho) const
Test whether xwyho is solution
Int2(int m, const Gecode::IntArgs &w0, const Gecode::IntArgs &h0)
Create and register test with maximal coordinate value m.
Passing integer variables.
Passing integer arguments.
Passing Boolean variables.
IntOpt2(int m, const Gecode::IntArgs &w0, const Gecode::IntArgs &h0)
Create and register test with maximal value m and n rectangles.
Test for no-overlap with optional rectangles and shared variables
Test for no-overlap with optional rectangles
BoolVar expr(Home home, const BoolExpr &e, IntPropLevel ipl)
Post Boolean expression and return its value.
bool testfix
Whether to perform fixpoint test.
virtual bool solution(const Assignment &xwyho) const
Test whether xwyho is solution
Post propagator for SetVar SetOpType SetVar y
Test for no-overlap with integer dimensions (rectangles)
Node * x
Pointer to corresponding Boolean expression node.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xwyho)
Post constraint on xwyho.
virtual bool solution(const Assignment &xy) const
Test whether xy is solution
Base class for assignments
Gecode toplevel namespace
Test for no-overlap with optional rectangles
VarOptShared2(int m, int n)
Create and register test with maximal value m and n rectangles.
Create(void)
Perform creation and registration.
Var2(int m, int n)
Create and register test with maximal value m and n rectangles.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xwyho)
Post constraint on xwyho.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xyo)
Post constraint on xwyho.
VarOpt2(int m, int n)
Create and register test with maximal value m and n rectangles.
Test for no-overlap with variable dimensions (rectangles)