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 TutorialCalling an Output Function IterativelyFor some problems, you might want output from an optimization algorithm ateach iteration. For example, you might want to find the sequence of pointsthat the algorithm computes and plot those points. To do this, you can createan output function that the optimization function calls at each iteration. Thissection provides an example of an output function.This section covers the following topics:• “<strong>What</strong> the Example Does” on page 2-88• “Output Function” on page 2-89• “Creating the M-File for the Example” on page 2-90• “RunningtheExample”onpage2-92<strong>What</strong> the Example DoesThe example in this section continues the one described in “NonlinearInequality Constrained Example” on page 2-12, which calls the functionfmincon at the command line to solve a nonlinear, constrained optimizationproblem. However, the example in this section uses an M-file to call fmincon.The M-file also contains all the functions needed for the example, including• The objective function• The constraint function• An output function that records the history of points computed by thealgorithm for fmincon. At each iteration of the algorithm for fmincon,the output function- Plots the current point computed by the algorithm- Stores the point and its corresponding objective function value in avariable called history, and the current search direction in a variablecalled searchdir. The search direction is a vector that points in thedirection from the current point to the next one.You can see the code for the M-file in “Creating the M-File for the Example”on page 2-90.2-88

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

Saved successfully!

Ooh no, something went wrong!