What Is Optimization Toolbox?
What Is Optimization Toolbox? What Is Optimization Toolbox?
2 TutorialClosed-Loop ResponseThe problem is to design a feedback control loop that tracks a unit step inputto the system. The closed-loop plant is entered in terms of the blocks wherethe plant and actuator have been placed in a hierarchical Subsystem block.A Scope block displays output trajectories during the design process. SeeClosed-Loop Model on page 2-28.Closed-Loop Model2-28
Examples That Use Standard AlgorithmsOnewaytosolvethisproblemistominimizetheerrorbetweentheoutputand the input signal. The variables are the parameters of the ProportionalIntegral Derivative (PID) controller. If you only need to minimize the errorat one time unit, it would be a single objective function. But the goal isto minimize the error for all time steps from 0 to 100, thus producing amultiobjective function (one function for each time step).The routine lsqnonlin is used to perform a least-squares fit on the trackingoftheoutput. Thetrackingisperformed via an M-file function tracklsq,which returns the error signal yout, the output computed by calling sim,minus the input signal 1. Thecodefortracklsq, shown below, is contained inthe file runtracklsq.m, which is included in Optimization Toolbox.The function runtracklsq sets up all the needed values and then callslsqnonlin with the objective function tracklsq, which is nested insideruntracklsq. The variable options passed to lsqnonlin defines thecriteria and display characteristics. In this case you ask for output, use themedium-scale algorithm, and give termination tolerances for the step andobjective function on the order of 0.001.To run the simulation in the model optsim, thevariablesKp, Ki, Kd, a1, anda2 (a1 and a2 are variables in the Plant block) must all be defined. Kp, Ki, andKd are the variables to be optimized. The function tracklsq is nested insideruntracklsq so that the variables a1 and a2 aresharedbetweenthetwofunctions. The variables a1 and a2 are initialized in runtracklsq.The objective function tracklsq must run the simulation. The simulation canbe run either in the base workspace or the current workspace, that is, theworkspace of the function calling sim, which in this case is the workspace oftracklsq. In this example, the simset command is used to tell sim to run thesimulation in the current workspace by setting 'SrcWorkspace' to 'Current'.You can also choose a solver for sim using the simset function. The simulationis performed using a fixed-step fifth-order method to 100 seconds.When the simulation is completed, the variables tout, xout, andyout are nowin the current workspace (that is, the workspace of tracklsq). The Outportblock in the block diagram model puts yout into the current workspace at theend of the simulation.The following is the code for runtracklsq:2-29
- 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 42 and 43: 2 Tutorial3.7081Sharing Variables U
- Page 44 and 45: 2 Tutorialcomponents.');end% Evalua
- Page 46 and 47: 2 TutorialThe example produces the
- 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
- Page 93 and 94: Large-Scale Examplesalgorithm: 'lar
- Page 95 and 96: Large-Scale Examplescgiterations: 0
- Page 97 and 98: Large-Scale Examplesdoes not give a
2 TutorialClosed-Loop ResponseThe problem is to design a feedback control loop that tracks a unit step inputto the system. The closed-loop plant is entered in terms of the blocks wherethe plant and actuator have been placed in a hierarchical Subsystem block.A Scope block displays output trajectories during the design process. SeeClosed-Loop Model on page 2-28.Closed-Loop Model2-28