61 "NoOverlap::Int::2::"+
str(m)+
"::"+
str(w0)+
"::"+
str(h0),
67 int n = xy.
size() / 2;
68 for (
int i=0; i<n; i++) {
69 int xi=xy[2*i+0], yi=xy[2*i+1];
70 for (
int j=i+1; j<n; j++) {
71 int xj=xy[2*j+0], yj=xy[2*j+1];
72 if (!((xi +
w[i] <= xj) || (xj +
w[j] <= xi) ||
73 (yi +
h[i] <= yj) || (yj +
h[j] <= yi)))
82 int n = xy.
size() / 2;
84 for (
int i=0; i<n; i++) {
85 x[i]=xy[2*i+0]; y[i]=xy[2*i+1];
101 3*w0.size(), 0, m-1),
w(w0),
h(h0) {}
104 int n = xyo.
size() / 3;
105 for (
int i=0; i<n; i++) {
106 int xi=xyo[3*i+0], yi=xyo[3*i+1];
108 for (
int j=i+1; j<n; j++) {
109 int xj=xyo[3*j+0], yj=xyo[3*j+1];
111 if ((oi > 0) && (oj > 0) &&
112 !((xi +
w[i] <= xj) || (xj +
w[j] <= xi) ||
113 (yi +
h[i] <= yj) || (yj +
h[j] <= yi)))
122 int n = xyo.
size() / 3;
125 for (
int i=0; i<n; i++) {
126 x[i]=xyo[3*i+0]; y[i]=xyo[3*i+1];
127 o[i]=
expr(home, xyo[3*i+2] > 0);
141 int n = xwyh.
size() / 4;
142 for (
int i=0; i<n; i++) {
143 int xi=xwyh[4*i+0], yi=xwyh[4*i+2];
144 int wi=xwyh[4*i+1], hi=xwyh[4*i+3];
145 for (
int j=i+1; j<n; j++) {
146 int xj=xwyh[4*j+0], yj=xwyh[4*j+2];
147 int wj=xwyh[4*j+1], hj=xwyh[4*j+3];
148 if (!((xi + wi <= xj) || (xj + wj <= xi) ||
149 (yi + hi <= yj) || (yj + hj <= yi)))
158 int n = xwyh.
size() / 4;
159 IntVarArgs x0(n), w(n), x1(n), y0(n), h(n), y1(n);
160 for (
int i=0; i<n; i++) {
161 x0[i]=xwyh[4*i+0]; w[i]=xwyh[4*i+1];
162 x1[i]=
expr(home, x0[i] + w[i]);
163 y0[i]=xwyh[4*i+2]; h[i]=xwyh[4*i+3];
164 y1[i]=
expr(home, y0[i] + h[i]);
180 int n = xwyho.
size() / 5;
181 for (
int i=0; i<n; i++) {
182 int xi=xwyho[5*i+0], yi=xwyho[5*i+2];
183 int wi=xwyho[5*i+1], hi=xwyho[5*i+3];
185 for (
int j=i+1; j<n; j++) {
186 int xj=xwyho[5*j+0], yj=xwyho[5*j+2];
187 int wj=xwyho[5*j+1], hj=xwyho[5*j+3];
189 if ((oi > 0) && (oj > 0) &&
190 !((xi + wi <= xj) || (xj + wj <= xi) ||
191 (yi + hi <= yj) || (yj + hj <= yi)))
200 int n = xwyho.
size() / 5;
201 IntVarArgs x0(n), w(n), x1(n), y0(n), h(n), y1(n);
203 for (
int i=0; i<n; i++) {
204 x0[i]=xwyho[5*i+0]; w[i]=xwyho[5*i+1];
205 x1[i]=
expr(home, x0[i] + w[i]);
206 y0[i]=xwyho[5*i+2]; h[i]=xwyho[5*i+3];
207 y1[i]=
expr(home, y0[i] + h[i]);
208 o[i]=
expr(home, xwyho[5*i+4] > 0);
210 nooverlap(home, x0, w, x1, y0, h, y1, o);
220 str(m)+
"::"+
str(n), 2*n+2, 0, m) {
225 int n = (xwyho.
size() - 2) / 2;
226 for (
int i=0; i<n; i++) {
227 int xi=xwyho[2*i+0], yi=xwyho[2*i+0];
228 int wi=xwyho[2*i+1], hi=xwyho[2*i+1];
229 int oi=xwyho[2*n + (i % 2)];
230 for (
int j=i+1; j<n; j++) {
231 int xj=xwyho[2*j+0], yj=xwyho[2*j+0];
232 int wj=xwyho[2*j+1], hj=xwyho[2*j+1];
233 int oj=xwyho[2*n + (j % 2)];
234 if ((oi > 0) && (oj > 0) &&
235 !((xi + wi <= xj) || (xj + wj <= xi) ||
236 (yi + hi <= yj) || (yj + hj <= yi)))
245 int n = (xwyho.
size() - 2) / 2;
246 IntVarArgs x0(n), w(n), x1(n), y0(n), h(n), y1(n);
248 for (
int i=0; i<n; i++) {
249 x0[i]=xwyho[2*i+0]; w[i]=xwyho[2*i+1];
250 x1[i]=
expr(home, x0[i] + w[i]);
251 y0[i]=xwyho[2*i+0]; h[i]=xwyho[2*i+1];
252 y1[i]=
expr(home, y0[i] + h[i]);
253 o[i]=
expr(home, xwyho[2*n + (i % 2)] > 0);
255 nooverlap(home, x0, w, x1, y0, h, y1, o);
272 for (
int m=2; m<3; m++) {
283 (void)
new Var2(2, 2);
284 (void)
new Var2(3, 2);
285 (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).
TestTags tags(void) const
Return tags for test.
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)
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
Int2(TestTags tags, int m, const Gecode::IntArgs &w0, const Gecode::IntArgs &h0)
Create and register test with maximal coordinate value m.
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.
static std::string str(bool b)
Map bool to string.
bool testfix
Whether to perform fixpoint test.
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.
Tests for no-overlap constraint
Testing finite domain integers.
@ sweep
Really heavy sweep tests.