DOC PREVIEW
Berkeley ELENG 141 - Optimization Toolbox

This preview shows page 1-2-3-4 out of 11 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Optimization Toolbox fmincon Find a minimum of a constrained nonlinear multivariable function subject to where x, b, beq, lb, and ub are vectors, A and Aeq are matrices, c(x) and ceq(x) are functions that returnvectors, and f(x) is a function that returns a scalar. f(x), c(x), and ceq(x) can be nonlinear functions.Syntaxx = fmincon(fun,x0,A,b)x = fmincon(fun,x0,A,b,Aeq,beq)x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub)x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options,P1,P2, ...)[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] = fmincon(...)Descriptionfmincon finds a constrained minimum of a scalar function of several variables starting at an initialestimate. This is generally referred to as constrained nonlinear optimization or nonlinear programming.x = fmincon(fun,x0,A,b) starts at x0 and finds a minimum x to the function described in funsubject to the linear inequalities A*x <= b. x0 can be a scalar, vector, or matrix.x = fmincon(fun,x0,A,b,Aeq,beq) minimizes fun subject to the linear equalities Aeq*x = beq as well as A*x <= b . Set A=[] and b=[] if no inequalities exist.x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub) defines a set of lower and upper bounds on thedesign variables, x, so that the solution is always in the range lb <= x <= ub . Set Aeq=[] and beq=[] if no equalities exist.x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon) subjects the minimization to thenonlinear inequalities c(x) or equalities ceq(x) defined in nonlcon. fmincon optimizes such that c(x) <= 0 and ceq(x) = 0. Set lb=[] and/or ub=[] if no bounds exist.x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options) minimizes with theoptimization parameters specified in the structure options. Use optimset to set these parameters. x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options,P1,P2,...) passes theproblem-dependent parameters P1, P2, etc., directly to the functions fun and nonlcon. Pass emptymatrices as placeholders for A, b, Aeq, beq, lb, ub, nonlcon, and options if these arguments arenot needed.[x,fval] = fmincon(...) returns the value of the objective function fun at the solution x.[x,fval,exitflag] = fmincon(...) returns a value exitflag that describes the exitcondition of fmincon.[x,fval,exitflag,output] = fmincon(...) returns a structure output with informationabout the optimization.[x,fval,exitflag,output,lambda] = fmincon(...) returns a structure lambda whosefields contain the Lagrange multipliers at the solution x.[x,fval,exitflag,output,lambda,grad] = fmincon(...) returns the value of the gradientof fun at the solution x.[x,fval,exitflag,output,lambda,grad,hessian] = fmincon(...) returns the value ofthe Hessian of fun at the solution x.Input ArgumentsFunction Arguments contains general descriptions of arguments passed in to fmincon. This"Arguments" section provides function-specific details for fun, nonlcon, and options:funThe function to be minimized. fun is a function that accepts a scalar x and returns ascalar f, the objective function evaluated at x. The function fun can be specified as afunction handle.x = fmincon(@myfun,x0,A,b)where myfun is a MATLAB function such asfunction f = myfun(x)f = ... % Compute function value at xfun can also be an inline object.x = fmincon(inline('norm(x)^2'),x0,A,b);If the gradient of fun can also be computed and the GradObj parameter is 'on', as setbyoptions = optimset('GradObj','on')then the function fun must return, in the second output argument, the gradient value g, avector, at x. Note that by checking the value of nargout the function can avoidcomputing g when fun is called with only one output argument (in the case where theoptimization algorithm only needs the value of f but not g).function [f,g] = myfun(x)f = ... % Compute the function value at xif nargout > 1 % fun called with two output arguments g = ... % Compute the gradient evaluated at xendThe gradient consists of the partial derivatives of f at the point x. That is, the ithcomponent of g is the partial derivative of f with respect to the ith component of x.If the Hessian matrix can also be computed and the Hessian parameter is 'on', i.e., options = optimset('Hessian','on') , then the function fun must return theHessian value H, a symmetric matrix, at x in a third output argument. Note that bychecking the value of nargout we can avoid computing H when fun is called with onlyone or two output arguments (in the case where the optimization algorithm only needs thevalues of f and g but not H).function [f,g,H] = myfun(x)f = ... % Compute the objective function value at xif nargout > 1 % fun called with two output arguments g = ... % Gradient of the function evaluated at x if nargout > 2 H = ... % Hessian evaluated at xendThe Hessian matrix is the second partial derivatives matrix of f at the point x. That is, the(i,j)th component of H is the second partial derivative of f with respect to xi and xj, . The Hessian is by definition a symmetric matrix.nonlconThe function that computes the nonlinear inequality constraints c(x)<= 0 and thenonlinear equality constraints ceq(x) = 0 . The function nonlcon accepts a vector xand returns two vectors c and ceq. The vector c contains the nonlinear inequalitiesevaluated at x, and ceq contains the nonlinear equalities evaluated at x. The function nonlcon can be specified as a function handle.x = fmincon(@myfun,x0,A,b,Aeq,beq,lb,ub,@mycon)where mycon is a MATLAB function such asfunction [c,ceq] = mycon(x)c = ... % Compute nonlinear inequalities at x.ceq = ... % Compute nonlinear equalities at x.If the gradients of the constraints can also be computed and the GradConstr parameteris 'on', as set byoptions = optimset('GradConstr','on')then the function nonlcon must also return, in the third and fourth output arguments, GC,the gradient of c(x), and GCeq, the gradient of ceq(x). Note that by checking the valueof nargout the function can avoid computing GC and GCeq when nonlcon is called withonly two output arguments (in the case where the optimization algorithm only needs thevalues of c and ceq but not GC and GCeq).function [c,ceq,GC,GCeq] = mycon(x)c = ... % Nonlinear inequalities at xceq = ... % Nonlinear equalities


View Full Document

Berkeley ELENG 141 - Optimization Toolbox

Documents in this Course
Adders

Adders

7 pages

Memory

Memory

33 pages

I/O

I/O

14 pages

Lecture 8

Lecture 8

34 pages

Lab 3

Lab 3

2 pages

I/O

I/O

17 pages

Project

Project

6 pages

Adders

Adders

15 pages

SRAM

SRAM

13 pages

Load more
Download Optimization Toolbox
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Optimization Toolbox and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Optimization Toolbox 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?