lingo编程练习题

上传人:第*** 文档编号:31075172 上传时间:2018-02-04 格式:DOC 页数:20 大小:227.08KB
返回 下载 相关 举报
lingo编程练习题_第1页
第1页 / 共20页
lingo编程练习题_第2页
第2页 / 共20页
lingo编程练习题_第3页
第3页 / 共20页
lingo编程练习题_第4页
第4页 / 共20页
lingo编程练习题_第5页
第5页 / 共20页
点击查看更多>>
资源描述

《lingo编程练习题》由会员分享,可在线阅读,更多相关《lingo编程练习题(20页珍藏版)》请在金锄头文库上搜索。

1、1一、编写 lingo 程序求解下列方程(组)1、 4xsincoxsyms x; x=solve(x=(cos(x)+sin(x)/4)x =0.315182442838735901956487060939832、 x4 syms x; x=solve(x=4-2x)x =4 - lambertw(0, 16*log(2)/log(2) x=eval(x)x =1.3861669800714943、求方程 在 中的根的近似值07423xxf 43,Matlab:syms x; y=x3-2*x2-4*x-7; x=eval(solve(y)x =3.6320 + 0.0000i-0.8160

2、 - 1.1232i-0.8160 + 1.1232iOR:syms x; a=1,-2,-4,-7; x=roots(a)x =3.6320 + 0.0000i-0.8160 + 1.1232i-0.8160 - 1.1232iLingo:x3-2*x2-4*x-7=0;bnd(3,x,4);Feasible solution found.Infeasibilities: 0.5329071E-14Extended solver steps: 52Total solver iterations: 36Variable ValueX 3.631981Matlab:function y=f(m,

3、n)syms x xk;a=m;b=n;ff=x3-2*x2-4*x-7;while b-a0.00001xk=(a+b)/2;fx=subs(ff,x,xk);fa=subs(ff,x,a);if fx=0y=xk;break;elseif fa*fx x4=solve(x42-3*x4-4=0,x4)x4 =4-1lingox12-3*x1-4=0;x22-3*x2-4=0;free(x2);Variable ValueX1 4.000000X2 -1.00000035、12340,5.xxsyms x1 x2 x3 x4; x1,x2,x3,x4=solve(2*x1+x2-x3+x4,

4、3*x1-2*x2+x3-x4,x1+4*x2-3*x3+5*x4,x1,x2,x3,x4)x1 =z/7x2 =(5*z)/7x3 =z x4 =06、 .xx,310224521a=5,2,1;-1,4,2;2,-3,10; b=-12;20;3; x=inv(a)*bx =-4.0000000000000003.0000000000000002.000000000000000二、编写 lingo 程序求解下列最优化问题1、 .x,x,.ts为4321432102144*x1-x2+2*x3-x4=-2;x1+x2-x3+2*x42;free(x4);Feasible solution f

5、ound.Infeasibilities: 0.000000Total solver iterations: 2Variable Value4X1 0.000000X2 1.000000X3 0.000000X4 1.0000002、 321-xzmin.x,x,.ts为3214063、 zma.x,.ts为05214121max=3*x1-x2;3*x1-x210;2*x1+x21;x1-x2+6*x3+4*x48;5*x1+3*x3+x45;bin(x1);bin(x2);bin(x3);bin(x4);Global optimal solution found.Objective val

6、ue: 0.000000Objective bound: 0.000000Infeasibilities: 0.000000Extended solver steps: 0Total solver iterations: 0Variable Value Reduced CostX 0.000000 3.000000X2 0.000000 7.000000X3 1.000000 -1.000000X4 1.000000 1.000000X1 1.000000 0.0000006、求图中点 到各点的最短路(不可逆行) 1v6v2v4v3v1v5v6v72532463 342 1v8model:SE

7、TS:points/v1,v2,v3,v4,v5,v6,v7,v8/: L; roads(points,points)/v1,v2 v1,v3 v1,v4v2,v3 v2,v5 v3,v6 v4,v3v6,v5 v6,v8 v7,v6 v7,v4 v8,v5 v8,v7/: d;ENDSETSDATA:d=2 5 32 4 6 43 4 2 7 3 1; L=0,;ENDDATA FOR(points(i)|i#GT#index(v1):L(i) = MIN( roads(j, i): L(j) + d(j, i););endLinearization components added:Con

8、straints: 24Variables: 14Integers: 10Feasible solution found.Infeasibilities: 0.000000Extended solver steps: 0Total solver iterations: 0Variable ValueL( V1) 0.000000L( V2) 2.000000L( V3) 4.000000477L( V4) 3.000000L( V5) 6.000000L( V6) 10.00000L( V7) 15.00000L( V8) 14.00000D( V1, V2) 2.000000D( V1, V

9、3) 5.000000D( V1, V4) 3.000000D( V2, V3) 2.000000D( V2, V5) 4.000000D( V3, V6) 6.000000D( V4, V3) 4.000000D( V6, V5) 3.000000D( V6, V8) 4.000000D( V7, V6) 2.000000D( V7, V4) 7.000000D( V8, V5) 3.000000D( V8, V7) 1.000000三、先建立问题的数学模型,再编写 lingo 程序求解1、某厂每日 8 小时的产量不低于 1800 件为了进行质量控制,计划聘请两种不同水平的检验员一级检验员的

10、标准为:速度 25 件/小时,正确率 98%,计时工资 4 元/小时;二级检验员的标准为:速度 15 小时/ 件,正确率 95%,计时工资 3 元/小时检验员每错检一次,工厂要损失 2 元为使总检验费用最省,该工厂应聘一级、二级检验员各几名?min=8*x1*(4+0.02*25*2)+8*x2*(3+0.05*15*2);8*x1*25+8*x2*15=1800;gin(x1);gin(x2);Global optimal solution found.Objective value: 360.0000Objective bound: 360.0000Infeasibilities: 0.0

11、00000Extended solver steps: 0Total solver iterations: 0Variable Value Reduced CostX1 9.000000 40.00000X2 0.000000 36.000002、某饲料场饲养动物出售,设每头动物每天至少需 700 克蛋白质、30 克矿物8质、100 毫克维生素现有 5 种饲料可供选用,各种饲料每公斤营养成分含量及单价如表所示:饲料 蛋白质(g) 矿物质(g) 维生素(mg) 价格(元/kg)1234532161810.50.220.50.51.00.220.80.20.70.40.30.8要求确定既满足动物生

12、长的营养需要,又使费用最省的选用饲料的方案model:sets:f/1.5/:x,p;e/1.3/;s(f,e):c;endsetsdata:p=0.2 0.7 0.4 0.3 0.8;c=3 1 0.52 0.5 11 0.2 0.26 2 218 0.5 0.8;enddatamin=sum(f(i):p(i)*x(i);sum(f(i):c(i,1)*x(i)700;sum(f(i):c(i,2)*x(i)30;sum(f(i):c(i,3)*x(i)100;Global optimal solution found.Objective value: 32.43590Infeasibilities: 0.000000Total solver iterations: 2Variable Value Reduced CostX( 1) 0.000000 0.5961538E-01X( 2) 0.000000 0.5935897X( 3) 0.000000 0.3525641X( 4) 39.74

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号