12.07.2015 Views

What Is Optimization Toolbox?

What Is Optimization Toolbox?

What Is Optimization Toolbox?

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2 TutorialThe problem is to find x to minimize(2-7)where n = 1000.Step 1: Write an M-file brownfgh.m that computes theobjective function, the gradient of the objective, and the sparsetridiagonal Hessian matrix.This file is rather long and is not included here. You can view the code withthe commandtype brownfghBecause brownfgh computes the gradient and Hessian values as well as theobjective function, you need to use optimset to indicate that this informationis available in brownfgh, usingtheGradObj and Hessian options.Step 2: Call a nonlinear minimization routine with a startingpoint xstart.n = 1000;xstart = -ones(n,1);xstart(2:2:n,1) = 1;options = optimset('GradObj','on','Hessian','on');[x,fval,exitflag,output] = fminunc(@brownfgh,xstart,options);This 1000 variable problem is solved in about 7 iterations and 7 conjugategradient iterations with a positive exitflag indicating convergence. Thefinal function value and measure of optimality at the solution x are both closeto zero. For fminunc, the first order optimality is the infinity norm of thegradient of the function, which is zero at a local minimum:exitflag =1fval =2.8709e-017output.iterations2-52

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!