《钢管的订购和运输模型程序(共12页).doc》由会员分享,可在线阅读,更多相关《钢管的订购和运输模型程序(共12页).doc(12页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上模型一的matlab程序!A为邻接矩阵;T,T2分别为铁路的矩阵和铁路的费用矩阵;R,R2分别为公路的矩阵和公路的费用矩阵;w,Q为总费用矩阵;cost为S到A的各项费用矩阵A=ones(39,39);for i=1:39; for j=1:39; if i=j A(i,j)=0; else A(i,j)=inf; end endend A(8,10)=450;A(9,10)=80;A(10,11)=1150;A(11,16)=1100;A(12,13)=306;A(13,14)=195;A(1,14)=20;A(1,16)=202;A(2,16)=1200;A(16
2、,17)=720;A(3,17)=690;A(17,18)=520;A(18,19)=170;A(4,19)=690;A(19,20)=160;A(5,15)=462;A(15,19)=88;A(20,21)=70;A(20,22)=320;A(22,23)=160;A(6,23)=70;A(23,24)=290;A(7,24)=30;for j=1:39; for i=1:j-1; A(j,i)=A(i,j); endend T=A;m=1;while mT(i,m)+T(m,j); T(i,j)=T(i,m)+T(m,j); end end end m=m+1;endT2=ones(39,
3、39);for i=1:39; for j=1:39; if T(i,j)=0 T2(i,j)=T(i,j); elseif T(i,j)0&T(i,j)300&T(i,j)350&T(i,j)400&T(i,j)450&T(i,j)500&T(i,j)600&T(i,j)700&T(i,j)800&T(i,j)900&T(i,j)=1000 T2(i,j)=60; else T2(i,j)=60+ceil(T(i,j)-1000)/100)*5; end endendB=ones(39,39);for i=1:39; for j=1:39; if i=j B(i,j)=0; else B(i
4、,j)=inf; end endend B(8,26)=3;B(9,27)=2;B(11,28)=600;B(12,29)=10;B(13,30)=5;B(14,31)=10;B(1,31)=31;B(16,32)=12;B(17,33)=42;B(18,34)=70;B(15,35)=10;B(21,36)=10;B(22,37)=62;B(6,38)=110;B(23,38)=30;B(24,39)=20;B(7,39)=20;B(25,26)=104;B(26,27)=301;B(27,28)=750;B(28,29)=606;B(29,30)=194;B(30,31)=205;B(31
5、,32)=201;B(32,33)=680;B(33,34)=480;B(34,35)=300;B(35,36)=220;B(36,37)=210;B(37,38)=420;B(38,39)=500;for j=1:39; for i=1:j-1; B(j,i)=B(i,j); endendR=B;g=1;while gR(i,g)+R(g,j); R(i,j)=R(i,g)+R(g,j); end end end g=g+1;endR2=0.1.*R;w=ones(39,39);for i=1:39; for j=1:39; if T2(i,j)R2(i,j) w(i,j)=R2(i,j);
6、 else w(i,j)=T2(i,j); end end endf=1;while fw(i,f)+w(f,j) w(i,j)=w(i,f)+w(f,j); end end end f=f+1;endQ=ones(39,39);for i=1:7 for j=25:39 cost(i,j)=w(i,j) endend模型一的matlab结果cost =Columns 25 through 39 170.7000 160.3000 140.2000 98.6000 38.0000 20.5000 3.1000 21.2000 64.2000 92.0000 96.0000 106.0000 1
7、21.2000 128.0000 142.0000 215.7000 205.3000 190.2000 171.6000 111.0000 95.5000 86.0000 71.2000 114.2000 142.0000 146.0000 156.0000 171.2000 178.0000 192.0000 230.7000 220.3000 200.2000 181.6000 121.0000 105.5000 96.0000 86.2000 48.2000 82.0000 86.0000 96.0000 111.2000 118.0000 132.0000 260.7000 250.
8、3000 235.2000 216.6000 156.0000 140.5000 131.0000 116.2000 84.2000 62.0000 51.0000 61.0000 76.2000 83.0000 97.0000 255.7000 245.3000 225.2000 206.6000 146.0000 130.5000 121.0000 111.2000 79.2000 57.0000 33.0000 51.0000 71.2000 73.0000 87.0000 265.7000 255.3000 235.2000 216.6000 156.0000 140.5000 131
9、.0000 121.2000 84.2000 62.0000 51.0000 45.0000 26.2000 11.0000 28.0000 275.7000 265.3000 245.2000 226.6000 166.0000 150.5000 141.0000 131.2000 99.2000 76.0000 66.0000 56.0000 38.2000 26.0000 2.0000模型一的lingo程序model:!钢管购买与运输铺优化设问; sets:!cj表示厂家;md表示目的地; cj/1.7/:p,s,t; md/1.15/:y,z,D; link(cj,md):cost,x
10、; endsets!这里是数据; data: s=800 800 1000 2000 2000 2000 3000; D=104,301,750,606,194,205,201,680,480,300,220,210,420,500,0; p=160,155,155,160,155,150,160; cost=170.7 160.3 140.2 98.6 38.0 20.5 3.1 21.2 64.2 92.0 96.0 106.0 121.2 128.0 142.0 215.7 205.3 190.2 171.6 111.0 95.5 86.0 71.2 114.2 142.0 146.0
11、156.0 171.2 178.0 192.0 230.7 220.3 200.2 181.6 121.0 105.5 96.0 86.2 48.2 82.0 86.0 96.0 111.2 118.0 132.0 260.7 250.3 235.2 216.6 156.0 140.5 131.0 116.2 84.2 62.0 51.0 61.0 76.2 83.0 97.0 255.7 245.3 225.2 206.6 146.0 130.5 121.0 111.2 79.2 57.0 33.0 51.0 71.2 73.0 87.0 265.7 255.3 235.2 216.6 15
12、6.0 140.5 131.0 121.2 84.2 62.0 51.0 45.0 26.2 11.0 28.0 275.7 265.3 245.2 226.6 166.0 150.5 141.0 131.2 99.2 77.0 66.0 56.0 38.2 26.0 2.0; enddata!目标函数; min=w; w=sum(link(i,j):(p(i)+cost(i,j)*x(i,j)+0.1/2*sum(md(j):y(j)2+y(j)+z(j)2+z(j);!约束条件; for(cj(i):sum(md(j):x(i,j)=500*t(i); s(i)*t(i)=sum(md(j
13、):x(i,j); bin(t(i); for(md(j):sum(cj(i):x(i,j)=y(j)+z(j); for(md(j)|j#ne#15:D(j)=y(j)+z(j+1); z(15)=0;y(1)=0; gin(sum(link(i,j):x(i,j); end 铺设方案 Variable Value Reduced Cost Y( 1) 0. 0. Y( 2) 75.00000 0. Y( 3) 282.0000 0. Y( 4) 0. 0. Y( 5) 9. 0. Y( 6) 15.50000 0. Y( 7) 76.00000 0. Y( 8) 175.0000 0. Y
14、( 9) 159.0000 0. Y( 10) 30.00000 0. Y( 11) 145.0000 0. Y( 12) 11.00000 0. Y( 13) 134.0000 0. Y( 14) 500.0000 0. Y( 15) 0. 141.0500 Z( 1) 0. 405.7500 Z( 2) 104.0000 0. Z( 3) 226.0000 0. Z( 4) 468.0000 0. Z( 5) 606.0000 0. Z( 6) 184.5000 0. Z( 7) 189.5000 0. Z( 8) 125.0000 0. Z( 9) 505.0000 0. Z( 10)
15、321.0000 0. Z( 11) 270.0000 0. Z( 12) 75.00000 0. Z( 13) 199.0000 0. Z( 14) 286.0000 0. Z( 15) 0. 0.厂家分配方案X( 1, 1) 0. 28.00000 X( 1, 2) 0. 28.00000 X( 1, 3) 0. 23.00000 X( 1, 4) 250.4441 0. X( 1, 5) 84.05588 0. X( 1, 6) 200.0000 0. X( 1, 7) 265.5000 0. X( 1, 8) 0. 23.00000 X( 1, 9) 0. 99.00000 X( 1,
16、 10) 0. 143.0000 X( 1, 11) 0. 171.0000 X( 1, 12) 0. 174.0000 X( 1, 13) 0. 208.0000 X( 1, 14) 0. 230.0000 X( 1, 15) 0. 264.0000 X( 2, 1) 0. 0. X( 2, 2) 179.0000 0. X( 2, 3) 321.0000 0. X( 2, 4) 0. 0. X( 2, 5) 0. 0. X( 2, 6) 0. 2. X( 2, 7) 0. 9. X( 2, 8) 300.0000 0. X( 2, 9) 0. 76.00000 X( 2, 10) 0. 1
17、20.0000 X( 2, 11) 0. 148.0000 X( 2, 12) 0. 151.0000 X( 2, 13) 0. 185.0000 X( 2, 14) 0. 207.0000 X( 2, 15) 0. 241.0000 X( 3, 1) 0. 5. X( 3, 2) 0. 5. X( 3, 3) 147.2817 0. X( 3, 4) 119.7061 0. X( 3, 5) 69.01229 0. X( 3, 6) 0. 2. X( 3, 7) 0. 9. X( 3, 8) 0. 5. X( 3, 9) 664.0000 0. X( 3, 10) 0. 50.00000 X
18、( 3, 11) 0. 78.00000 X( 3, 12) 0. 81.00000 X( 3, 13) 0. 115.0000 X( 3, 14) 0. 137.0000 X( 3, 15) 0. 171.0000 X( 4, 1) 0. 5. X( 4, 2) 0. 5. X( 4, 3) 0. 5. X( 4, 4) 0. 5. X( 4, 5) 0. 5. X( 4, 6) 0. 7. X( 4, 7) 0. 14.90000 X( 4, 8) 0. 5. X( 4, 9) 0. 6. X( 4, 10) 0. 0. X( 4, 11) 0. 13.00000 X( 4, 12) 0.
19、 16.00000 X( 4, 13) 0. 50.00000 X( 4, 14) 0. 72.00000 X( 4, 15) 0. 106.0000 X( 5, 1) 0. 5. X( 5, 2) 0. 5. X( 5, 3) 39.71834 0. X( 5, 4) 97.84982 0. X( 5, 5) 462.4318 0. X( 5, 6) 0. 2. X( 5, 7) 0. 9. X( 5, 8) 0. 5. X( 5, 9) 0. 6. X( 5, 10) 262.7391 0. X( 5, 11) 415.0000 0. X( 5, 12) 0. 11.00000 X( 5,
20、 13) 0. 50.00000 X( 5, 14) 0. 67.00000 X( 5, 15) 0. 101.0000 X( 6, 1) 0. 10.00000 X( 6, 2) 0. 10.00000 X( 6, 3) 0. 5. X( 6, 4) 0. 5. X( 6, 5) 0. 5. X( 6, 6) 0. 7. X( 6, 7) 0. 14.90000 X( 6, 8) 0. 10.00000 X( 6, 9) 0. 6. X( 6, 10) 88.26093 0. X( 6, 11) 0. 13.00000 X( 6, 12) 86.00000 0. X( 6, 13) 333.
21、0000 0. X( 6, 14) 786.0000 0. X( 6, 15) 0. 37.00000 X( 7, 1) 0. 9. X( 7, 2) 0. 9. X( 7, 3) 0. 4. X( 7, 4) 0. 4. X( 7, 5) 0. 4. X( 7, 6) 0. 6. X( 7, 7) 0. 13.90000 X( 7, 8) 0. 9. X( 7, 9) 0. 10.00000 X( 7, 10) 0. 4. X( 7, 11) 0. 17.00000 X( 7, 12) 0. 0. X( 7, 13) 0. 1. X( 7, 14) 0. 4. X( 7, 15) 0. 0.
22、最少总费用Local optimal solution found. Objective value: . Extended solver steps: 0 Total solver iterations: 36模型三的matlab程序 A=ones(39,39);for i=1:39; for j=1:39; if i=j A(i,j)=0; else A(i,j)=inf; end endend A(8,10)=450;A(9,10)=80;A(10,11)=1150;A(11,16)=1100;A(12,13)=306;A(13,14)=195;A(1,14)=20;A(1,16)=20
23、2;A(2,16)=1200;A(16,17)=720;A(3,17)=690;A(17,18)=520;A(18,19)=170;A(4,19)=690;A(19,20)=160;A(5,15)=462;A(15,19)=88;A(20,21)=70;A(20,22)=320;A(22,23)=160;A(6,23)=70;A(23,24)=290;A(7,24)=30;for j=1:39; for i=1:j-1; A(j,i)=A(i,j); endend T=A;m=1;while mT(i,m)+T(m,j); T(i,j)=T(i,m)+T(m,j); end end end m=m+1;endT2=ones(39,39);for i=1:39; for j=1:39; if T(i,j)=0 T2(i,j)=T(i,j); elseif T(i,j)0&T(i,j)300&T(i,j)350&T(i,j)400&T(i,j)450&T(i,j)500&T(i,j)600&T(i,j)700&T(i,j)800&T(i,j)=900 T2(i
限制150内