Solving 2d bin packing, nesting problem with Cplex

Is it possible to solve a 2d bin packing problem or nesting problem with Cplex? The solution should present the $$x$$ and $$y$$ coordinates of each item.

– EhsanK
Feb 3 '21 at 16:49
• @Mathew, beside of the interested answer of Alex, you might want to take a look into the ABS models to solve floor layout problems. :) Feb 4 '21 at 8:14

//using CP;

int n=25; // nb of rectangles

int sizeBigSquare=10000;

int l[i in 1..n]=rand(100);
int w[i in 1..n]=rand(100);

dvar int x[i in 1..n]in 0..sizeBigSquare;
dvar int y[i in 1..n] in 0..sizeBigSquare;
dvar boolean rota[i in 1..n]; // do we rotate?

dexpr int x2[i in 1..n]=x[i]+(rota[i]==1)*w[i]+(rota[i]==0)*l[i];
dexpr int y2[i in 1..n]=y[i]+(rota[i]==1)*l[i]+(rota[i]==0)*w[i];

dexpr int Mx=max(i in 1..n) x2[i];
dexpr int My=max(i in 1..n) y2[i];

minimize My;

subject to
{

Mx<=1000;
forall(ordered i,j in 1..n)
(x2[i]<=x[j]) || (x2[j]<=x[i]) || (y2[i]<=y[j]) || (y2[j]<=y[i]);
}

float rate=sum(i in 1..n) w[i]*l[i]/My/Mx;

execute
{
writeln("Rate=",rate);
}

that is relying on MIP within CPLEX

And if you comment // in //using CP; then this model will use constraint programming