中国高校课件下载中心 》 教学资源 》 大学文库

上海交通大学:《线性规划与非线性规划》教学资源_Matlab优化函数_NLP-ex

文档信息
资源类别:文库
文档格式:PDF
文档页数:16
文件大小:56.96KB
团购合买:点击进入团购
内容简介
上海交通大学:《线性规划与非线性规划》教学资源_Matlab优化函数_NLP-ex
刷新页面文档预览

NLP E Example

NLP Example

Unconstrained Example

Unconstrained Example

fminunc Consider the problem of finding a set of values [x1,x2]that solves Minimize f(x) X =ex1(4x,2+2x22+4xx2+2x2+1)

fminunc • Consider the problem of finding a set of values [x1, x2] that solves Minimize f ( x ) x =ex1 ( 4x 1 2 +2x 2 2 +4x 1 x 2 +2x 2 +1 )

To solve this two-dimensional problem, write an M-file that returns the function value Then,invoke the unconstrained minimization routine fminunc

• To solve this two-dimensional problem, write an M-file that returns the function value • Then, invoke the unconstrained minimization routine fminunc

Step 1:Write an M-file objfun.m 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)

Step 1: Write an M-file objfun.m 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)

Step 2:Invoke one of the unconstrained optimization routines xO [-1,1];Starting guess ·options optimset('LargeScale','off); [x,fval,exitflag,output] fminunc(@objfun,x0,options);

Step 2: Invoke one of the unconstrained optimization routines • x0 = [-1,1]; % Starting guess • options = optimset('LargeScale','off'); • [x,fval,exitflag,output] = fminunc(@objfun,x0,options);

After 40 function evaluations,this produces the solution X= 0.5000-1.0000 The function at the solution x is returned in fval. fval 1.3030e-10 The exitflag tells if the algorithm converged.An exitflag 0 means a local minimum was found. exitflag 1

• After 40 function evaluations, this produces the solution x = 0.5000 -1.0000 • The function at the solution x is returned in fval. fval = 1.3030e-10 • The exitflag tells if the algorithm converged. An exitflag > 0 means a local minimum was found. exitflag = 1

Note When more than one local minimum exists, the initial guess for the vector [x1,x2] affects both the number of function evaluations and the value of the solution point

Note • When more than one local minimum exists, the initial guess for the vector [x1, x2] affects both the number of function evaluations and the value of the solution point

Nonlinear Inequality Constrained Example

Nonlinear Inequality Constrained Example

fmincon For example,find x that solves Minimize f(x =exl (4x 2 +2x22 X +4x1x2+2x2+1) subject to the constraints x1X2一X1一尤2 ≤-1.5 x12≥-10

fmincon • For example, find x that solves • Minimize f ( x ) = ex 1 ( 4 x 1 2 +2 x 2 2 x +4 x 1 x 2 +2 x 2 +1 ) • subject to the constraints x 1 x 2 –x 1 – x 2 ≤ –1.5 x 1 x 2 ≥ – 10

共16页,试读已结束,阅读完整版请下载
刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档