资源描述:
《《非线性优化问题》word版》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、非线性优化问题函数fmincon使用格式:[x,fval,exitflag,output,lambda,grad,hessian]=fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)x0为开始运算的初始值x为最优解时x的值fval为z的最优值exitflag判断算法停止的原因grad梯度m文件functiony=funn(x)y=-x(1)-2*x(2)+0.5*(x(1).^2+x(2).^2)主程序A=[23;14];b=[6;5];vlb=[0;0];x0=[0;0];[x,fval,exitflag,output,lambda,
2、grad,hession]=fmincon('funn',x0,A,b,[],[],vlb)结果如下Activeinequalities(towithinoptions.TolCon=1e-006):lowerupperineqlinineqnonlin2x=0.76471.0588fval=-2.0294exitflag=1output=iterations:1funcCount:6lssteplength:1stepsize:1.3061algorithm:'medium-scale:SQP,Quasi-Newton,line-search'firstorderopt:1.796
3、9e-008constrviolation:0message:[1x788char]lambda=lower:[2x1double]upper:[2x1double]eqlin:[0x1double]eqnonlin:[0x1double]ineqlin:[2x1double]ineqnonlin:[0x1double]grad=-0.2353-0.9412hession=1001首先增加一个M文件functiony=nonline(x)y=2*x(1)+3*x(2).^2-6主程序A=[23;14];b=[6;5];vlb=[0;0];x0=[0;0];[x,fval,exitfl
4、ag,output,lambda,grad,hession]=fmincon('funn',x0,A,b,[],[],vlb,'nonline')x=0.76471.0588fval=-2.0294exitflag=1output=iterations:1funcCount:6lssteplength:1stepsize:1.3061algorithm:'medium-scale:SQP,Quasi-Newton,line-search'firstorderopt:1.7969e-008constrviolation:0message:[1x788char]lambda=lower:
5、[2x1double]upper:[2x1double]eqlin:[0x1double]eqnonlin:[0x1double]ineqlin:[2x1double]ineqnonlin:[0x1double]grad=-0.2353-0.9412hession=1001