作业帮 > 数学 > 作业

floyd算法计算最短距离时,赋权邻接矩阵怎么算

来源:学生作业帮 编辑:作业帮 分类:数学作业 时间:2024/11/05 14:47:57
floyd算法计算最短距离时,赋权邻接矩阵怎么算
Model:
!2个工厂,3个中转站及4个客户的运输问题;
sets:
plant/A,B/:produce;
warhouse/x,y,z/;
costomer/1..4/:require;
link(plant,warhouse,costomer):poss,cost,x;
endsets
data:
produce=9,8;
require=3,4,3,5;
!邻接矩阵;
poss = 1 1 0 0 !A-x-1,A-x-2,A-x-3,A-x-4;
1 1 1 0 !A-y-1,A-y-2,A-y-3,A-y-4;
0 0 0 0 !A-z-1,A-z-2,A-z-3,A-z-4;
0 1 0 0 !B-x-1,B-x-2,B-x-3,B-x-4;
1 1 1 0 !B-y-1,B-y-2,B-y-3,B-y-4;
0 1 1 1; !B-z-1,B-z-2,B-z-3,B-z-4;
!赋权矩阵;
cost=6 8 0 0
11 8 9 0
0 0 0 0
8 10 0 0
10 7 8 0
0 10 9 6;
enddata
!目标函数;
min=@sum(link:poss*cost*x);
!约束条件;
@for(plant(i):@sum(warhouse(j):@sum(costomer(k):poss(i,j,k)*x(i,j,k)))