运筹学光盘内容实验指导第四章非线性_第1页
运筹学光盘内容实验指导第四章非线性_第2页
运筹学光盘内容实验指导第四章非线性_第3页
运筹学光盘内容实验指导第四章非线性_第4页
运筹学光盘内容实验指导第四章非线性_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

本章,我们介绍两种解决非线性规划问题的软件第一种:中的optimizationtoolbox中的若干程序;第二种:LINGO软件.程序名unpfun1函数unpfun2unpfun1实例Minimizethe

f(x)3x22xx 1 在命令窗口输入以下信息>>x0=[1,1];%Thencallfminunctofindaminimumofunpfun1near>>输出以下信息OptimizationterminatedSearchdirectionlessthan2*options.TolXx=1.0e-008 fval=unpfun2实例:将上述的实例用梯度法做>>options=optimset('GradObj','on');%Tominimizethisfunctionwiththegradientprovided>>x0=>>[x,fval]=输出以下信息OptimizationterminatedFirst-orderoptimalitylessthanOPTIONS.TolFun,andnonegative/zerocurvaturedetectedx1.0e-015 fval=第一种fminsearchFindaminimumofanunconstrainedmultivariablewherexisavectorandf(x)isafunctionthatreturnsa语法如下x=x=fminsearch(fun,x0,options)[x,fval]=fminsearch(...)[x,fval,exitflag]=fminsearch(...)[x,fval,exitflag,output]=解释fminsearchattemptstofindaminimumofascalarfunctionofseveralvariables,startingataninitialestimate.Thisisgenerallyreferredtoasunconstrainednonlinearoptimization.x=fminsearch(fun,x0)startsatthepointx0andattemptstofindalocalminimumxofthefunctiondescribedinfun.funisafunctionhandleforeitheranM-filefunctionorananonymousfunction.x0canbeascalar,vector,ormatrix.x=fminsearch(fun,x0,options)minimizeswiththeoptimizationoptionsspecifiedinthestructureoptions.Useoptimsettosetthese[x,fval]=fminsearch(...)returnsinfvalthevalueoftheobjectivefunctionfunatthesolutionx.[x,fval,exitflag]=fminsearch(...)returnsavalueexitflagthatdescribestheexitconditionoffminsearch.[x,fval,exitflag,output]=fminsearch(...)returnsastructureoutputthatcontainsinformationabouttheoptimization.AvoidingGlobalVariablesviaAnonymousandNestedFunctionsex inshowtoparameterizetheobjectivefunctionfun,ifnecessary.第二种:Findaminimumofanunconstrainedmultivariablewherexisavectorandf(x)isafunctionthatreturnsax=x=fminunc(fun,x0,options)[x,fval]=fminunc(...)[x,fval,exitflag]=fminunc(...)[x,fval,exitflag,output]=fminunc(...)[x,fval,exitflag,output,grad]=fminunc(...)[x,fval,exitflag,output,grad,hessian]=fminunc(...)fminuncattemptstofindaminimumofascalarfunctionofseveralvariables,startingataninitialestimate.Thisisgenerallyreferredtoasunconstrainednonlinearoptimization.x=fminunc(fun,x0)startsatthepointx0andattemptstofindalocalminimumxofthefunctiondescribedinfun.x0canbeascalar,vector,orx=fminunc(fun,x0,options)minimizeswiththeoptimizationoptionsspecifiedinthestructureoptions.Useoptimsettosettheseoptions.[x,fval]=fminunc(...)returnsinfvalthevalueoftheobjectivefunctionfunatthesolutionx.[x,fval,exitflag]=fminunc(...)returnsavalueexitflagthatdescribestheexitcondition.[x,fval,exitflag,output]=fminunc(...)returnsastructureoutputthatcontainsinformationabouttheoptimization.[x,fval,exitflag,output,grad]=fminunc(...)returnsingradthevalueofthegradientoffunatthesolutionx.[x,fval,exitflag,output,grad,hessian]=fminunc(...)returnsinhessianthevalueoftheHessianoftheobjectivefunctionfunatthesolutionx.SeeAvoidingGlobalVariablesviaAnonymousandNestedFunctionsex inshowtoparameterizetheobjectivefunctionfun,ifnecessary.程序名cnpfuncnfun实例

fx1x2 0x12x22x3在命令窗口输入以下信息>>A=[-1,-2,->>>>x0=[10;10;10];%Startingguessatthe>>[x,fval]=输出以下信息OptimizationterminatedMagnitudeofdirectionalderivativeinsearchdirectionlessthan2*options.TolFunand umconstraintviolationislessthanoptions.TolConActiveConstraints:x=fval程序的相关知识Findaminimumofaconstrainednonlinearmultivariablesubjectwherex,b,beq,lb,andubarevectors,AandAeqarematrices,c(x)andceq(x)arefunctionsthatreturnvectors,andf(x)isafunctionthatreturnsascalar.f(x),c(x),andceq(x)canbenonlinearfunctions.x=x=x=x=x=fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)[x,fval]=fmincon(...)[x,fval,exitflag]=fmincon(...)[x,fval,exitflag,output]=fmincon(...)[x,fval,exitflag,output,lambda]=fmincon(...)[x,fval,exitflag,output,lambda,grad]=fmincon(...)[x,fval,exitflag,output,lambda,grad,hessian]=fminconattemptstofindaconstrainedminimumofascalarfunctionofseveralvariablesstartingataninitialestimate.Thisisgenerallyreferredtoasconstrainednonlinearoptimizationornonlinearprogramming.x=fmincon(fun,x0,A,b)startsatx0andattemptstofindaminimumxtothefunctiondescribedinfunsubjecttothelinearinequalitiesA*x<=b.x0canbeascalar,vector,ormatrix.x=fmincon(fun,x0,A,b,Aeq,beq)minimizesfunsubjecttothelinearequalitiesAeq*x=beqaswellasA*x<=b.SetA=[]andb=[]ifnoinequalitiesexist.x=fmincon(fun,x0,A,b,Aeq,beq,lb,ub)definesasetoflowerandupperboundsonthedesignvariablesinx,sothatthesolutionisalwaysintherangelb<=x<=ub.SetAeq=[]andbeq=[]ifnoequalitiesexist.x=fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)subjectstheminimizationtothenonlinearinequalitiesc(x)orequalitiesceq(x)definedinnonlcon.fminconoptimizessuchthatc(x)<=0andceq(x)=0.Setlb=[]and/orub=[]ifnoboundsexist.x=fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)minimizeswiththeoptimizationoptionsspecifiedinthestructureoptions.Useoptimsettosettheseoptions.Setnonlcon=[]iftherearenononlinearinequalityorequalityconstraints.[x,fval]=fmincon(...)returnsthevalueoftheobjectivefunctionfunatthesolutionx.[x,fval,exitflag]=fmincon(...)returnsavalueexitflagthatdescribestheexitconditionoffmincon.[x,fval,exitflag,output]=fmincon(...)returnsastructureoutputwithinformationabouttheoptimization.[x,fval,exitflag,output,lambda]=fmincon(...)returnsastructurelambdawhosefieldscontaintheLagrangemultipliersatthesolutionx.[x,fval,exitflag,output,lambda,grad]=fmincon(...)returnsthevalueofthegradientoffunatthesolutionx.[x,fval,exitflag,output,lambda,grad,hessian]=fmincon(...)returnsthevalueoftheHessianatthesolutionx.SeeHessian.AvoidingGlobalVariablesviaAnonymousandNestedFunctionsexinshowtoparameterizetheobjectivefunctionfun,ifnecessary.程序名qprogramqprogram实例:

f(x)x2x2 42x1x x1,x2在命令窗口输入以下信息theprogramiswiththequadraticPleaseinputtheconstraintsnumberoftheprogrammingm4Pleaseinputthevariantnumberoftheprogrammingn4PleaseinputcostmatrixoftheobjectivefunctionH Pleaseinputcostarrayoftheobjectivefunctionc60PleaseinputthecoefficientmatrixoftheconstraintsA(m,n)=[-2,-1;-1,0;0,-A Pleaseinputtheresourcearrayoftheprogramb(m)_T=[-b00命令窗口输出信息Optimizationterminatedsuccessfully.Thesolutionofthequadraticis:x=程序的相关知识SolvethequadraticprogrammingwhereH,A,andAeqarematrices,andf,b,beq,lb,ub,andxare语法如下x=x=x=x=x=quadprog(H,f,A,b,Aeq,beq,lb,ub,x0,options)[x,fval]=quadprog(...)[x,fval,exitflag]=quadprog(...)[x,fval,exitflag,output]=quadprog(...)[x,fval,exitflag,output,lambda]=quadprog(...)解释x=quadprog(H,f,A,b)returnsavectorxthatminimizes1/2*x'*H*x+f'*xsubjecttoA*x<=b.x=quadprog(H,f,A,b,Aeq,beq)solvestheprecedingproblemwhileadditionallysatisfyingtheequalityconstraintsAeq*x=beq.x=quadprog(H,f,A,b,Aeq,beq,lb,ub)definesasetoflowerandupperboundsonthedesignvariables,x,sothatthesolutionisintherangelb<=x<=x=quadprog(H,f,A,b,Aeq,beq,lb,ub,x0)setsthestartingpointtox0.x=quadprog(H,f,A,b,Aeq,beq,lb,ub,x0,options)minimizeswiththeoptimizationoptionsspecifiedinthestructureoptions.Useoptimsettosettheseoptions.[x,fva

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论