实验三:利用Lingo解一个具体的运输问题例子11、实验目的和任务1.1.进一步掌握Lingo编程操作;1.2通过实验进一步掌握运筹学运输问题的建模以及求解过程,提高学生分析问题和解决问题能力。2、实验仪器、设备及材料计算机、Lingo3、实验内容运输问题问题P271设有某种物资需要从m个产地12,,...,mAAA运到n个销地12,,...,nBBB,其中每个产地的生产量为12,,...,maaa,每个销地的需求量为12,,...,nbbb。设从产地iA到销地jB的运费单价为(1,2,...,,1,2,...,),ijcimjn,问如何调运可使总运费最少?3个产地4个销地的运输问题1B2B3B4B产量1A6267302A4953253A881521销量15172212建模决策变量:决策变量就是产地iA到销地jB的运量ijx目标函数:11minmnijijijzcx,约束条件:第i个产地的运出量应小于或等于该地的生产量,即1,1,2,...,.nijijxaim第j个销地的运入量应等于该地的需求量,即实验三:利用Lingo解一个具体的运输问题例子21,1,2,....mijjixbjn求解过程编写模型程序:model:!3Warehouse,4CustomerTransportationProblem;sets:Warehouse/1..3/:a;Customer/1..4/:b;Routes(warehouse,customer):c,x;endsets!herearetheparameters;data:a=30,25,21;b=15,17,22,12;c=6,2,6,7,4,9,5,3,8,8,1,5;enddata!Theobjective;[obj]min=@sum(routes:c*x);!Thesupplyconstraints;@for(warehouse(i):[sup]@sum(customer(j):x(i,j))=a(i));!Thedemandconstraints;@for(customer(j):[dem]@sum(warehouse(i):x(i,j))=b(j));end计算结果:Globaloptimalsolutionfound.Objectivevalue:161.0000Totalsolveriterations:6VariableValueReducedCostA(1)30.000000.000000A(2)25.000000.000000A(3)21.000000.000000B(1)15.000000.000000B(2)17.000000.000000B(3)22.000000.000000实验三:利用Lingo解一个具体的运输问题例子3B(4)12.000000.000000C(1,1)6.0000000.000000C(1,2)2.0000000.000000C(1,3)6.0000000.000000C(1,4)7.0000000.000000C(2,1)4.0000000.000000C(2,2)9.0000000.000000C(2,3)5.0000000.000000C(2,4)3.0000000.000000C(3,1)8.0000000.000000C(3,2)8.0000000.000000C(3,3)1.0000000.000000C(3,4)5.0000000.000000X(1,1)2.0000000.000000X(1,2)17.000000.000000X(1,3)1.0000000.000000X(1,4)0.0000002.000000X(2,1)13.000000.000000X(2,2)0.0000009.000000X(2,3)0.0000001.000000X(2,4)12.000000.000000X(3,1)0.0000007.000000X(3,2)0.00000011.00000X(3,3)21.000000.000000X(3,4)0.0000005.000000RowSlackorSurplusDualPriceOBJ161.0000-1.000000SUP(1)10.000000.000000SUP(2)0.0000002.000000SUP(3)0.0000005.000000DEM(1)0.000000-6.000000DEM(2)0.000000-2.000000DEM(3)0.000000-6.000000事实上,我们关心更多的是那些非零变量,因此,可选择“Lingo|solution..”弹出一个对话框(介绍此对话框),选择“nonzerosonly”,即可只列出非零变量:Globaloptimalsolutionfound.Objectivevalue:161.0000Totalsolveriterations:6VariableValueReducedCost实验三:利用Lingo解一个具体的运输问题例子4A(1)30.000000.000000A(2)25.000000.000000A(3)21.000000.000000B(1)15.000000.000000B(2)17.000000.000000B(3)22.000000.000000B(4)12.000000.000000C(1,1)6.0000000.000000C(1,2)2.0000000.000000C(1,3)6.0000000.000000C(1,4)7.0000000.000000C(2,1)4.0000000.000000C(2,2)9.0000000.000000C(2,3)5.0000000.000000C(2,4)3.0000000.000000C(3,1)8.0000000.000000C(3,2)8.0000000.000000C(3,3)1.0000000.000000C(3,4)5.0000000.000000X(1,1)2.0000000.000000X(1,2)17.000000.000000X(1,3)1.0000000.000000X(2,1)13.000000.000000X(2,4)12.000000.000000X(3,3)21.000000.000000RowSlackorSurplusDualPriceSUP(2)0.0000002.000000SUP(3)0.0000005.000000DEM(1)0.000000-6.000000DEM(2)0.000000-2.000000DEM(3)0.000000-6.000000DEM(4)0.000000-5.000000结果分析由于Lingo软件中采用集,数据段和循环函数的编写方式,因此便于程序推广到一般形式使用,例如,只需修改运输问题中产地和销地的个数,以及参数a,b,c的值,就可以求解任何运输问题。4、实验要求试用Lingo求解课本P99的第5题,并把相关模型程序和结果填在实验报告中。