Use MATLAB to solve linear programs Optimization Method 最优化方法经典教材课件.ppt

Use MATLAB to solve linear programs Optimization Method 最优化方法经典教材课件.ppt

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Use MATLAB to solve linear programs Optimization Method 最优化方法经典教材课件

Use MATLAB to solve linear programs LI Xiao-lei MATLAB format for linear programs MATLAB uses the following format for linear programs: min z = fTx s. t. Ax ≤ b Aeq = beq (1) x≥ l x ≤ u Command format A linear program in the format of equation (1) is solved using the command: x = linprog(f ,A, b, Aeq, beq, l, u) Simple example Suppose we want to solve the following linear program using MATLAB: max z=4x1 + 2x2 + x3 s. t. 2x1 + x2 ≤ 1 x1 +2x3 ≤ 2 x1 + x2 + x3 = 1 x1 ≤1 x2 ≤ 1 x3 ≤2 x1≥0;x2≥0;x3≥0 Simple example Convert the LP into MATLAB format Comparing the above LP with the format given in (1) we get: Simple example Input the variables into MATLAB: f = -[4;2;1]; A = [2 1 0;1 0 2]; b = [1;2]; Aeq = [1 1 1]; beq = [1]; l = [0;0;0]; u = [1;1;2]; Simple example Solve the linear program using MATLAB: x = linprog(f,A,b,Aeq,beq,l,u) And you should see the following: Optimization terminated successfully. x = 0.5000 0.0000 0.5000 What to do when some of the variables are missing ? For example, suppose there are no lower bounds on the variables. In this case define l to be the empty set using the MATLAB command: l = []; Do this and resolve the LP by calling the linprog command. You should see: Optimization terminated successfully. x = 0.6667 -0.3333 0.6667 What to do when some of the variables are missing ? Similarly define other matrices to be empty matrices if they do not appear in the problem. For example, if there are no equality constraints, define Aeq and beq as empty sets, i.e. Aeq = []; beq = []; So this and resolve the LP by calling linprog. You should see: Optimization terminated successfully. x = 0.0000 1.0000 1.0000 * *

文档评论(0)

qiwqpu54 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档