12.07.2015 Views

What Is Optimization Toolbox?

What Is Optimization Toolbox?

What Is Optimization Toolbox?

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2 Tutorial• Contains a nested function qpbox4mult that uses A and B to compute theHessian matrix product W, whereW = H*Y = (B + A*A')*Y. The nestedfunction must have the formW = qpbox4mult(Hinfo,Y,...)ThefirsttwoargumentsHinfo and Y are required.• Loads the problem parameters from qpbox4.mat.• Uses optimset to set the HessMult option to a function handle that pointsto qpbox4mult.• Calls quadprog with B as the first argument.The first argument to the nested function qpbox4mult must be the same asthe first argument passed to quadprog, which in this case is the matrix B.The second argument to qpbox4mult is the matrix Y (of W = H*Y). Becausequadprog expects Y to be used to form the Hessian matrix product, Y is alwaysamatrixwithn rows, where n is the number of dimensions in the problem.The number of columns in Y can vary. The function qpbox4mult is nested sothat the value of the matrix A comes from the outer function.function [fval, exitflag, output, x] = runqpbox4% RUNQPBOX4 demonstrates 'HessMult' option for QUADPROG with% bounds.problem = load('qpbox4'); % Get xstart, u, l, B, A, fxstart = problem.xstart; u = problem.u; l = problem.l;B = problem.B; A = problem.A; f = problem.f;mtxmpy = @qpbox4mult; % function handle to qpbox4mult nested% subfunction% Choose the HessMult optionoptions = optimset('HessMult',mtxmpy);% Pass B to qpbox4mult via the Hinfo argument. Also, B will be% used in computing a preconditioner for PCG.[x, fval, exitflag, output] = ...quadprog(B,f,[],[],[],[],l,u,xstart,options);2-68

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

Saved successfully!

Ooh no, something went wrong!