用MATLAB求解非线性优化问题

上传人:油条 文档编号:27333341 上传时间:2018-01-09 格式:DOC 页数:6 大小:76.50KB
返回 下载 相关 举报
用MATLAB求解非线性优化问题_第1页
第1页 / 共6页
用MATLAB求解非线性优化问题_第2页
第2页 / 共6页
用MATLAB求解非线性优化问题_第3页
第3页 / 共6页
用MATLAB求解非线性优化问题_第4页
第4页 / 共6页
用MATLAB求解非线性优化问题_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《用MATLAB求解非线性优化问题》由会员分享,可在线阅读,更多相关《用MATLAB求解非线性优化问题(6页珍藏版)》请在金锄头文库上搜索。

1、实验四 用 MATLAB 求解非线性优化问题一、实验目的:了解 Matlab 的优化工具箱,利用 Matlab 求解非线性优化问题。二、相关知识非线性优化包括相当丰富的内容,我们这里就 Matlab 提供的一些函数来介绍相关函数的用法及其所能解决的问题。(一)非线性一元函数的最小值Matlab 命令为 fminbnd(),其使用格式为:X=fminbnd(fun,x1,x2)X,fval,exitflag,output= fminbnd(fun,x1,x2)其中:fun 为目标函数,x1,x2 为变量得边界约束,即 x1xx2,X 为返回得满足 fun取得最小值的 x 的值,而 fval 则为

2、此时的目标函数值。exitflag0 表示计算收敛,exitflag=0表示超过了最大的迭代次数,exitflag0 表示优化结果收敛于解,exitflag=0 表示优化超过了函数值的计算次数,exitflag0 表示优化不收敛。lambda 是拉格朗日乘子,显示那个约束条件有效。grad 表示梯度,hessian 表示汉森矩阵。例 4:求 12,x,使得目标函数 121212(,)(4)xfex在约束条件12.5*0, 12*0x下取得最小值。我们设计的程序如下:先把目标函数和约束条件分别编写成独立的 m 文件,注意,这样的 m 文件必须用function 开头,并且文件名一定要和函数名一致

3、。目标函数的文件为:function f=objfun(x)f=exp(x(1)*(4*x(1)2+2*x(2)2+4*x(1)*x(2)+2*x(2)+1);约束条件的文件为:function c,ceq=confun(x)c=1.5+x(1)*x(2)-x(1)-x(2);-x(1)*x(2)-10;ceq=;接着,编写完成优化的程序如下:clearx0=-1 1;options=optimset(largescale,off,display,iter);x,fval,exitflag,output=fmincon(objfun,x0,confun,options)运行结果为:Iter F

4、-count f(x) constraint maxStep-size Directional derivative Procedure1 3 1.8394 0.5 1 0.04862 7 1.85127 -0.09197 1 -0.556 Hessian modified twice3 11 0.300167 9.33 1 0.174 15 0.529834 0.9209 1 -0.9655 20 0.186965 -1.517 0.5 -0.1686 24 0.0729085 0.3313 1 -0.05187 28 0.0353322 -0.03303 1 -0.01428 32 0.0

5、235566 0.003184 1 -6.22e-0069 36 0.0235504 9.032e-008 1 1.76e-010 Hessian modifiedOptimization terminated successfully:Search direction less than 2*options.TolX andmaximum constraint violation is less than options.TolConActive Constraints:12x = -9.5474 1.0474fval = 0.0236exitflag = 1output = iterati

6、ons: 9funcCount: 38stepsize: 1algorithm: medium-scale: SQP, Quasi-Newton, line-searchfirstorderopt: cgiterations: 例 5:在上例的基础上,再加上边界约束条件,即加上 10x, 2,则我们仅需要修改上面的第三个程序为:clearx0=-1 1;lb=0,0;ub=;options=optimset(largescale,off,display,iter);x,fval,exitflag,output=fmincon(objfun,x0,lb,ub,confun,options)现在得

7、到的结果为:Iter F-count f(x) constraintmax Step-sizeDirectional derivative Procedure1 3 5.0009 0.5 1 32 7 8.5004 1.355e-020 1 -0.00043 11 8.5 3.04e-013 1 2.43e-012 Hessian modifiedOptimization terminated successfully:Search direction less than 2*options.TolX andmaximum constraint violation is less than o

8、ptions.TolConActive Constraints:13x = 0 1.5000fval = 8.5000exitflag = 1output = iterations: 3funcCount: 13stepsize: 1algorithm: medium-scale: SQP, Quasi-Newton, line-searchfirstorderopt: cgiterations: 三、实验内容1将例 1 中 x 的范围改为-5,5你将得到怎样的结果,你认为正确吗?应该如何解决?2求函数 2()4f的最小值。3在区间 0,上,求函数 42()2)sin(1)cosfxxx的最小值。4求有约束的非线性优化问题:312min()f约束条件为: 120x5求有约束的非线性优化问题:21122in()46fxx约束条件为:1250,x6完成实验报告。

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

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