资源描述
数学建模作业
(实验6 图论(组合优化)实验)
基本实验
1.设备更新问题
某公司需要对一台已经使用了2年的机器确定今后4年(n=4)的最优更新策略.公司要求,用了6年的机器必须更新,购买一台新机器的价格是100万元,表6.1给出了该问题的数据,请给出设备的更新策略。
解答
解:用图论知识来理解此题。
设用A,B…表示决策年度,用数字表示机龄,因此,第1年决策的节点就是A2,第2年只有两种可能,就是B3(第1年不更新)或B1(第1年更新),以此类推。
LINGO程序
sets:
nodes/A2, B3, B1, C4, C2, C1, D5, D3, D2, D1,E6,
E4, E3, E2, E1, F/;
arcs(nodes, nodes)/ A2,B3 A2,B1
B3,C4 B3,C1 B1,C2 B1,C1
C4,D5 C4,D1 C2,D3 C2,D1 C1,D2 C1,D1
D5,E1 D5,E6 D3,E4 D3,E1 D2,E3 D2,E1 D1,E2 D1,E1
E6,F E4,F E3,F E2, F E1,F /: c, x;
endsets
data:
c = 17.3 -20.2 15.7 -30.2 18.4 -0.2 13.8 -50.2 17.3 -20.2 18.4 -0.2 12.2 -70.2 15.7 -30.2 17.3 -20.2 18.4 -0.2 5 30 50 60 80;
enddata
n = @size(nodes);
max = @sum(arcs: c * x);
@sum(arcs(i,j)| i #eq# 1 : x(i,j)) = 1;@for(nodes(i)| i #ne# 1 #and# i #ne# n:@sum(arcs(i,j): x(i,j)) - @sum(arcs(j,i): x(j,i))=0);
@sum(arcs(j,i)| i #eq# n : x(j,i)) = 1;@for(arcs: @bin(x));
运行结果
Global optimal solution found.
Objective value: 139.0000
Objective bound: 139.0000
Infeasibilities: 0.000000
Extended solver steps: 0
Total solver iterations: 0
Model Class: PILP
Total variables: 25
Nonlinear variables: 0
Integer variables: 25
Total constraints: 17
Nonlinear constraints: 0
Total nonzeros: 75
Nonlinear nonzeros: 0
Variable Value Reduced Cost
N 16.00000 0.000000
C( A2, B3) 17.30000 0.000000
C( A2, B1) -20.20000 0.000000
C( B3, C4) 15.70000 0.000000
C( B3, C1) -30.20000 0.000000
C( B1, C2) 18.40000 0.000000
C( B1, C1) -0.2000000 0.000000
C( C4, D5) 13.80000 0.000000
C( C4, D1) -50.20000 0.000000
C( C2, D3) 17.30000 0.000000
C( C2, D1) -20.20000 0.000000
C( C1, D2) 18.40000 0.000000
C( C1, D1) -0.2000000 0.000000
C( D5, E1) 12.20000 0.000000
C( D5, E6) -70.20000 0.000000
C( D3, E4) 15.70000 0.000000
C( D3, E1) -30.20000 0.000000
C( D2, E3) 17.30000 0.000000
C( D2, E1) -20.20000 0.000000
C( D1, E2) 18.40000 0.000000
C( D1, E1) -0.2000000 0.000000
C( E6, F) 5.000000 0.000000
C( E4, F) 30.00000 0.000000
C( E3, F) 50.00000 0.000000
C( E2, F) 60.00000 0.000000
C( E1, F) 80.00000 0.000000
X( A2, B3) 1.000000 -17.30000
X( B3, C4) 1.000000 -15.70000
X( C4, D5) 1.000000 -13.80000
X( D5, E1) 1.000000 -12.20000
X( E1, F) 1.000000 -80.00000
Row Slack or Surplus Dual Price
1 0.000000 0.000000
3 0.000000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000000
7 0.000000 0.000000
8 0.000000 0.000000
9 0.000000 0.000000
10 0.000000 0.000000
11 0.000000 0.000000
12 0.000000 0.000000
13 0.000000 0.000000
14 0.000000 0.000000
15 0.000000 0.000000
16 0.000000 0.000000
17 0.000000 0.000000
18 0.000000 0.000000
由运行结果可得:
最佳的路径为A2-B3-C4-D5-E1-F,设备的最优更新策略应该是使用5年。
2.运输问题
有甲、乙和丙三个城市,每年分别需要煤炭320万吨、250万吨和350万吨,由A, B两个煤矿负责供应.已知煤矿年产量A为400万吨,B为450万吨,从两煤矿至各城市煤炭运价如表6.2所示.由于需求大于供应,经协商平衡,甲城市在必要时可少供应0-30万吨,乙城市需求量须全部满足,丙城市需求量不少于270万吨。试求将甲、乙两矿煤炭全部分配出去,满足上述条件又使总运费最低的调运方案。
解答
解:根据题意可得:
煤矿的总需求为320+250+350=920;总产量为400+450=850;因此,增加一个虚拟产地C,产量为70;
根据下面的模型可得LINGO程序为:
LINGO程序
sets:
From / A, B/: Capacity;
To/ C1, C2, C3/: Demand;
Routes( From, To): D, x;
endsets
data:
Capacity =400,450;
Demand = 320,250,380 ;
D =15,18,22,21,25,16;
Enddata
min = @sum(Routes: D * x);
@for (From(i): [SUP] @sum (To(j): x(i,j)) <= Capacity(i));
@for (To(j): [DEM] @sum (From(i): x(i,j)) >= Demand(j));
运行结果
No feasible solution found.
Infeasibilities: 100.0000
Total solver iterations: 4
Model Class: LP
Total variables: 6
Nonlinear variables: 0
Integer variables: 0
Total constraints: 6
Nonlinear constraints: 0
Total nonzeros: 18
Nonlinear nonzeros: 0
Variable Value Reduced Cost
CAPACITY( A) 400.0000 0.000000
CAPACITY( B) 450.0000 0.000000
DEMAND( C1) 320.0000 0.000000
DEMAND( C2) 250.0000 0.000000
DEMAND( C3) 380.0000 0.000000
D( A, C1) 15.00000 0.000000
D( A, C2) 18.00000 0.000000
D( A, C3) 22.00000 0.000000
D( B, C1) 21.00000 0.000000
D( B, C2) 25.00000 0.000000
D( B, C3) 16.00000 0.000000
X( A, C1) 150.0000 0.000000
X( A, C2) 250.0000 0.000000
X( B, C1) 170.0000 0.000000
X( B, C3) 380.0000 0.000000
Row Slack or Surplus Dual Price
SUP( A) 0.000000 6.000000
DEM( C1) 0.000000 -21.00000
DEM( C2) 0.000000 -24.00000
DEM( C3) 0.000000 -16.00000
由运行结果可得:
由A矿向甲乙丙三座城市的送矿量(万吨)为150、250、0;由B矿向甲乙丙三座城市的送矿量(万吨)为140、0、310。
此时总运输费最小为:
150*15+250*18+140*21+270*16+40*16+30*0+40*0=14650万元。
3.生产计划与库存管理
(1)某公司生产一种除臭剂,它在1至4季度的生产成本、生产量及订货量表4.3所示。如果除臭剂在生产当季没有交货,保管在仓库里除臭剂每盒每季度还需1元钱的储存费用。如果某个季度的货物供应量不足,则允许延期交货,延期交货的罚金是每盒每季度3元。请公司希望制定一个成本最低(包括储存费用和罚金)的除臭剂的生产计划,问各季度应生产多少?
(2)如果产品不允许延期交货,则公司考虑工人加班,已知加班生产出产品的成本要比原成本高出20%,且每季度加班最多生产2万盒。问:在这种情况下,将如何安排生产,使总成本最少?
解答
解:(1)根据题意可得:
设cij为从季度生产Ai到季度需求Bj的配送单价,xij为从季度生产Ai到季度需求Bj的运输量,因此总的费用为:
第i个季度的运出量应该小于或等于该季度的生产量:
第j个季度的运入量应该等于该季度的需求量:
LINGO程序
sets:
Warehouse /1..4/: a;
Customer /1..4/: b;
Routes(Warehouse, Customer): c, x;
Endsets
data:
a= 13, 15, 15, 13 ;
b= 10, 14, 20, 8 ;
c = 5, 6, 7, 8,
8, 5, 6, 7,
12, 9, 6, 7,
15, 12, 9, 6;
Enddata
min = @sum(Routes: c * x);
@for(Warehouse(i): [SUP]
@sum(Customer(j): x(i,j))<= a(i));
@for(Customer(j): [DEM]
@sum(Warehouse(i): x(i,j))= b(j));
运行结果
Global optimal solution found.
Objective value: 294.0000
Infeasibilities: 0.000000
Total solver iterations: 7
Model Class: LP
Total variables: 16
Nonlinear variables: 0
Integer variables: 0
Total constraints: 9
Nonlinear constraints: 0
Total nonzeros: 48
Nonlinear nonzeros: 0
Variable Value Reduced Cost
A( 1) 13.00000 0.000000
A( 2) 15.00000 0.000000
A( 3) 15.00000 0.000000
A( 4) 13.00000 0.000000
B( 1) 10.00000 0.000000
B( 2) 14.00000 0.000000
B( 3) 20.00000 0.000000
B( 4) 8.000000 0.000000
C( 1, 1) 5.000000 0.000000
C( 1, 2) 6.000000 0.000000
C( 1, 3) 7.000000 0.000000
C( 1, 4) 8.000000 0.000000
C( 2, 1) 8.000000 0.000000
C( 2, 2) 5.000000 0.000000
C( 2, 3) 6.000000 0.000000
C( 2, 4) 7.000000 0.000000
C( 3, 1) 12.00000 0.000000
C( 3, 2) 9.000000 0.000000
C( 3, 3) 6.000000 0.000000
C( 3, 4) 7.000000 0.000000
C( 4, 1) 15.00000 0.000000
C( 4, 2) 12.00000 0.000000
C( 4, 3) 9.000000 0.000000
C( 4, 4) 6.000000 0.000000
X( 1, 1) 10.00000 0.000000
X( 1, 2) 3.000000 0.000000
X( 2, 2) 11.00000 0.000000
X( 2, 3) 4.000000 0.000000
X( 3, 3) 15.00000 0.000000
X( 4, 3) 1.000000 0.000000
X( 4, 4) 8.000000 0.000000
Row Slack or Surplus Dual Price
SUP( 1) 0.000000 2.000000
SUP( 2) 0.000000 3.000000
SUP( 3) 0.000000 3.000000
DEM( 1) 0.000000 -7.000000
DEM( 2) 0.000000 -8.000000
DEM( 3) 0.000000 -9.000000
DEM( 4) 0.000000 -6.000000
由运行结果可得:
第一季度生产13万盒,拿出10万盒满足第一季度要求,库存3万盒,不拖欠;第二季度生产15万盒,拿出11万盒,连同第一季度库存3万盒加起来为14万盒满足第二季度要求,库存4万盒,不拖欠;第三季度生产15万盒,全部拿出,连同第二季度库存4万盒加起来19万盒,拖欠1万盒;第四季度生产9万盒,还清第三季度拖欠1万盒,剩下8万盒满足第四季度需求。此方案下总成本最小,为294万元。
(2)根据题意可得:
如果考虑工人加班,可以将工人加班的费用视为除本季生产外为接下来其他季度供应货物的费用,只需将每季度生产量扩充2万盒即可。
LINGO程序
sets:
Warehouse /1..4/: a;
Customer /1..4/: b;
Routes(Warehouse, Customer): c, x;
Endsets
data:
a= 15, 17, 17, 15 ;
b= 10, 14, 20, 8 ;
c = 5, 6, 6, 6,
100000, 5, 6, 6,
1000000, 1000000, 6, 7.2,
1000000, 1000000, 1000000, 6;
Enddata
min = @sum(Routes: c * x);
@for(Warehouse(i): [SUP]
@sum(Customer(j): x(i,j))<= a(i));
@for(Customer(j): [DEM]
@sum(Warehouse(i): x(i,j))= b(j));
end
运行结果
Global optimal solution found.
Objective value: 288.0000
Infeasibilities: 0.000000
Total solver iterations: 8
Model Class: LP
Total variables: 16
Nonlinear variables: 0
Integer variables: 0
Total constraints: 9
Nonlinear constraints: 0
Total nonzeros: 48
Nonlinear nonzeros: 0
Variable Value Reduced Cost
A( 1) 15.00000 0.000000
A( 2) 17.00000 0.000000
A( 3) 17.00000 0.000000
A( 4) 15.00000 0.000000
B( 1) 10.00000 0.000000
B( 2) 14.00000 0.000000
B( 3)
展开阅读全文