Page 247 - 数学建模算法与应用
P. 247
第八章 图与网络模型及方法应用
supply/S1..S7/:s,p,f;
need/A1..A21/:b,y,z;!y 表示每一点往节点编号小的方向铺设量,z 表示
往节点编号大的方向铺设量;
linkf(supply,need):cf,x;
special/1..3/:sx;! 铺设节点 9,11,17 往最大编号节点方向的铺设量;
endsets
data:
s=800 800 1000 2000 2000 2000 3000;
p=160 155 155 160 155 150 160;
b=104,301,750,606,194,205,201,680,480,300,220,210,
420,500,42,10,130,190,260,100,0;
path1=0; path=0; w=0; c2=0;
! 以下是格式化输出计算的中间结果和最终结果;
@text(MiddleCost.txt)=@writefor(supply(i): @writefor(need(j): @
format(cf(i,j),’ 6.1f’ )), @newline(1));
@text(Train_path.txt)=@writefor(nodes(i):@writefor(nodes(j):@
format(path1(i,j),’5.0f’)), @newline(1));
@text(Final_path.txt)=@writefor(nodes(i):@writefor(nodes(j):@
format(path(i,j),’5.0f’)), @newline(1));
@text(FinalResult.txt)=@writefor(supply(i):@writefor(need(j):@
format(x(i,j),’5.0f’)), @newline(1) );
@text(FinalResult.txt)=@write(@newline(1));
@text(FinalResult.txt)=@writefor(need:@format(y,’5.0f’));
@text(FinalResult.txt)=@write(@newline(2));
@text(FinalResult.txt)=@writefor(need:@format(z,’5.0f’));
enddata
calc:
! 输入铁路距离邻接矩阵的上三角元素;
w(28,30)=450;w(29,30)=80;w(30,32)=1150;w(31,33)=306;w(33,
34)=195;w(1,34)=20;
237

