数学建模课后作业第五章.docx
《数学建模课后作业第五章.docx》由会员分享,可在线阅读,更多相关《数学建模课后作业第五章.docx(41页珍藏版)》请在冰豆网上搜索。
数学建模课后作业第五章
第五章.图论组合优化实验
5.2.基本实验
1.最短路问题的应用——设备更新问题
解:
令xi为表示第i年初购买一台新设备,令(xi,xj)为第i年初购买用到第j年初的设备,令xij为第i年到j年所支付的总费用。
可得:
(x1,x2)x12=2.5+0.3-2=0.8;
(x1,x3)x13=2.5+0.3+0.5-1.6=1.7;
(x1,x4)x14=2.5+0.3+0.5+0.8-1.3=2.8;
(x1,x5)x15=2.5+0.3+0.5+0.8+1.2-1.1=4.2;
(x2,x3)x23=2.6+0.3-2=0.9;
(x2,x4)x24=2.6+0.3+0.5-1.6=1.8;
(x2,x5)x25=2.6+0.3+0.5+0.8-1.3=2.9;
(x3,x4)x34=2.8+0.3-2=1.1;
(x3,x5)x35=2.8+0.3+0.5-1.6=2.0;
(x4,x5)x45=3.1+0.3-2=1.4;
从第一年初到第五年初的费用为:
(1)x12+x25=0.8+2.9=3.7;
x12+x24+x45=0.8+1.8+1.4=4;
x12+x23+x35=0.8+0.9+2=3.7;
x12+x23+x34+x45=0.8+0.9+1.1+1.4=4.2;
(2)x14+x45=2.8+1.4=4.2;
x13+x34+x45=1.7+1.1+1.4=4.2,
(3)x13+x35=1.7+2.0=3.7;
(4)x15=4.2;
由以上的结果可知最少的支出费用为
x13+x35=1.7+2.0=3.7万元;
x12+x23+x35=0.8+0.9+2=3.7万元;
x12+x25=0.8+2.9=3.7万元;
2.生产计划与库存管理
解:
(1)设x1、x2、x3、x4为第一、二、三、四季度生产量,则可以得出第第一、二、三、四季度支出费用为
第一季度费用z1:
5*x1+(x1-10);
第二季度费用z2:
5*x2+(x1+x2-24);
第三季度费用z3:
6*x3+(x1+x2+x3-44);
第四季度费用z4:
6*x4+(x1+x2+x3+x4-52);
总的支出费用为:
Z=z1+z2+z3+z4=9x1+8x2+8x3+7x4-130;
约束条件为:
x1+x2+x3+x4=52;
x1<=14;
x1>=10;
x2<=15;
x1+x2>=24;
x3<=15;
x1+x2+x3>=44;
x4<=13;
可以得出lingo程序如下:
min=9*x1+8*x2+8*x3+7*x4-130;
x1+x2+x3+x4=52;
x1<=14;
x1>=10;
x2<=15;
x1+x2>=24;
x3<=15;
x1+x2+x3>=44;
x4<=13;
运行程序后可得:
Globaloptimalsolutionfound.
Objectivevalue:
292.0000
Infeasibilities:
0.000000
Totalsolveriterations:
0
ModelClass:
LP
Totalvariables:
4
Nonlinearvariables:
0
Integervariables:
0
Totalconstraints:
9
Nonlinearconstraints:
0
Totalnonzeros:
18
Nonlinearnonzeros:
0
VariableValueReducedCost
X114.000000.000000
X215.000000.000000
X315.000000.000000
X48.0000000.000000
RowSlackorSurplusDualPrice
1292.0000-1.000000
20.000000-7.000000
30.0000000.000000
44.0000000.000000
50.0000001.000000
65.0000000.000000
70.0000001.000000
80.000000-2.000000
95.0000000.000000则可得x1=14,x2=15,x3=15,x4=8;
即第一季度生产14万盒,
第二季度生产15万盒,
第三季度15万盒,
第四季度为8万盒。
总的支出费用为292万元。
(2)由题目可得新的lingo程序:
min=7*x1+6*x2+6*x3+6*x4-31;
x1+x2+x3+x4=52;
x1<=13;
x1>=10;
x2<=15;
x1+x2>=24;
x3<=15;
x1+x2+x3>=43;
x4<=13;
运行程序之后可得:
Globaloptimalsolutionfound.
Objectivevalue:
294.0000
Infeasibilities:
0.000000
Totalsolveriterations:
0
ModelClass:
LP
Totalvariables:
4
Nonlinearvariables:
0
Integervariables:
0
Totalconstraints:
9
Nonlinearconstraints:
0
Totalnonzeros:
18
Nonlinearnonzeros:
0
VariableValueReducedCost
X113.000000.000000
X215.000000.000000
X315.000000.000000
X49.0000000.000000
RowSlackorSurplusDualPrice
1294.0000-1.000000
20.000000-6.000000
30.0000000.000000
43.0000000.000000
50.0000001.000000
64.0000000.000000
70.0000001.000000
80.000000-1.000000
94.0000000.000000
可得x1=13,x2=15,x3=15,x4=9;
即第一季度生产13万盒,
第二季度生产15万盒,
第三季度15万盒,
第四季度为9万盒。
总的支出费用为294万元。
(3)设第一季度加班生产的产品为x11盒,
第一季度加班生产的产品为x21盒,
第一季度加班生产的产品为x31盒,
第一季度加班生产的产品为x41盒,
则可以得到新的lingo程序:
min=8*x1+9*x11+7*x2+8*x21+7*x3+8.2*x31+6*x4+7.2*x41-78;
x1+x11+x2+x21+x3+x31+x4+x41=52;
x1<=13;
x1+x11>=10;
x2<=15;
x1+x2+x11+x21>=24;
x3<=15;
x1+x2+x3+x11+x21+x31>=44;
x4<=13;
运行程序可得:
Globaloptimalsolutionfound.
Objectivevalue:
292.0000
Infeasibilities:
0.000000
Totalsolveriterations:
2
ModelClass:
LP
Totalvariables:
8
Nonlinearvariables:
0
Integervariables:
0
Totalconstraints:
9
Nonlinearconstraints:
0
Totalnonzeros:
32
Nonlinearnonzeros:
0
VariableValueReducedCost
X113.000000.000000
X110.0000001.000000
X215.000000.000000
X211.0000000.000000
X315.000000.000000
X310.0000000.2000000
X48.0000000.000000
X410.0000001.200000
RowSlackorSurplusDualPrice
1292.0000-1.000000
20.000000-6.000000
30.0000000.000000
43.0000000.000000
50.0000001.000000
65.0000000.000000
70.0000001.000000
80.000000-2.000000
95.0000000.000000
则可以得出新的生产方案为:
则可得x1=13,x21=1,x2=15,x3=15,x4=8;
即第一季度生产13万盒,
第二季度生产15万盒,
第二季度加班生产的产品为1万盒,
第三季度15万盒,
第四季度为8万盒。
(4)设第一季度加班生产的产品为x11盒,
第一季度加班生产的产品为x21盒,
第一季度加班生产的产品为x31盒,
第一季度加班生产的产品为x41盒,
可以得到新的lingo程序:
min=8*x1+9*x11+7*x2+8*x21+7*x3+8.2*x31+6*x4+7.2*x41-77;
x1+x11+x2+x21+x3+x31+x4+x41=52;
x1<=13;
x1+x11>=10;
x2<=15;
x1+x2+x11+x21>=24;
x3<=15;
x1+x2+x3+x11+x21+x31>=44;
x4<=13;
Globaloptimalsolutionfound.
Objectivevalue:
293.0000
Infeasibilities:
0.000000
Totalsolveriterations:
2
ModelClass:
LP
Totalvariables:
8
Nonlinearvariables:
0
Integervariables:
0
Totalconstraints:
9
Nonlinearconstraints:
0
Totalnonzeros:
32
Nonlinearnonzeros:
0
VariableValueReducedCost
X113.000000.000000
X110.0000001.000000
X215.000000.000000
X211.0000000.000000
X315.000000.000000
X310.0000000.2000000
X48.0000000.000000
X410.0000001.200000
RowSlackorSurplusDualPrice
1293.0000-1.000000
20.000000-6.000000
30.0000000.000000
43.0000000.000000
50.0000001.000000
65.0000000.000000
70.0000001.000000
80.000000-2.000000
95.0000000.000000
3.指派问题
解:
由此转换问题的解决方案分别为
(1)甲(worker1)(worker5)完成两项任务,乙(worker2)丙(worker3)丁(worker4)各完成一项任务;可以得出如下的lingo程序:
model:
sets:
worker/w1..w5/;
job/j1..j5/;
links(worker,job):
c,x;
endsets
data:
c=2529314237
3938262033
3427284032
2442362345
2529314237;
enddata
min=@sum(links:
c*x);
@for(worker(i):
@sum(job(j):
x(i,j))=1);
@for(job(j):
@sum(worker(i):
x(i,j))=1);
@for(links:
@bin(x));
End
运行程序后可得:
Globaloptimalsolutionfound.
Objectivevalue:
135.0000
Objectivebound:
135.0000
Infeasibilities:
0.000000
Extendedsolversteps:
0
Totalsolveriterations:
0
ModelClass:
PILP
Totalvariables:
25
Nonlinearvariables:
0
Integervariables:
25
Totalconstraints:
11
Nonlinearconstraints:
0
Totalnonzeros:
75
Nonlinearnonzeros:
0
VariableValueReducedCost
C(W1,J1)25.000000.000000
C(W1,J2)29.000000.000000
C(W1,J3)31.000000.000000
C(W1,J4)42.000000.000000
C(W1,J5)37.000000.000000
C(W2,J1)39.000000.000000
C(W2,J2)38.000000.000000
C(W2,J3)26.000000.000000
C(W2,J4)20.000000.000000
C(W2,J5)33.000000.000000
C(W3,J1)34.000000.000000
C(W3,J2)27.000000.000000
C(W3,J3)28.000000.000000
C(W3,J4)40.000000.000000
C(W3,J5)32.000000.000000
C(W4,J1)24.000000.000000
C(W4,J2)42.000000.000000
C(W4,J3)36.000000.000000
C(W4,J4)23.000000.000000
C(W4,J5)45.000000.000000
C(W5,J1)25.000000.000000
C(W5,J2)29.000000.000000
C(W5,J3)31.000000.000000
C(W5,J4)42.000000.000000
C(W5,J5)37.000000.000000
X(W1,J1)0.00000025.00000
X(W1,J2)1.00000029.00000
X(W1,J3)0.00000031.00000
X(W1,J4)0.00000042.00000
X(W1,J5)0.00000037.00000
X(W2,J1)0.00000039.00000
X(W2,J2)0.00000038.00000
X(W2,J3)1.00000026.00000
X(W2,J4)0.00000020.00000
X(W2,J5)0.00000033.00000
X(W3,J1)0.00000034.00000
X(W3,J2)0.00000027.00000
X(W3,J3)0.00000028.00000
X(W3,J4)0.00000040.00000
X(W3,J5)1.00000032.00000
X(W4,J1)0.00000024.00000
X(W4,J2)0.00000042.00000
X(W4,J3)0.00000036.00000
X(W4,J4)1.00000023.00000
X(W4,J5)0.00000045.00000
X(W5,J1)1.00000025.00000
X(W5,J2)0.00000029.00000
X(W5,J3)0.00000031.00000
X(W5,J4)0.00000042.00000
X(W5,J5)0.00000037.00000
RowSlackorSurplusDualPrice
1135.0000-1.000000
20.0000000.000000
30.0000000.000000
40.0000000.000000
50.0000000.000000
60.0000000.000000
70.0000000.000000
80.0000000.000000
90.0000000.000000
100.0000000.000000
110.0000000.000000
可以得出:
甲完成A、B两个任务,乙完成C任务,丙完成E任务,丁完成D任务,花费的时间最短时间为135。
(2)乙(worker2)(worker5)完成两项任务,甲(worker1)丙(worker3)丁(worker4)各完成一项任务;可以得出如下的lingo程序:
model:
sets:
worker/w1..w5/;
job/j1..j5/;
links(worker,job):
c,x;
endsets
data:
c=2529314237
3938262033
3427284032
2442362345
3938262033;
enddata
min=@sum(links:
c*x);
@for(worker(i):
@sum(job(j):
x(i,j))=1);
@for(job(j):
@sum(worker(i):
x(i,j))=1);
@for(links:
@bin(x));
End
运行程序可以得出:
Globaloptimalsolutionfound.
Objectivevalue:
131.0000
Objectivebound:
131.0000
Infeasibilities:
0.000000
Extendedsolversteps:
0
Totalsolveriterations:
0
ModelClass:
PILP
Totalvariables:
25
Nonlinearvariables:
0
Integervariables:
25
Totalconstraints:
11
Nonlinearconstraints:
0
Totalnonzeros:
75
Nonlinearnonzeros:
0
VariableValueReducedCost
C(W1,J1)25.000000.000000
C(W1,J2)29.000000.000000
C(W1,J3)31.000000.000000
C(W1,J4)42.000000.000000
C(W1,J5)37.000000.000000
C(W2,J1)39.000000.000000
C(W2,J2)38.000000.000000
C(W2,J3)26.000000.000000
C(W2,J4)20.000000.000000
C(W2,J5)33.000000.000000
C(W3,J1)34.000000.000000
C(W3,J2)27.000000.000000
C(W3,J3)28.000000.000000
C(W3,J4)40.000000.000000
C(W3,J5)32.000000.000000
C(W4,J1)24.000000.000000
C(W4,J2)42.000000.000000
C(W4,J3)36.000000.000000
C(W4,J4)23.000000.000000
C(W4,J5)45.000000.000000
C(W5,J1)39.000000.000000
C(W5,J2)38.000000.000000
C(W5,J3)26.000000.000000
C(W5,J4)20.000000.000000
C(W5,J5)33.000000.000000
X(W1,J1)0.00000025.00000
X(W1,J2)1.00000029.00000
X(W1,J3)0.00000031.00000
X(W1,J4)0.00000042.00000
X(W1,J5)0.00000037.00000
X(W2,J1)0.00000039.00000
X(W2,J2)0.00000038.00000
X(W2,J3)1.00000026.00000
X(W2,J4)0.00000020.00000
X(W2,J5)0.00000033.00000
X(W3,J1)0.00000034.00000
X(W3,J2)0.00000027.00000
X(W3,J3)0.00000028.00000
X(W3,J4)0.00000040.00000
X(W3,J5)1.00000032.00000
X(W4,J1)1.00000024.00000
X(W4,