版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
本章,我们介绍两种解决非线性规划问题的软件第一种:中的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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年杭州市余杭区事业单位人员招聘考试备考试题及答案详解
- 2026年江苏省南京市事业单位人员招聘考试备考题库及答案详解
- 2026年武汉市汉南区事业单位人员招聘考试备考题库及答案详解
- 2026年广东省揭阳市事业单位人员招聘笔试参考试题及答案详解
- 2026年天津市河北区事业单位人员招聘考试参考题库及答案详解
- 2026年陕西省榆林市事业单位人员招聘考试模拟试题及答案详解
- 2026浙江交工集团股份有限公司招聘1人(2026年第4期)考试参考题库及答案详解
- 2026年揭阳市榕城区事业单位人员招聘考试备考试题及答案详解
- 2026年乌鲁木齐市沙依巴克区事业单位人员招聘考试备考题库及答案详解
- 2026年柳州市城中区事业单位人员招聘考试模拟试题及答案详解
- 国家职业标准 4-10-01-06 家政服务员(整 理收纳师) (2026年版)
- FOCUS-PDCA原理及流程完整版
- 农贸市场保洁工作制度
- 胃镜病理切片检查
- VDA 6.5 产品审核培训
- 电子束熔炼技术探索-洞察与解读
- 《3-6岁儿童学习与发展指南》健康领域知识测评题库(附答案)
- 国开电大本科《理工英语3》一平台机考交际用语题库2026珍藏版
- 情感咨询话术
- 2026公安联考行测真题及答案
- 育婴培训课件教学
评论
0/150
提交评论