您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 咨询培训 > 数学建模lingo培训程序
1·数学建模讲义例题例1:max=2*x+3*y;4*x+3*y10;3*x+5*y12;(1,有max=(或min=),2,每行后面均有一个分号“;”,3,系数与变量间有“*”,4,首行可增添:”model:”,末行增添”end”。)Globaloptimalsolutionfound.Objectivevalue:7.454545Infeasibilities:0.000000Totalsolveriterations:2VariableValueReducedCostX1.2727270.000000Y1.6363640.000000RowSlackorSurplusDualPrice17.4545451.00000020.0000000.9090909E-0130.0000000.5454545例2:LINGO模型构成的4个段:(1)集合段(2)数据段(3)初始段(4)目标与约束段TitleLocationproblem;sets:demand/1..6/:a,b,c;supply/1..2/:x,y,e;link(demand,supply):d;endsetsdata:a=1.25,8.75,0.5,5.75,3,7.25;b=1.25,0.75,4.75,5,6.5,7.75;c=3,5,4,7,6,11;e=20,20;enddatainit:x,y=5,1,2,7;endinit[obj]min=@sum(link(i,j):d(i,j)*((x(j)-a(i))^2+(y(j)-b(i))^2)^(1/2));@for(demand(i):[demand_con]@sum(supply(j):d(i,j)));@for(supply(i):[supply_con]@sum(demand(j):d(j,i))=e(i));end2例3:注意属性值的个数必须等于集成员的个数(!...;)。在数据声明中输入两个相连的逗号表示该位置对应的集成员的属性值未知,两个逗号间可以有空格。sets:set1/A,B,C/:X,Y;endsetsdata:X=1,2,3;y=4,5,6;EnddataFeasiblesolutionfound.Totalsolveriterations:0VariableValueX(A)1.000000X(B)2.000000X(C)3.000000Y(A)4.000000Y(B)5.000000Y(C)6.000000例4:给定一个直角三角形,求包含该三角形的最小正方形。则如图可推知:sets:object/1..3/:f;endsetsdata:a,b=3,4;enddataf(1)=a*@sin(x);f(2)=b*@cos(x);f(3)=a*@cos(x)+b*@sin(x);min=@smax(f(1),f(2),f(3));@bnd(0,x,1.57);Localoptimalsolutionfound.Objectivevalue:3.880570Objectivebound:3.880570Infeasibilities:0.5370432E-07Extendedsolversteps:1Totalsolveriterations:38VariableValueReducedCostA3.0000000.000000B4.0000000.000000X0.24497870.000000F(1)0.72760690.0000003F(2)3.8805700.000000F(3)3.8805700.000000例5:求向量[5,1,3,4,6,10]前5个数最小值,后3个数最大值。sets:number/1..6/:x;endsetsdata:x=5134610;enddataminv=@min(number(i)|i#le#5:x);!或者minv=@smin(x1(1),x(2),x(3),x(4),x(5));maxv=@max(number(i)|i#ge#4:x);!或者maxv=@smax(x(4),x(5),x(6));endFeasiblesolutionfound.Totalsolveriterations:0VariableValueMINV1.000000MAXV10.00000X(1)5.000000X(2)1.000000X(3)3.000000X(4)4.000000X(5)6.000000X(6)10.00000例6:加工奶制品的生产计划。则设:x1桶牛奶生产A1x2桶牛奶生产A2获利24*3*x1与16*4*x2约束条件为:x1+x2=50;12*x1+8*x2=480;3*x1=100;x1,x2=0。4每天获利:Maxz=72*x1+64*x2model:max=72*x1+64*x2;x1+x250;12*x1+8*x2480;3*x1100;endGlobaloptimalsolutionfound.Objectivevalue:3360.000Infeasibilities:0.000000Totalsolveriterations:2VariableValueReducedCostX120.000000.000000X230.000000.000000RowSlackorSurplusDualPrice13360.0001.00000020.00000048.0000030.0000002.000000440.000000.0000005例7:求解问题:求minf(x)+g(y);0x2x,0x,2x100f(x)20,20,360)(yyyyxg30yxmodel:min=fx+fy;fx=@if(x#gt#0,100+2*x^2,2*x)+0;fy=@if(y#gt#0,60,-y)+3*y;X+y=30;EndLinearizationcomponentsadded:Constraints:30Variables:16Integers:12Localoptimalsolutionfound.Objectivevalue:0.000000Objectivebound:0.000000Infeasibilities:0.000000Extendedsolversteps:0Totalsolveriterations:13VariableValueReducedCostFX0.0000001.000000FY0.0000001.000000X0.0000000.000000Y0.0000000.0000006例8.1:即求:21612/122])()[(minjiijijijbyaxc由:6,...,1,21idciijj2,1,61jecjijisets:demand/1..6/:a,b,d;supply/1..2/:x,y,e;link(demand,supply):c;endsetsdata:a=1.258.750.55.7537.25;b=1.250.754.7556.57.75;d=3547611;e=20,20;x,y=5,12,7;enddatainit:endinit[obj]min=@sum(link(i,j):c(i,j)*((x(j)-a(i))^2+(y(j)-b(i))^2)^(1/2));@for(demand(i):[demand_con]@sum(supply(j):c(i,j))=d(i););@for(supply(i):[supply_con]@sum(demand(j):c(j,i))=e(i););EndGlobaloptimalsolutionfound.Objectivevalue:136.2275Infeasibilities:0.000000Totalsolveriterations:1VariableValueReducedCostA(1)1.2500000.000000.E(2)20.000000.000000C(1,1)3.0000000.000000C(1,2)0.0000003.852207C(2,1)5.0000000.000000C(2,2)0.0000007.252685C(3,1)0.0000001.341700C(3,2)4.0000000.000000C(4,1)7.0000000.000000C(4,2)0.0000001.992119C(5,1)0.0000002.922492C(5,2)6.0000000.000000C(6,1)1.0000000.000000C(6,2)10.000000.0000007例8.2:当两个料场的坐标为待求量时,试求得坐标与向各工地的分配方案。sets:demand/1..6/:a,b,d;supply/1..2/:x,y,e;link(demand,supply):c;endsetsdata:a=1.258.750.55.7537.25;b=1.250.754.7556.57.75;d=3547611;e=20,20;enddatainit:endinit[obj]min=@sum(link(i,j):c(i,j)*((x(j)-a(i))^2+(y(j)-b(i))^2)^(1/2));@for(demand(i):@sum(supply(j):c(i,j))=d(i));@for(supply(i):@sum(demand(j):c(j,i))=e(i));@for(supply:@free(x);@free(y));endLocaloptimalsolutionfound.Objectivevalue:85.26604Infeasibilities:0.000000Totalsolveriterations:68VariableValueReducedCostA(1)1.2500000.000000.D(6)11.000000.000000X(1)3.2548830.000000X(2)7.250000-0.1853513E-05Y(1)5.6523320.000000Y(2)7.750000-0.1114154E-05.C(1,1)3.0000000.000000C(1,2)0.0000004.008540C(2,1)0.0000000.2051358C(2,2)5.0000000.000000C(3,1)4.0000000.000000C(3,2)0.0000004.487750C(4,1)7.0000000.000000C(4,2)0.0000000.5535090C(5,1)6.0000000.000000C(5,2)0.0000003.544853C(6,1)0.0000004.5123368C(6,2)11.00000例9:求解二次优化:求minf(x)=x1^2+x2^2-4*x1+4;其中:x1-x2=-2;-x1+x2-1=0;min=x1^2+x2^2-4*x1+4;x2-x12;x1-x2-1;endLocaloptimalsolutionfound.Objectivevalue:4.500000Infeasibilities:0.2664535E-14Extendedsolversteps:5Totalsolveriterations:46VariableValueReducedCostX10.50000000.000000X21.5000000.000000RowSlackorSurplusDualPrice14.500000-1.00000021.0000000.00000030.0000003.000000min=x1^2+x2^2-4*x1+4;x1-x2=-2;-x1+x2-1=0;EndLocaloptimalsolutionfound.Objectivevalue:
本文标题:数学建模lingo培训程序
链接地址:https://www.777doc.com/doc-2331315 .html