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 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

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

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

Saved successfully!

Ooh no, something went wrong!