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.

<strong>Optimization</strong> Tool Examples<strong>Optimization</strong> Tool Examples• “<strong>Optimization</strong> Tool with the fmincon Solver” on page 5-47• “<strong>Optimization</strong> Tool with the lsqlin Solver” on page 5-51<strong>Optimization</strong> Tool with the fmincon SolverThisexampleshowshowtousethe<strong>Optimization</strong>Toolwiththefminconsolver to minimize a quadratic subject to linear and nonlinear constraintsand bounds.Consider the problem of finding [x 1, x 2]thatsolvesmin ( )x f x = x + x1 2 2 2subject to the constraints05 . ≤ x− x − x + 1≤01 21 2 2 2− x − x + 1≤0−9x− x + 9≤01 2 2 2− x − x ≤ 01 2 2− x + x ≤ 02 2 11The starting guess for this problem is x 1=3andx 2=1.Step 1: Write an M-file objfun.m for the objective function.function f = objfun(x)f = x(1)^2 + x(2)^2;Step 2: Write an M-file nonlconstr.m for the constraints.function [c,ceq] = nonlconstr(x)c = [-x(1)^2 - x(2)^2 + 15-47

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

Saved successfully!

Ooh no, something went wrong!