sets:
firehouse/1..3/:num
fire/1..7/:
link(firehouse,fire):distance,x
endsets
data:
num=3,2,2
enddata
min=@sum(link:distance*x)
@for(firehouse(i):@sum(fire(j):x(i,j))=num(i))
@for(fire(j):@sum(firehouse(i):x(i,j))=1)
@for(link:@gin(x))
end
结果
X( 1, 1)0.0000000.000000
X( 1, 2)1.0000000.000000
X( 1, 3)0.0000000.000000
X( 1, 4)0.0000000.000000
X( 1, 5)0.0000000.000000
X( 1, 6)1.0000000.000000
X( 1, 7)1.0000000.000000
X( 2, 1)0.0000000.000000
X( 2, 2)0.0000000.000000
X( 2, 3)1.0000000.000000
X( 2, 4)1.0000000.000000
X( 2, 5)0.0000000.000000
X( 2, 6)0.0000000.000000
X( 2, 7)0.0000000.000000
X( 3, 1)1.0000000.000000
X( 3, 2)0.0000000.000000
X( 3, 3)0.0000000.000000
X( 3, 4)0.0000000.000000
X( 3, 5)1.0000000.000000
X( 3, 6)0.0000000.000000
X( 3, 7)0.0000000.000000
就是说1号消防站派车到2 6 7
2号到3 4
3号到1 5
使用LINGO软件计算6个发点8个收点的最小费用运输问题。产销单位运价如下表。单
位销地
运
价
产地 B1 B2 B3 B4 B5 B6 B7 B8 产量
A1 6 2 6 7 4 2 5 9 60
A2 4 9 5 3 8 5 8 2 55
A3 5 2 1 9 7 4 3 3 51
A4 7 6 7 3 9 2 7 1 43
A5 2 3 9 5 7 2 6 5 41
A6 5 5 2 2 8 1 4 3 52
销量 35 37 22 32 41 32 43 38
首先建立该该问题的数学模型,设上表中6*8矩阵记为C, , , 为从i地到j地的运量。则数学模型为:
使用LINGO软件,编制程序如下:
model:
!6发点8收点运输问题
sets:
warehouses/wh1..wh6/: capacity
vendors/v1..v8/: demand
links(warehouses,vendors): cost, volume
endsets
!目标函数
min=@sum(links: cost*volume)
!需求约束
@for(vendors(J):
@sum(warehouses(I): volume(I,J))=demand(J))
!产量约束
@for(warehouses(I):
@sum(vendors(J): volume(I,J))<=capacity(I))
!这里是数据
data:
capacity=60 55 51 43 41 52
demand=35 37 22 32 41 32 43 38
cost=6 2 6 7 4 2 9 5
4 9 5 3 8 5 8 2
5 2 1 9 7 4 3 3
7 6 7 3 9 2 7 1
2 3 9 5 7 2 6 5
5 5 2 2 8 1 4 3
enddata
end
这样写 其中x表示的是两个人是否配对model:
sets:
student/1..8/
match(student,student)|&1#lt#&2:cost,x
endsets
data:
cost=
9 3 4 2 1 5 6
7 3 5 2 1
4 4 2 9 2
1 5 5 2
8 7 6
2 3
4
enddata
min=@sum(match:cost*x)
@for(student(i):@sum(student(j)|@in(match,i,j):x(i,j))+@sum(student(j)|@in(match,j,i):x(j,i))=1)
end
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)