What Is Optimization Toolbox?

What Is Optimization Toolbox? What Is Optimization Toolbox?

cda.psych.uiuc.edu
from cda.psych.uiuc.edu More from this publisher
12.07.2015 Views

2 Tutorial3.7081Sharing Variables Using Nested FunctionsThe preceding example uses an existing function ellipj that has morearguments than would be passed by fsolve. If you are writing your ownfunction, you can use the technique above, or you might find it moreconvenient to use a nested function. Nested functions have the additionaladvantage that you can share variables between them. For example, supposeyou want to minimize an objective function, subject to an additional nonlinearconstraint that the objective function should never exceed a certain value.To avoid having to recompute the objective function value in the constraintfunction, you can use a nested function.You can see an example of sharing variables via nested functions in “SimulinkExample Using fminimax” on page 2-33.Nonlinear Equations with Analytic JacobianThis example demonstrates the use of the default medium-scale fsolvealgorithm. It is intended for problems where• The system of nonlinear equations is square, i.e., the number of equationsequals the number of unknowns.• There exists a solution such that .The example uses fsolve to obtain the minimum of the banana (orRosenbrock) function by deriving and then solving an equivalent system ofnonlinear equations. The Rosenbrock function, which has a minimum at, is a common test problem in optimization. It has a high degree ofnonlinearity and converges extremely slowly if you try to use steepest descenttype methods. It is given byFirst generalize this function to an n-dimensional function, for any positive,even value of n:2-22

Examples That Use Standard AlgorithmsThis function is referred to as the generalized Rosenbrock function. It consistsof n squared terms involving n unknowns.Before you can use fsolve to find the values of such that ,i.e.,obtain the minimum of the generalized Rosenbrock function, you must rewritethe function as the following equivalent system of nonlinear equations:This system is square, and you can use fsolve to solve it. As the exampledemonstrates, this system has a unique solution given by .Step 1: Write an M-file bananaobj.m to compute the objectivefunction values and the Jacobian.function [F,J] = bananaobj(x);% Evaluate the vector function and the Jacobian matrix for% the system of nonlinear equations derived from the general% n-dimensional Rosenbrock function.% Get the problem sizen = length(x);if n == 0, error('Input vector, x, is empty.'); endif mod(n,2) ~= 0,error('Input vector, x, must have an even number of2-23

2 Tutorial3.7081Sharing Variables Using Nested FunctionsThe preceding example uses an existing function ellipj that has morearguments than would be passed by fsolve. If you are writing your ownfunction, you can use the technique above, or you might find it moreconvenient to use a nested function. Nested functions have the additionaladvantage that you can share variables between them. For example, supposeyou want to minimize an objective function, subject to an additional nonlinearconstraint that the objective function should never exceed a certain value.To avoid having to recompute the objective function value in the constraintfunction, you can use a nested function.You can see an example of sharing variables via nested functions in “SimulinkExample Using fminimax” on page 2-33.Nonlinear Equations with Analytic JacobianThis example demonstrates the use of the default medium-scale fsolvealgorithm. It is intended for problems where• The system of nonlinear equations is square, i.e., the number of equationsequals the number of unknowns.• There exists a solution such that .The example uses fsolve to obtain the minimum of the banana (orRosenbrock) function by deriving and then solving an equivalent system ofnonlinear equations. The Rosenbrock function, which has a minimum at, is a common test problem in optimization. It has a high degree ofnonlinearity and converges extremely slowly if you try to use steepest descenttype methods. It is given byFirst generalize this function to an n-dimensional function, for any positive,even value of n:2-22

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

Saved successfully!

Ooh no, something went wrong!