1、13信算3班张超第1次作业练习1 铁路平板车装货问题(用Lingo求解)有七种规格的包装箱要装到两节铁路平板车上去。包装箱的宽和高是一样的,厚度(t,cm 计)及重量(w,kg计)不同。表1给出了包装箱的厚度、重量以及数量。每节平板车有10.2m 长的地方可装包装箱,载重为40t。由于当地货运的限制,对于C5, C6, C7 类包装箱的总数有一个特别限制:箱子所占的空间(厚度)不能超过302.7cm。试把包装箱装到平板车上,使得浪费空间最小。种类C1C2C3C4C5C6C7t/cm48.753.061.372.048.752.064.0w/kg2000300010005004000200010
2、00n/件8796648决策变量:设包装箱种类为A(i)(i=1,2,.,7),平板车为B(j)(j=1,2),设有x(i,j)个A(i)类包装箱装到平板车B(j)上。目标函数:z=48.7*x(1,1)+48.7*x(1,2)+53.0*x(2,1)+53.0*x(2,2)+61.3*x(3,1)+61.3*x(3,2)+72.0*x(4,1)+72.0*x(4,2)+48.7*x(5,1)+48.7*x(5,2)+52.0*x(6,1)+52.0*x(6,2)+64.0*x(7,1)+64.0*x(7,2).约束条件:数量约束:各类包装箱数量有限,即x(1,1)+x(1,2)=8;x(2,
3、1)+x(2,2)=7;x(3,1)+x(3,2)=9;x(4,1)+x(4,2)=6;x(5,1)+x(5,2)=6;x(6,1)+x(6,2)=4;x(7,1)+x(8,1)=8;空间约束:每节平板车有10.2m 长的地方可装包装箱,即48.7*x(1,1)+53.0*x(2,1)+61.3*x(3,1)+72.0*x(4,1)+48.7*x(5,1)+52.0*x(6,1)+64.0*x(7,1)=1020;48.7*x(1,2)+53.0*x(2,2)+61.3*x(3,2)+72.0*x(4,2)+48.7*x(5,2)+52.0*x(6,2)+64.0*x(7,2)=1020;载重
4、约束:每节平板车载重为40t,即2000*x(1,1)+3000*x(2,1)+1000*x(3,1)+500*x(4,1)+4000*x(5,1)+2000*x(6,1)+1000*x(7,1)=40000;2000*x(1,2)+3000*x(2,2)+1000*x(3,2)+500*x(4,2)+4000*x(5,2)+2000*x(6,2)+1000*x(7,2)=40000;特别约束:箱子所占的空间(厚度)不能超过302.7cm,即48.7*x(5,1)+52.0*x(6,1)+64.0*x(7,1)+48.7*x(5,2)+52.0*x(6,2)+64.0*x(7,2)=0;综上可
5、得Max z=48.7*x(1,1)+48.7*x(1,2)+53.0*x(2,1)+53.0*x(2,2)+61.3*x(3,1)+61.3*x(3,2)+72.0*x(4,1)+72.0*x(4,2)+48.7*x(5,1)+48.7*x(5,2)+52.0*x(6,1)+52.0*x(6,2)+64.0*x(7,1)+64.0*x(7,2).S.t. x(1,1)+x(1,2)=8;x(2,1)+x(2,2)=7;x(3,1)+x(3,2)=9;x(4,1)+x(4,2)=6;x(5,1)+x(5,2)=6; x(6,1)+x(6,2)=4;x(7,1)+x(8,1)=8;48.7*x(
6、1,1)+53.0*x(2,1)+61.3*x(3,1)+72.0*x(4,1)+48.7*x(5,1)+52.0*x(6,1)+64.0*x(7,1)=1020;48.7*x(1,2)+53.0*x(2,2)+61.3*x(3,2)+72.0*x(4,2)+48.7*x(5,2)+52.0*x(6,2)+64.0*x(7,2)=1020;2000*x(1,1)+3000*x(2,1)+1000*x(3,1)+500*x(4,1)+4000*x(5,1)+2000*x(6,1)+1000*x(7,1)=40000;2000*x(1,2)+3000*x(2,2)+1000*x(3,2)+500*
7、x(4,2)+4000*x(5,2)+2000*x(6,2)+1000*x(7,2)=40000;48.7*x(5,1)+52.0*x(6,1)+64.0*x(7,1)+48.7*x(5,2)+52.0*x(6,2)+64.0*x(7,2)=0;模型求解:软件实现!T表示包装箱的厚度,W表示包装箱的重量,N表示包装箱的数量;model:!铁路平板车装货问题;sets: A/n1.n7/:T,W,N;!包装箱; B/1,2/;!平板车; links(A,B):X;endsets!目标函数;max=sum(A(i):sum(B(j):X(i,j)*T(i);!长度约束; for(B(j):sum(
8、A(i):X(i,j)*T(i)=1020);!载重约束; sum(B(j):sum(A(i)|i#ge#5:X(i,j)*T(i)=302.7;!厚度约束; for(B(j):sum(A(i):X(i,j)*W(i)=40000);!件数约束; for(A(i):sum(B(j):X(i,j)=1; x6+x8+x12=1; x1+x2+x3=1; x3+x4+x5+x7=1; x7+x8+x9+x10=1; x10+x12+x13=1; x2+x5+x9+x11=1; x11+x13=1;非负约束:x(i)=0;综上可得:min z=x1+x2+x3+x4+x5+x6+x7+x8+x9+x
9、10+x11+x12+x13; S.t. x1+x4+x6=1; x6+x8+x12=1; x1+x2+x3=1; x3+x4+x5+x7=1; x7+x8+x9+x10=1; x10+x12+x13=1; x2+x5+x9+x11=1; x11+x13=1;模型求解:lingo实现Model:!模型1;min z=x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13;x1+x4+x6=1;x6+x8+x12=1;x1+x2+x3=1;x3+x4+x5+x7=1;x7+x8+x9+x10=1;x10+x12+x13=1;x2+x5+x9+x11=1;x11+x1
10、3=1;gin(x1);gin(x2);gin(x3);gin(x4);gin(x5);gin(x6);gin(x7);gin(x8);gin(x9);gin(x10);gin(x11);gin(x12);gin(x13);end运行结果: Global optimal solution found. Objective value: 4.000000 Objective bound: 4.000000 Infeasibilities: 0.000000 Extended solver steps: 0 Total solver iterations: 0 Variable Value Red
11、uced Cost X1 0.000000 1.000000 X2 0.000000 1.000000 X3 1.000000 1.000000 X4 0.000000 1.000000 X5 0.000000 1.000000 X6 1.000000 1.000000 X7 0.000000 1.000000 X8 0.000000 1.000000 X9 0.000000 1.000000 X10 1.000000 1.000000 X11 1.000000 1.000000 X12 0.000000 1.000000 X13 0.000000 1.000000 Row Slack or
12、Surplus Dual Price 1 4.000000 -1.000000 2 0.000000 0.000000 3 0.000000 0.000000 4 0.000000 0.000000 5 0.000000 0.000000 6 0.000000 0.000000 7 0.000000 0.000000 8 0.000000 0.000000 9 0.000000 0.000000Model:!模型2;min z=x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13;x1+x4+x6=1;x6+x8+x12=1;x1+x2+x3=1;x3+x4+x
13、5+x7=1;x7+x8+x9+x10=1;x10+x12+x13=1;x2+x5+x9+x11=1;x11+x13=1;gin(x1);gin(x2);gin(x3);gin(x4);gin(x5);gin(x6);gin(x7);gin(x8);gin(x9);gin(x10);gin(x11);gin(x12);gin(x13);x3+x6+x10+x11=1;x6+x8+x12=1;x1+x2+x3=1;x3+x4+x5+x7=1;x7+x8+x9+x10=1;x10+x12+x13=1;x2+x5+x9+x11=1;x11+x13=1;gin(x1);gin(x2);gin(x3);
14、gin(x4);gin(x5);gin(x6);gin(x7);gin(x8);gin(x9);gin(x10);gin(x11);gin(x12);gin(x13);x3+x6+x10+x11=3;x3+x6+x9+x13=1;x6+x8+x12=1;x1+x2+x3=1;x3+x4+x5+x7=1;x7+x8+x9+x10=1;x10+x12+x13=1;x2+x5+x9+x11=1;x11+x13=1;gin(x1);gin(x2);gin(x3);gin(x4);gin(x5);gin(x6);gin(x7);gin(x8);gin(x9);gin(x10);gin(x11);gin(
15、x12);gin(x13);x3+x6+x10+x11=3;x3+x6+x9+x13=3;x1+x7+x11+x12=1;x6+x8+x12=1;x1+x2+x3=1;x3+x4+x5+x7=1;x7+x8+x9+x10=1;x10+x12+x13=1;x2+x5+x9+x11=1;x11+x13=1;gin(x1);gin(x2);gin(x3);gin(x4);gin(x5);gin(x6);gin(x7);gin(x8);gin(x9);gin(x10);gin(x11);gin(x12);gin(x13);x3+x6+x10+x11=3;x3+x6+x9+x13=3;x1+x7+x11+x12=3;x1+x5+x8+x13=3;end运行结果:Global optimal solution found. Objective
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1