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 Tutorialfunction evaluations. See optimset, theindividualoptimization functions,and “<strong>Optimization</strong> Options” on page 6-8 for more options and information.Nonlinear Inequality Constrained ExampleIf inequality constraints are added to Equation 2-1, the resulting problem canbe solved by the fmincon function. For example, find x that solvessubject to the constraints(2-2)Because neither of the constraints is linear, you cannot pass the constraintsto fmincon at the command line. Instead you can create a second M-file,confun.m, that returns the value at both constraints at the current x in avector c. The constrained optimizer, fmincon, is then invoked. Becausefmincon expects the constraints to be written in the form ,youmustrewrite your constraints in the form(2-3)Step 1: Write an M-file objfun.m for the objective function.function f = objfun(x)f = exp(x(1))*(4*x(1)^2 + 2*x(2)^2 + 4*x(1)*x(2) + 2*x(2) + 1);Step2: WriteanM-fileconfun.mfortheconstraints.function [c, ceq] = confun(x)% Nonlinear inequality constraintsc = [1.5 + x(1)*x(2) - x(1) - x(2);-x(1)*x(2) - 10];% Nonlinear equality constraintsceq = [];2-12

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

Saved successfully!

Ooh no, something went wrong!