钢管的订购和运输模型程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

模型一的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

end

end

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,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);

end

end

T=A;

m=1;

while m<=39

for i=1:39

for j=1:39

if T(i,j)>T(i,m)+T(m,j);

T(i,j)=T(i,m)+T(m,j);

end

end

end

m=m+1;

end

T2=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 T2(i,j)=20;

elseif T(i,j)>300&T(i,j)<=350 T2(i,j)=23;

elseif T(i,j)>350&T(i,j)<=400 T2(i,j)=26;

elseif T(i,j)>400&T(i,j)<=450 T2(i,j)=29;

elseif T(i,j)>450&T(i,j)<=500 T2(i,j)=32;

elseif T(i,j)>500&T(i,j)<=600 T2(i,j)=37;

elseif T(i,j)>600&T(i,j)<=700 T2(i,j)=44;

elseif T(i,j)>700&T(i,j)<=800 T2(i,j)=50;

elseif T(i,j)>800&T(i,j)<=900 T2(i,j)=55;

elseif 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

end

end

B=ones(39,39);

for i=1:39;

for j=1:39;

if i==j B(i,j)=0;

else B(i,j)=inf;

end

end

end

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,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);

end

end

R=B;

g=1;

while g<=39;

for i=1:39;

for j=1:39;

if R(i,j)>R(i,g)+R(g,j);

R(i,j)=R(i,g)+R(g,j);

end

end

end

g=g+1;

end

R2=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);

else w(i,j)=T2(i,j);

end

end

end

f=1;

while f<=39

for i=1:39

for j=1:39

if w(i,j)>w(i,f)+w(f,j)

w(i,j)=w(i,f)+w(f,j);

end

end

end

f=f+1;

end

Q=ones(39,39);

for i=1:7

for j=25:39

cost(i,j)=w(i,j)

end

end

模型一的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 121.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.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.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

相关文档
最新文档