43 namespace Test {
namespace Int {
63 :
Test(
"NoOverlap::Int::2::"+
str(m)+
"::"+
str(w0)+
"::"+
str(h0),
69 int n = xy.
size() / 2;
70 for (
int i=0;
i<
n;
i++) {
71 int xi=xy[2*
i+0], yi=xy[2*
i+1];
72 for (
int j=
i+1; j<
n; j++) {
73 int xj=xy[2*j+0], yj=xy[2*j+1];
74 if (!((xi + w[
i] <= xj) || (xj + w[j] <= xi) ||
75 (yi + h[
i] <= yj) || (yj + h[j] <= yi)))
84 int n = xy.
size() / 2;
86 for (
int i=0;
i<
n;
i++) {
87 x[
i]=xy[2*
i+0]; y[
i]=xy[2*
i+1];
102 :
Test(
"NoOverlap::Int::Opt::2::"+
str(m)+
"::"+
str(w0)+
"::"+
str(h0),
103 3*w0.
size(), 0, m-1), w(w0), h(h0) {}
106 int n = xyo.
size() / 3;
107 for (
int i=0;
i<
n;
i++) {
108 int xi=xyo[3*
i+0], yi=xyo[3*
i+1];
110 for (
int j=
i+1; j<
n; j++) {
111 int xj=xyo[3*j+0], yj=xyo[3*j+1];
113 if ((oi > 0) && (oj > 0) &&
114 !((xi + w[
i] <= xj) || (xj + w[j] <= xi) ||
115 (yi + h[
i] <= yj) || (yj + h[j] <= yi)))
124 int n = xyo.
size() / 3;
127 for (
int i=0;
i<
n;
i++) {
128 x[
i]=xyo[3*
i+0]; y[
i]=xyo[3*
i+1];
129 o[
i]=
expr(home, xyo[3*
i+2] > 0);
140 :
Test(
"NoOverlap::Var::2::"+
str(m)+
"::"+
str(n), 4*n, 0, m) {}
143 int n = xwyh.
size() / 4;
144 for (
int i=0;
i<
n;
i++) {
145 int xi=xwyh[4*
i+0], yi=xwyh[4*
i+2];
146 int wi=xwyh[4*
i+1], hi=xwyh[4*
i+3];
147 for (
int j=
i+1; j<
n; j++) {
148 int xj=xwyh[4*j+0], yj=xwyh[4*j+2];
149 int wj=xwyh[4*j+1], hj=xwyh[4*j+3];
150 if (!((xi + wi <= xj) || (xj + wj <= xi) ||
151 (yi + hi <= yj) || (yj + hj <= yi)))
160 int n = xwyh.
size() / 4;
162 for (
int i=0;
i<
n;
i++) {
163 x0[
i]=xwyh[4*
i+0];
w[
i]=xwyh[4*
i+1];
165 y0[
i]=xwyh[4*i+2];
h[
i]=xwyh[4*i+3];
166 y1[
i]=
expr(home, y0[i] +
h[i]);
177 :
Test(
"NoOverlap::Var::Opt::2::"+
str(m)+
"::"+
str(n), 5*n, 0, m) {
182 int n = xwyho.
size() / 5;
183 for (
int i=0;
i<
n;
i++) {
184 int xi=xwyho[5*
i+0], yi=xwyho[5*
i+2];
185 int wi=xwyho[5*
i+1], hi=xwyho[5*
i+3];
187 for (
int j=
i+1; j<
n; j++) {
188 int xj=xwyho[5*j+0], yj=xwyho[5*j+2];
189 int wj=xwyho[5*j+1], hj=xwyho[5*j+3];
191 if ((oi > 0) && (oj > 0) &&
192 !((xi + wi <= xj) || (xj + wj <= xi) ||
193 (yi + hi <= yj) || (yj + hj <= yi)))
202 int n = xwyho.
size() / 5;
205 for (
int i=0;
i<
n;
i++) {
206 x0[
i]=xwyho[5*
i+0];
w[
i]=xwyho[5*
i+1];
208 y0[
i]=xwyho[5*i+2];
h[
i]=xwyho[5*i+3];
209 y1[
i]=
expr(home, y0[i] +
h[i]);
210 o[
i]=
expr(home, xwyho[5*i+4] > 0);
221 :
Test(
"NoOverlap::Var::Opt::Shared::2::"+
222 str(m)+
"::"+
str(n), 2*n+2, 0, m) {
227 int n = (xwyho.
size() - 2) / 2;
228 for (
int i=0;
i<
n;
i++) {
229 int xi=xwyho[2*
i+0], yi=xwyho[2*
i+0];
230 int wi=xwyho[2*
i+1], hi=xwyho[2*
i+1];
231 int oi=xwyho[2*n + (
i % 2)];
232 for (
int j=
i+1; j<
n; j++) {
233 int xj=xwyho[2*j+0], yj=xwyho[2*j+0];
234 int wj=xwyho[2*j+1], hj=xwyho[2*j+1];
235 int oj=xwyho[2*n + (j % 2)];
236 if ((oi > 0) && (oj > 0) &&
237 !((xi + wi <= xj) || (xj + wj <= xi) ||
238 (yi + hi <= yj) || (yj + hj <= yi)))
247 int n = (xwyho.
size() - 2) / 2;
250 for (
int i=0;
i<
n;
i++) {
251 x0[
i]=xwyho[2*
i+0];
w[
i]=xwyho[2*
i+1];
253 y0[
i]=xwyho[2*i+0];
h[
i]=xwyho[2*i+1];
254 y1[
i]=
expr(home, y0[i] +
h[i]);
255 o[
i]=
expr(home, xwyho[2*n + (i % 2)] > 0);
274 for (
int m=2; m<3; m++) {
275 (void)
new Int2(m, s1, s1);
276 (void)
new Int2(m, s2, s2);
277 (void)
new Int2(m, s3, s3);
278 (void)
new Int2(m, s2, s3);
279 (void)
new Int2(m, s4, s4);
280 (void)
new Int2(m, s4, s2);
285 (void)
new Var2(2, 2);
286 (void)
new Var2(3, 2);
287 (void)
new Var2(1, 3);
virtual bool solution(const Assignment &xyo) const
Test whether xyo is solution
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xy)
Post constraint on xy.
Help class to create and register tests.
virtual bool solution(const Assignment &xwyh) const
Test whether xwyh is solution
static std::string str(Gecode::ExtensionalPropKind epk)
Map extensional propagation kind to string.
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
bool testfix
Whether to perform fixpoint test.
BoolVar expr(Home home, const BoolExpr &e, IntConLevel icl)
Post Boolean expression and return its value.
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.
Base class for assignments
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, IntConLevel)
Post propagator for rectangle packing.
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.
int size(void) const
Return size of array (number of elements)
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xwyho)
Post constraint on xwyho.
int size(void) const
Return number of variables.
virtual bool solution(const Assignment &xwyho) const
Test whether xwyho is solution
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)
virtual bool solution(const Assignment &xy) const
Test whether xy is solution