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;
157 IntVarArgs x0(n), w(n), x1(n), y0(n), h(n), y1(n);
158 for (
int i=0; i<n; i++) {
159 x0[i]=xwyh[4*i+0]; w[i]=xwyh[4*i+1];
160 x1[i]=
expr(home, x0[i] + w[i]);
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;
199 IntVarArgs x0(n), w(n), x1(n), y0(n), h(n), y1(n);
201 for (
int i=0; i<n; i++) {
202 x0[i]=xwyho[5*i+0]; w[i]=xwyho[5*i+1];
203 x1[i]=
expr(home, x0[i] + w[i]);
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);
208 nooverlap(home, x0, w, x1, y0, h, y1, o);
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;
244 IntVarArgs x0(n), w(n), x1(n), y0(n), h(n), y1(n);
246 for (
int i=0; i<n; i++) {
247 x0[i]=xwyho[2*i+0]; w[i]=xwyho[2*i+1];
248 x1[i]=
expr(home, x0[i] + w[i]);
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);
253 nooverlap(home, x0, w, x1, y0, h, y1, o);
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);
Passing Boolean variables.
Passing integer arguments.
Passing integer variables.
int size(void) const
Return size of array (number of elements)
Base class for assignments
int size(void) const
Return number of variables.
Help class to create and register tests.
Create(void)
Perform creation and registration.
Test for no-overlap with integer dimensions (rectangles)
Int2(int m, const Gecode::IntArgs &w0, const Gecode::IntArgs &h0)
Create and register test with maximal coordinate value m.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xy)
Post constraint on xy.
virtual bool solution(const Assignment &xy) const
Test whether xy is solution
Test for no-overlap with optional rectangles
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xyo)
Post constraint on xwyho.
IntOpt2(int m, const Gecode::IntArgs &w0, const Gecode::IntArgs &h0)
Create and register test with maximal value m and n rectangles.
virtual bool solution(const Assignment &xyo) const
Test whether xyo is solution
Test for no-overlap with variable dimensions (rectangles)
Var2(int m, int n)
Create and register test with maximal value m and n rectangles.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xwyh)
Post constraint on xwyh.
virtual bool solution(const Assignment &xwyh) const
Test whether xwyh is solution
Test for no-overlap with optional rectangles
virtual bool solution(const Assignment &xwyho) const
Test whether xwyho is solution
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xwyho)
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 optional rectangles and shared variables
VarOptShared2(int m, int n)
Create and register test with maximal value m and n rectangles.
virtual bool solution(const Assignment &xwyho) const
Test whether xwyho is solution
virtual void post(Gecode::Space &home, Gecode::IntVarArray &xwyho)
Post constraint on xwyho.
bool testfix
Whether to perform fixpoint test.
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
void nooverlap(Home home, const IntVarArgs &x, const IntArgs &w, const IntVarArgs &y, const IntArgs &h, IntPropLevel ipl=IPL_DEF)
Post propagator for rectangle packing.
Gecode toplevel namespace
IntVar expr(Home home, const LinIntExpr &e, const IntPropLevels &ipls=IntPropLevels::def)
Post linear expression and return its value.
Post propagator for SetVar SetOpType SetVar y
Post propagator for SetVar x
Tests for no-overlap constraint
Testing finite domain integers.