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.

Large-Scale Examples'LargeScale','on','PrecondBandWidth',1);[x,fval,exitflag,output] = fsolve(fun,xstart,options);In this case the output isNorm of First-order CG-Iteration Func-count f(x) step optimality Iterations1 2 1011 1 19 02 3 16.0839 7.92496 1.92 13 4 0.0458181 1.3279 0.579 14 5 0.000101184 0.0631898 0.0203 25 6 3.16615e-007 0.00273698 0.00079 26 7 9.72481e-010 0.00018111 5.82e-005 2<strong>Optimization</strong> terminated successfully:Relative function value changing by less than OPTIONS.TolFunNote that although the same number of iterations takes place, the numberof PCG iterations has dropped, so less work is being done per iteration. See“Preconditioned Conjugate Gradients” on page 4-7.Nonlinear Equations with Jacobian Sparsity PatternIn the preceding example, the function nlsf1 computes the Jacobian J, asparse matrix, along with the evaluation of F. <strong>What</strong> if the code to compute theJacobian is not available? By default, if you do not indicate that the Jacobiancan be computed in nlsf1 (by setting the Jacobian option in options to'on'), fsolve, lsqnonlin, andlsqcurvefit instead uses finite differencingto approximate the Jacobian.In order for this finite differencing to be as efficient as possible, you shouldsupply the sparsity pattern of the Jacobian, by setting JacobPattern to 'on'in options. That is, supply a sparse matrix Jstr whose nonzero entriescorrespond to nonzeros of the Jacobian for all x. Indeed,thenonzerosofJstrcan correspond to a superset of the nonzero locations of J; however, in generalthe computational cost of the sparse finite-difference procedure will increasewith the number of nonzeros of Jstr.Providing the sparsity pattern can drastically reduce the time needed tocompute the finite differencing on large problems. If the sparsity patternis not provided (and the Jacobian is not computed in the objective function2-47

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

Saved successfully!

Ooh no, something went wrong!