CPLEX上不可行的解决方案错误(2D箱包装问题)
[可行解决方案的表示] [1] [1]:https://i.sstatic.net/83esm.png
大家好,
我目前正在研究CPLEX上3级二维箱包装问题的改编。不幸的是,当我尝试解决问题时,出现一些错误。 该模型的目的是将高度和宽度的项目分配给最小数量的垃圾箱。 这些项目将首先分配给堆栈,然后将堆栈分配给条纹,最后条纹将被分配给垃圾箱(图像附加的示例)。 物品是根据其高度订购的(最高项目将首先使用最小的索引(例如1))。堆栈/条纹具有最高项目的索引(最小的索引)。 原始模型的救援表明,堆栈的物品必须具有相同的宽度。 我正在尝试更改此公式,以便堆栈中的项目可以具有不同的宽度。 我的方法是定义一个新的决策变量(float),该变量将按每个堆栈上每个项目的最大宽度(第二次最后一个约束)的最大宽度,然后限制条纹的宽度,而条纹的宽度不会大于宽度。垃圾箱(最后一个约束)。
在我的描述中,“ bin =手推车”,
我非常感谢您的评论,以了解我在忽略的内容。
引擎日志上的错误 传统回调pi 警告:整数变量的非整体界限。 不可行的行'c160':0< = -5。
第160行提及第二个添加的约束。 C160: - _e(1)(2)#26 + 5 a(2)(2)(2)#52< = 0
当我增加宽度容量时,我得到了此错误: 传统回调pi 警告:整数变量的非整体界限。 行'c255'不可行,所有条目在隐含的边界处。
c255: _e(1)(1)#25 + _e(1)(2)#26 + _e(1)(3)#27 + _e(1)(4)#28 + _e(1)(5)#29
- 20 b(1)(1)#65 <= 0
我尝试给出一个可行的灵魂,但我仍然在新约束上遇到错误。
/*a [1] [1] == 1; a [1] [3] == 1;
a [2] [2] == 1; a [2] [4] == 1;
a [5] [5] == 1;
B [1] [1] == 1; B [1] [2] == 1;
C [1] [1] == 1;
B [5] [5] == 1; C [5] [5] == 1;*/
模型摘要:
int n=...; //number of items
range iitem=1..n;
float heighttrolley=...; //length of bin j
float widthtrolley=...; //width of bin j
float heightitem[iitem]=...; //length of item i
float widthitem[iitem]=...; //width of item i
dvar boolean a[1..n][1..n]; //if item i is assigned to stack j
dvar boolean b[1..n][1..n]; //if stack j is contained in stripe k
dvar boolean c[1..n][1..n]; //if stripe k is contained in bin l
dvar boolean d[1..n-1][2..n][1..n-1]; //if item i contributes to the total height of all stripes in bin l and is contained in stack j
dvar float e[1..n][1..n]; //max width of an item in stack j contained in stripe k
minimize sum (l in 1..n) c[l][l];
subject to{
forall(j in 1..n, i in 1..n: i<j)
a[j][i]==0;
forall(l in 1..n, k in 1..n: k<l)
c[l][k]==0;
forall(l in 1..n-1, i in l+1..n, j in l..n-1: i<l+1 && j<l && j>i-1)
d[l][i][j]==0;
forall(j, k in iitem)
e[j][k]<=widthtrolley;
forall(i in iitem)
sum (j in 1..i) a[j][i]==1; //each item has to be packed once
forall(j in 1..n-1)
sum (i in j+1..n)a[j][i]<=(n-j)*a[j][j]; //items can be assigned to unused stacks
forall(j in 1..n-1, i in iitem: i>j && heightitem[i]+heightitem[j]>heighttrolley)// && widthitem[i]<=widthitem[j]) //total height of any pair of stacked items must not exceed height of bin
a[j][i]==0;
forall(j in 1..n)
sum (k in 1..n) b[k][j]==a[j][j]; // every item j is packed exactly once into a stripe k
forall(k in 2..n, j in 1..k-1)
sum(i in j..n) heightitem[i]*a[j][i]<= sum(i in k..n)heightitem[i]*a[k][i]+(heighttrolley+1)*(1-b[k][j]); //ensure that the height of each stack j never exceeds the height of the stripe k it is contained in (1)
forall(k in 1..n-1, j in k+1..n)
sum(i in j..n) heightitem[i]*a[j][i]<= sum(i in k..n)heightitem[i]*a[k][i]+heighttrolley*(1-b[k][j]); //ensure that the height of each stack j never exceeds the height of the stripe k it is contained in (2)
forall(k in 1..n)
sum(l in 1..k)c[l][k]==b[k][k]; //force each used stripe k to be packed into exactly one bin
forall(l in 1..n-1)
sum(i in l..n)heightitem[i]*c[l][i]+sum(i in l+1..n)heightitem[i]*sum(j in l..i-1)d[l][i][j]<=heighttrolley*c[l][l]; //bins used height has to be smaller than the height of bin
forall(l in 1..n-1, i in l+1..n, j in l..i-1){ //force variable d to be set to 1, when item i contributes to the total height of all stripes in bin l and is contained in stack j
a[j][i]+c[l][j]-1<=d[l][i][j];
d[l][i][j]<=(a[j][i]+c[l][j])/2;}
forall(l in 1..n-1)
sum(k in l+1..n)c[l][k]<=(n-l)*c[l][l]; //ensure that no stripes are packed into an unused bin
forall(i,j,k in iitem) //if item i is assigned to stack j, then e[k][j] has to be at least bigger than the width of item i
widthitem[i]*a[j][i]<=e[k][j];
forall(k in iitem)
sum(j in iitem)e[k][j]<=widthtrolley*b[k][k]; //for every stripe, the sum of the max width of every stack j on the sripe k must be smaller than the width of the bin
[Representation of feasible solution][1]
[1]: https://i.sstatic.net/83ESm.png
Hi Everyone,
I'm currently working on an adaptation of a 3-Stage Two Dimensional Bin Packing Problem on Cplex. Unfortunately when I try to run the problem some errors appear.
The goal of the model is to allocate an n ount of items with height and width to a minimum number of bins.
The items are gonna be first assigned to stacks, then the stacks are gonna be assigned to stripes and last stripes are gonna be assigned to a bin (example on image attached).
Items are ordered according their height (highest item is gonna be first with the smallest index (e.g. 1)). The stacks/stripes have the index of the heighest item (smallest index).
The original model has the resctriction that the items withtin a stack must have the same width.
I'm trying to change this formulation, so that the items within the stack can have different widths.
My approach was to define a new decision variable (float), which is gonna sequentelly delimit by max width of every every item on every stack (second last constraint) and then restrict the width of the stripe, which can not be bigger than the width of the bin (last constraint).
"Bin=Trolley" on my descriptions
I would greatly appreciate a review to see what I am overlooking.
Error on Engine Log
Legacy callback pi
Warning: Non-integral bounds for integer variables rounded.
Infeasibility row 'c160': 0 <= -5.
row 160 make reference to the second last added constraint.
c160: - _e(1)(2)#26 + 5 a(2)(2)#52 <= 0
When I increase the width capacity, I got this error:
Legacy callback pi
Warning: Non-integral bounds for integer variables rounded.
Row 'c255' infeasible, all entries at implied bounds.
c255: _e(1)(1)#25 + _e(1)(2)#26 + _e(1)(3)#27 + _e(1)(4)#28 + _e(1)(5)#29
- 20 b(1)(1)#65 <= 0
I tried giving a feasible soultion, but I still get the error on the new constraint.
/*a[1][1]==1;
a[1][3]==1;
a[2][2]==1;
a[2][4]==1;
a[5][5]==1;
b[1][1]==1;
b[1][2]==1;
c[1][1]==1;
b[5][5]==1;
c[5][5]==1;*/
Summary of the model:
int n=...; //number of items
range iitem=1..n;
float heighttrolley=...; //length of bin j
float widthtrolley=...; //width of bin j
float heightitem[iitem]=...; //length of item i
float widthitem[iitem]=...; //width of item i
dvar boolean a[1..n][1..n]; //if item i is assigned to stack j
dvar boolean b[1..n][1..n]; //if stack j is contained in stripe k
dvar boolean c[1..n][1..n]; //if stripe k is contained in bin l
dvar boolean d[1..n-1][2..n][1..n-1]; //if item i contributes to the total height of all stripes in bin l and is contained in stack j
dvar float e[1..n][1..n]; //max width of an item in stack j contained in stripe k
minimize sum (l in 1..n) c[l][l];
subject to{
forall(j in 1..n, i in 1..n: i<j)
a[j][i]==0;
forall(l in 1..n, k in 1..n: k<l)
c[l][k]==0;
forall(l in 1..n-1, i in l+1..n, j in l..n-1: i<l+1 && j<l && j>i-1)
d[l][i][j]==0;
forall(j, k in iitem)
e[j][k]<=widthtrolley;
forall(i in iitem)
sum (j in 1..i) a[j][i]==1; //each item has to be packed once
forall(j in 1..n-1)
sum (i in j+1..n)a[j][i]<=(n-j)*a[j][j]; //items can be assigned to unused stacks
forall(j in 1..n-1, i in iitem: i>j && heightitem[i]+heightitem[j]>heighttrolley)// && widthitem[i]<=widthitem[j]) //total height of any pair of stacked items must not exceed height of bin
a[j][i]==0;
forall(j in 1..n)
sum (k in 1..n) b[k][j]==a[j][j]; // every item j is packed exactly once into a stripe k
forall(k in 2..n, j in 1..k-1)
sum(i in j..n) heightitem[i]*a[j][i]<= sum(i in k..n)heightitem[i]*a[k][i]+(heighttrolley+1)*(1-b[k][j]); //ensure that the height of each stack j never exceeds the height of the stripe k it is contained in (1)
forall(k in 1..n-1, j in k+1..n)
sum(i in j..n) heightitem[i]*a[j][i]<= sum(i in k..n)heightitem[i]*a[k][i]+heighttrolley*(1-b[k][j]); //ensure that the height of each stack j never exceeds the height of the stripe k it is contained in (2)
forall(k in 1..n)
sum(l in 1..k)c[l][k]==b[k][k]; //force each used stripe k to be packed into exactly one bin
forall(l in 1..n-1)
sum(i in l..n)heightitem[i]*c[l][i]+sum(i in l+1..n)heightitem[i]*sum(j in l..i-1)d[l][i][j]<=heighttrolley*c[l][l]; //bins used height has to be smaller than the height of bin
forall(l in 1..n-1, i in l+1..n, j in l..i-1){ //force variable d to be set to 1, when item i contributes to the total height of all stripes in bin l and is contained in stack j
a[j][i]+c[l][j]-1<=d[l][i][j];
d[l][i][j]<=(a[j][i]+c[l][j])/2;}
forall(l in 1..n-1)
sum(k in l+1..n)c[l][k]<=(n-l)*c[l][l]; //ensure that no stripes are packed into an unused bin
forall(i,j,k in iitem) //if item i is assigned to stack j, then e[k][j] has to be at least bigger than the width of item i
widthitem[i]*a[j][i]<=e[k][j];
forall(k in iitem)
sum(j in iitem)e[k][j]<=widthtrolley*b[k][k]; //for every stripe, the sum of the max width of every stack j on the sripe k must be smaller than the width of the bin
Link to data:
https://1drv.ms/u/s!Ajgu5Yf1URAAe7xcGOjaudRwhbQ?e=cKH7Ui
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的模型不可行。
例如,如果您将其命名为这样的约束:
那么在IDE中,您将获得一系列放松和冲突,可以帮助您调试模型。
Your model is not feasible.
If you name your constraints like this for instance:
then in the IDE you will get a set of relaxations and conflicts that will help you debug the model.