What Is Optimization Toolbox?
What Is Optimization Toolbox? What Is Optimization Toolbox?
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
- Page 1 and 2: Optimization Toolbox 3User’s Guid
- Page 3: Revision HistoryNovember 1990 First
- Page 6 and 7: Acknowledgments
- Page 8 and 9: Nonlinear Equations with Finite-Dif
- Page 10 and 11: Quadratic Programming (QP) Subprobl
- Page 12 and 13: Specifying the Options ............
- Page 14 and 15: xivContents
- Page 16 and 17: 1 Getting StartedWhat Is Optimizati
- Page 18 and 19: 1 Getting StartedOptimization Examp
- Page 20 and 21: 1 Getting Started[x, fval] =lsqlin(
- Page 22 and 23: 2 TutorialLarge-Scale Examples (p.
- Page 24 and 25: 2 TutorialMinimization (Continued)T
- Page 26 and 27: 2 TutorialUsing the Optimization Fu
- Page 28 and 29: 2 TutorialA choice of line search s
- Page 30 and 31: 2 TutorialThe tutorial uses the fun
- Page 32 and 33: 2 Tutorialfunction evaluations. See
- Page 34 and 35: 2 TutorialTo restrict x inEquation2
- Page 36 and 37: 2 Tutorialceq=[];DCeq = [ ];G conta
- Page 38 and 39: 2 TutorialEquality Constrained Exam
- Page 40 and 41: 2 Tutorialfunction y = findzero(b,
- Page 44 and 45: 2 Tutorialcomponents.');end% Evalua
- Page 46 and 47: 2 TutorialThe example produces the
- Page 48 and 49: 2 TutorialClosed-Loop ResponseThe p
- Page 50 and 51: 2 Tutorialfunction [Kp,Ki,Kd] = run
- Page 52 and 53: 2 TutorialThe resulting closed-loop
- Page 54 and 55: 2 Tutorialcalling the simulation tw
- Page 56 and 57: 2 TutorialThe last value shown in t
- Page 58 and 59: 2 TutorialStep 1: Write an M-file f
- Page 60 and 61: 2 TutorialLarge-Scale Examples•
- Page 62 and 63: 2 TutorialNote The following table
- Page 64 and 65: 2 TutorialLarge-Scale Problem Cover
- Page 66 and 67: 2 Tutorialoptimset('Display','iter'
- Page 68 and 69: 2 Tutorialeither) then, in this pro
- Page 70 and 71: 2 TutorialNonlinear Least-Squares w
- Page 72: 2 TutorialThe problem is to find x
- Page 75 and 76: Large-Scale Examplesto zero (for fm
- Page 77 and 78: Large-Scale Examples024681012141618
- Page 79 and 80: Large-Scale Examplesfval =270.4790o
- Page 81 and 82: Large-Scale Examplesans =1.1885e-01
- Page 83 and 84: Large-Scale ExamplesW = Hinfo*Y - V
- Page 85 and 86: Large-Scale Exampleswere not the sa
- Page 87 and 88: Large-Scale Examplestradeoff is ben
- Page 89 and 90: Large-Scale Examplesfunction W = qp
- Page 91 and 92: Large-Scale Examples% RUNQPBOX4PREC
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