Model Predictive Control Toolbox™Getting Started GuideAlberto BemporadManfred MorariN. Lawrence RickerR2015a
1 Introduction1-2Model Predictive Control Toolbox Product DescriptionDesign and simulate model predictive controllersModel Predictive Control Toolbox™
3 Designing Controllers Using the Design Tool GUI3-50Robustness Test, Accurate Model (1) and Perturbed Model (2)Note MIMO applications are usually mor
Design Controller for Plant with Delays3-51Design Controller for Plant with DelaysThis example shows how to design an MPC controller for a plant with
3 Designing Controllers Using the Design Tool GUI3-52It is good practice to specify the prediction and control horizons such thatP M t td max- D?,/Her
Design Controller for Plant with Delays3-53Specify the simulation settings as follows:• In the Duration box, enter 50.• In the Setpoints table, for t
3 Designing Controllers Using the Design Tool GUI3-54The plant outputs plot shows that the first output does not respond for the first minute,which co
Design Controller for Plant with Delays3-55The plant inputs plot shows that the initial input moves are more than five timesthe final change. Also, t
3 Designing Controllers Using the Design Tool GUI3-56In the tree, select Scenarios > Scenario1.Click Simulate.
Design Controller for Plant with Delays3-57The initial input moves are much smaller and the moves are less oscillatory. The trade-off is a slower out
3 Designing Controllers Using the Design Tool GUI3-58Design Controller for Nonsquare PlantA nonsquare plant has an unequal number of manipulated varia
Design Controller for Nonsquare Plant3-59More Manipulated Variables Than OutputsIn this situation, default Model Predictive Control Toolbox settings
Acknowledgments1-3AcknowledgmentsMathWorks would like to acknowledge the following contributors to Model PredictiveControl Toolbox.Alberto BemporadPr
4Designing Controllers Using theCommand Line• “Design Controller at the Command Line” on page 4-2• “Simulate Controller with Nonlinear Plant” on page
4 Designing Controllers Using the Command Line4-2Design Controller at the Command LineIn this section...“Create a Controller Object” on page 4-2“View
Design Controller at the Command Line4-3View and Alter Controller PropertiesOnce you've defined an MPC object, it's easy to alter its prope
4 Designing Controllers Using the Command Line4-4 Min: -Inf Max: Inf MinECR: 0 MaxECR: 0 RateMin: -Inf R
Design Controller at the Command Line4-5You can also specify time-varying weights and constraints. The time-varying weights andconstraints are define
4 Designing Controllers Using the Command Line4-6In this example, the review command found two potential issues in this design. Thefirst warning asks
Design Controller at the Command Line4-7T = 26;r = [2 0];sim(MPCobj,T,r);This simulates the closed-loop response for a duration of 26 control interva
4 Designing Controllers Using the Command Line4-8Save Calculated ResultsIf you'd like to save simulation results in your workspace, use the follo
Simulate Controller with Nonlinear Plant4-9Simulate Controller with Nonlinear PlantYou can use sim to simulate a closed-loop system consisting of a l
1 Introduction1-4Bibliography[1] Allgower, F., and A. Zheng, Nonlinear Model Predictive Control, Springer-Verlag,2000.[2] Camacho, E. F., and C. Bordo
4 Designing Controllers Using the Command Line4-10Example Code for Successive LinearizationIn the following code, the simulation begins at the CSTR mo
Simulate Controller with Nonlinear Plant4-11 % Define MPC Toolbox controller for the latest model MPCobj = mpc(Model, Ts); MPCobj.W.Outp
4 Designing Controllers Using the Command Line4-12figure(2)plot(tsave,usave(:,3));title('Coolant Temperature')CSTR Results and DiscussionThe
Simulate Controller with Nonlinear Plant4-13• Function linearize relinearizes the plant as its state evolves. This function wasdiscussed previously i
4 Designing Controllers Using the Command Line4-14controller design, always have nominal zero values. As they are unmeasured, thecontroller cannot be
Control Based On Multiple Plant Models4-15Control Based On Multiple Plant ModelsThe “Nonlinear CSTR Application” on page 4-9 shows how updates to the
4 Designing Controllers Using the Command Line4-16Animation of the Multi-Model ExampleIn order to achieve its objective, the controller can adjust the
Control Based On Multiple Plant Models4-17variable, and a spring constant calibration signal, which is a measured disturbanceinput.A1=[0 1;-k1/M1 -b1
4 Designing Controllers Using the Command Line4-18Simulating Controller PerformanceBlock Diagram of the Two-Model Example shows the Simulink block dia
Control Based On Multiple Plant Models4-19• A simulation of a contact sensor. When the two masses have the same position, theCompare to Constant bloc
2Building Models• “MPC Modeling” on page 2-2• “Signal Types” on page 2-8• “Construct Linear Time Invariant (LTI) Models” on page 2-9• “Specify Multi-I
4 Designing Controllers Using the Command Line4-20When the switch input is 1 the block automatically activates the first controller listed(MPC1), whic
Control Based On Multiple Plant Models4-21In the upper plot, the cyan curve is the desired position. It starts at –5. The M1 position(yellow) starts
4 Designing Controllers Using the Command Line4-22When the desired position changes step-wise to 5, the two masses separate briefly (withappropriate s
Control Based On Multiple Plant Models4-23If we put MPC1 in charge exclusively, we instead see sluggish movements that fail tosettle at the desired p
4 Designing Controllers Using the Command Line4-24Compute Steady-State GainThis example shows how to analyze a Model Predictive Controller using cloff
Extract Controller4-25Extract ControllerThis example shows how to obtain an LTI representation of an unconstrained ModelPredictive Control Toolbox co
4 Designing Controllers Using the Command Line4-26Bibliography[1] Lee, J. H. and N. L. Ricker, “Extended Kalman Filter Based Nonlinear ModelPredictive
Signal Previewing4-27Signal PreviewingBy default, a Model Predictive Controller assumes the current reference and measuredplant disturbance signals w
4 Designing Controllers Using the Command Line4-28Run-Time Constraint UpdatingConstraint bounds can change during controller operation. The mpcmove,mp
Run-Time Weight Tuning4-29Run-Time Weight TuningThere are two ways to perform tuning experiments using Model Predictive ControlToolbox software:• Mod
2 Building Models2-2MPC ModelingIn this section...“Plant Model” on page 2-2“Input Disturbance Model” on page 2-4“Output Disturbance Model” on page 2-5
4 Designing Controllers Using the Command Line4-30More About• “Signal Previewing” on page 4-27
5Designing and Testing Controllers inSimulink• “Design Controller in Simulink” on page 5-2• “Test an Existing Controller” on page 5-15• “Schedule Cont
5 Designing and Testing Controllers in Simulink5-2Design Controller in SimulinkThis example shows how to design a model predictive controller in Simul
Design Controller in Simulink5-3• CSTR Temperature — Temperature of the limiting reactant in the product stream.• Concentration — Concentration of th
5 Designing and Testing Controllers in Simulink5-4The MPC Controller box is blank. No controller has been designed yet.Click Design. The MPC Question
Design Controller in Simulink5-5For this example, use the default values of this dialog box. Click OK. The softwareperforms multiple tasks to design
5 Designing and Testing Controllers in Simulink5-6In the MPC open loop plant 1 node of the tree, click Operating Point.The software found a steady-sta
Design Controller in Simulink5-7In the tree of the Control and Estimation Tools Manager, click Operating Points. Then,click the Compute Operating Poi
5 Designing and Testing Controllers in Simulink5-8Click Compute Operating Points.The Computation Results tab displays the operating point search resul
Design Controller in Simulink5-9Confirm that Operating Point is the desired operating point. In the tree, clickOperating Point in the Operating Point
MPC Modeling2-3• Identified models (requires System Identification Toolbox™): idss, idtf, idproc,and idpoly.The MPC controller performs all the estim
5 Designing and Testing Controllers in Simulink5-10Click OK. The software calculates the linearized plant model, MPC open loop plant 2.This model is v
Design Controller in Simulink5-11These values correspond to the desired operating point.Update Controller to Use New Plant ModelIn the tree, click Co
5 Designing and Testing Controllers in Simulink5-12Alternatively, delete MPC open loop plant 1, the model computed at default operatingpoint. Deleting
Design Controller in Simulink5-13Tip After you export the controller, you can examine it for design errors and stabilityproblems using the review fun
5 Designing and Testing Controllers in Simulink5-14The decrease in feed concentration reduces heat generation. If the controller were absent,the react
Test an Existing Controller5-15Test an Existing ControllerIf you have already designed a model predictive controller to use with a Simulink plant,to
5 Designing and Testing Controllers in Simulink5-16Schedule Controllers at Multiple Operating PointsIn this section...“A Two-Model Plant” on page 5-16
Schedule Controllers at Multiple Operating Points5-17In the above, mass M2 is uncontrollable. It responds solely to the spring pulling it to theleft.
5 Designing and Testing Controllers in Simulink5-18Define the system parameters.M1 = 1; % massM2 = 5; % massk1 = 1; % spring constantk2 = 0.1; % sprin
Schedule Controllers at Multiple Operating Points5-19Ts = 0.2;p = 20;m = 1;MPC1 = mpc(sys1,Ts,p,m); % Controller for M1 detached from M2 MPC2 = mpc(s
2 Building Models2-4• up — Dimensionless plant input variables.• up — Dimensionless plant output variables.The resulting plant model has the following
5 Designing and Testing Controllers in Simulink5-20The lower part contains the following key elements:• A pulse generator that supplies the desired M1
Schedule Controllers at Multiple Operating Points5-21When the switch input is 1, the block automatically activates the first controllerthat is listed
5 Designing and Testing Controllers in Simulink5-22y2initial = 10;open('mpc_switching');sim('mpc_switching',Tstop);The figure belo
Schedule Controllers at Multiple Operating Points5-23
5 Designing and Testing Controllers in Simulink5-24In the upper plot, the cyan curve is the desired position. It starts at -5. The M1position (yellow)
Schedule Controllers at Multiple Operating Points5-25
5 Designing and Testing Controllers in Simulink5-26When the masses are disconnected, as at the start, MPC2 applies excessive force andthen over-compen
MPC Modeling2-5You can provide the input disturbance model as an LTI state-space (ss), transferfunction (tf), or zero-pole-gain (zpk) object. See “Co
2 Building Models2-6Here, Aod, Bod, Cod, and Dod are constant state space matrices and:• xod(k) — nxod ≥ 1 output disturbance model states.• yod(k) —
MPC Modeling2-7Note: If the minimum eigenvalue of D Dn nT is less than 1x10–8, the MPC controller adds1x10–4 to each diagonal element of Dn. This adj
How to Contact MathWorksLatest news:www.mathworks.comSales and services:www.mathworks.com/sales_and_servicesUser community:www.mathworks.com/matlabcen
2 Building Models2-8Signal TypesInputsThe plant inputs are the independent variables affecting the plant. As shown in “MPCModeling” on page 2-2, there
Construct Linear Time Invariant (LTI) Models2-9Construct Linear Time Invariant (LTI) ModelsIn this section...“Transfer Function Models” on page 2-9“Z
2 Building Models2-10Gtf1 = tf([1 2], [1 1 10], 'OutputDelay', 1.5)Control System Toolbox software builds and displays it as follows:Transfe
Construct Linear Time Invariant (LTI) Models2-11CSTR SchematicMeasurement of reactant concentrations is often difficult, if not impossible. Let usass
2 Building Models2-12C = [0 1 1 0];D = zeros(2,2);CSTR = ss(A,B,C,D);This defines a continuous-time state-space model. If you do not specify a sam
Construct Linear Time Invariant (LTI) Models2-13output. (See “Signal Types” on page 2-8 for definitions.) For example, the code specifiesthat input 2
2 Building Models2-14Input and Output TypesGeneral CaseAs mentioned in “Signal Types” on page 2-8, Model Predictive Control Toolbox softwaresupports t
Construct Linear Time Invariant (LTI) Models2-15Use setmpcsignals to make type definition. For exampleCSTR = setmpcsignals(CSTR, 'UD', 2, &
2 Building Models2-16Example Intended Resultzero(CSTR) Compute CSTR model's transmission zeros.
Specify Multi-Input Multi-Output (MIMO) Plants2-17Specify Multi-Input Multi-Output (MIMO) PlantsMost Model Predictive Control Toolbox applications in
Revision HistoryOctober 2004 First printing New for Version 2.1 (Release 14SP1)March 2005 Online only Revised for Version 2.2 (Release 14SP2)September
2 Building Models2-18 Distillate Purity: exp(-1*s) * ---------- 16.7 s + 1 6.6
CSTR Model2-19CSTR ModelThe linearized model of a continuous stirred-tank reactor (CSTR) involving anexothermic (heat-generating) reaction is represe
2 Building Models2-20xCTuTCyTCA cAi A=¢¢ÈÎ͢˚˙=¢¢ÈÎ͢˚˙=¢¢ÈÎ͢˚˙ ,Aa aa aBb bb bC D=ÈÎ͢˚˙=ÈÎ͢˚˙=ÈÎ͢˚˙=11 1221 2211 1221 220 11 00 000 0ÈÎ͢˚
Linearize Simulink Models2-21Linearize Simulink ModelsGenerally, real systems are nonlinear. To design an MPC controller for a nonlinearsystem, you m
2 Building Models2-22opspec = operspec('CSTR_OpenLoop');opspec = addoutputspec(opspec,'CSTR_OpenLoop/CSTR',2);opspec.Outputs(1).Kn
Linearize Simulink Models2-23For example, the following code specifies the coolant temperature as 305 K and initialguess values of the C_A and T_K st
2 Building Models2-24io(1) = linio('CSTR_OpenLoop/Feed Concentration', 1, 'input');io(2) = linio('CSTR_OpenLoop/Feed Temperat
Linearize Simulink Models2-25For this example, the CSTR model, CSTR_OpenLoop, is linearized.Open Simulink Modelsys = 'CSTR_OpenLoop';open_s
2 Building Models2-26To specify a signal as a:• Linearization input, right-click the signal in the Simulink model window and selectLinear Analysis Poi
Linearize Simulink Models2-27Create and Verify Operating PointIn the Trim the model dialog box, click Start trimming.The operating point op_trim1 dis
2 Building Models2-28In the Edit dialog box, select the Input tab.The coolant temperature at steady state is 299 K, as desired.Linearize ModelIn the L
Linearize Simulink Models2-29The step response from feed concentration to output CSTR/2 displays an interestinginverse response. An examination of th
2 Building Models2-30• “Design Controller in Simulink”• “Design Controller at the Command Line”
Identify Plant from Data2-31Identify Plant from DataThis example shows how to identify a linear plant model using measured data.When you have measure
2 Building Models2-32dry_data_detrended = detrend(dry_data);Estimate a linear plant model.You can use System Identification Toolbox software to estima
Design Controller for Identified Plant2-33Design Controller for Identified PlantThis example shows how to design a model predictive controller for a
2 Building Models2-34To view the structure of the model predictive controller, type controller at theMATLAB command prompt.See AlsompcRelated Examples
Design Controller Using Identified Model with Noise Channel2-35Design Controller Using Identified Model with Noise ChannelThis example shows how to d
2 Building Models2-36When you use the 'augmented' input argument, ss creates two input groups,Measured and Noise, for the measured and noise
Working with Impulse-Response Models2-37Working with Impulse-Response ModelsYou can use System Identification Toolbox software to estimate finite ste
vContentsIntroduction1Model Predictive Control Toolbox Product Description . . . . 1-2Key Features . . . . . . . . . . . . . . . . . . . . . . . . . .
2 Building Models2-38Bibliography[1] Allgower, F., and A. Zheng, Nonlinear Model Predictive Control, Springer-Verlag,2000.[2] Camacho, E. F., and C. B
3Designing Controllers Using theDesign Tool GUI• “Design Controller Using the Design Tool” on page 3-2• “Test Controller Robustness” on page 3-48• “De
3 Designing Controllers Using the Design Tool GUI3-2Design Controller Using the Design ToolIn this section...“Start the Design Tool” on page 3-2“Load
Design Controller Using the Design Tool3-3Model Predictive Control Toolbox Design Tool Initial ViewLoad a Plant ModelThe first step in the design is
3 Designing Controllers Using the Design Tool GUI3-4The following example uses the CSTR model described in “CSTR Model” on page 2-19.Verify that the L
Design Controller Using the Design Tool3-5Model Predictive Control Toolbox Design Tool's Signal Definition ViewSignal Property SpecificationsThe
3 Designing Controllers Using the Design Tool GUI3-6Note Once you leave this view, if you subsequently change a signal type, you will haveto restart t
Design Controller Using the Design Tool3-7Plant Models View with CSTR Model SelectedViewing Your ControllersNext, select Controllers. The view shown
3 Designing Controllers Using the Design Tool GUI3-8Controllers ViewThe table at the top of Controllers View lists all the controllers you've def
Design Controller Using the Design Tool3-9The buttons shown in Controllers View let you do the following:• Import a controller designed previously an
vi ContentsCSTR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19Linearize Simulink Models . . . . . . . . . .
3 Designing Controllers Using the Design Tool GUI3-10Scenarios ViewWhenever you select the Scenarios node, you see a table summarizing your currentsce
Design Controller Using the Design Tool3-11• “Running a Simulation” on page 3-12• “Open-Loop Simulations” on page 3-15Defining Simulation ConditionsT
3 Designing Controllers Using the Design Tool GUI3-12CSTR Temperature Setpoint Change ScenarioRunning a SimulationTo run a simulation, do one of the f
Design Controller Using the Design Tool3-13Plant Outputs for T Setpoint Scenario with Added Data Markers
3 Designing Controllers Using the Design Tool GUI3-14Plant Inputs for the T Setpoint ScenarioPlant Outputs for T Setpoint Scenario with Added Data Mar
Design Controller Using the Design Tool3-15it. Left-click in a graph's white space to erase its markers. For more information on datamarkers, se
3 Designing Controllers Using the Design Tool GUI3-16Using one of these, simulate the scenario (click its Simulate button). The outputresponse plot sh
Design Controller Using the Design Tool3-17This adds a pulse to the T output. The pulse begins at time t = 10, and lasts 20 timeunits. Its height is
3 Designing Controllers Using the Design Tool GUI3-18By default, each plant signal plots in its own graph area (as shown above). If thesimulation is c
Design Controller Using the Design Tool3-19Data Marker ContentsEach data marker provides information about the selected point, as follows:• Response
viiMore Manipulated Variables Than Outputs . . . . . . . . . . . . 3-59Designing Controllers Using the Command Line4Design Controller at the Command L
3 Designing Controllers Using the Design Tool GUI3-20To delete a single data marker, right-click it and select the Delete option.Right-Click OptionsRi
Design Controller Using the Design Tool3-21Revising a ScenarioIf you modify and recalculate a scenario, its data are replotted, replacing the origina
3 Designing Controllers Using the Design Tool GUI3-22Normalizing Response AmplitudesWhen you're using the Channel Grouping: All option, you might
Design Controller Using the Design Tool3-23Change Controller SettingsThe simulations shown in Plant Outputs for T Setpoint Scenario with Added DataMa
3 Designing Controllers Using the Design Tool GUI3-24• Plant model specifies the LTI model to be used for controller predictions.• Control interval se
Design Controller Using the Design Tool3-25• In the Output weights section, change the reactant concentration's Weight (lastentry in the second
3 Designing Controllers Using the Design Tool GUI3-26Improved Setpoint Tracking for CSTR TemperatureOn the other hand, the reactant concentration, CA,
Design Controller Using the Design Tool3-27the number of plant outputs, wyj is the weight for output j, and the term [rj(k + i) – yj(k +i)] is a pred
3 Designing Controllers Using the Design Tool GUI3-28than the cumulative value. Increasing this weight forces the controller to make smaller,more caut
Design Controller Using the Design Tool3-29S k w u k i uu juj jjniMmv( ) [ ( ) ]= + - -{ }==ÂÂ 1211where wuj is the input weight and uj is the nomin
viii ContentsDesigning and Testing Controllers in Simulink5Design Controller in Simulink . . . . . . . . . . . . . . . . . . . . . . . . . 5-2Test an
3 Designing Controllers Using the Design Tool GUI3-30Set Number of moves computed per step to 2. Verify that Blocking allocationwithin prediction hori
Design Controller Using the Design Tool3-31Simulate each of the three scenarios. When you run the first, new plot windows open.Leave them open when y
3 Designing Controllers Using the Design Tool GUI3-32Results for T Setpoint 3 are very similar to those shown in Improved Setpoint Trackingfor CSTR Te
Design Controller Using the Design Tool3-33Entering CSTR Manipulated Variable ConstraintsIf any simulation plot windows are open, close them (to forc
3 Designing Controllers Using the Design Tool GUI3-34CSTR Outputs, Unconstrained (1) and MVconstraints (2)CSTR Manipulated Variable, Unconstrained (1)
Design Controller Using the Design Tool3-35Copy this controller. Rename the copy OutputSteps. Click its Estimation tab. Theinitial view should be as
3 Designing Controllers Using the Design Tool GUI3-36Default Input Disturbance Settings for CSTRIn this case the disturbance magnitude is nonzero, and
Design Controller Using the Design Tool3-37In general, if your plant model includes unmeasured disturbance inputs, the toolboxdefault strategy will a
3 Designing Controllers Using the Design Tool GUI3-38CSTR Disturbance 1 ScenarioCopy Disturbance 1. Rename the copy Disturbance 2, and set its Control
Design Controller Using the Design Tool3-39The default controller expects unmeasured disturbances to enter as defined in thescenarios, so it's n
1Introduction• “Model Predictive Control Toolbox Product Description” on page 1-2• “Acknowledgments” on page 1-3• “Bibliography” on page 1-4
3 Designing Controllers Using the Design Tool GUI3-40For comparison, reset the two scenarios so that the only disturbance is a one-degree stepincrease
Design Controller Using the Design Tool3-41Similarly, start with a single scenario identical to CSTR Disturbance 1 Scenario, exceptthat its Controlle
3 Designing Controllers Using the Design Tool GUI3-42Constraint Softening Dialog BoxThe Output constraints section lists the output limits and their r
Design Controller Using the Design Tool3-43Constraint Softening Scenarios: 1 = None, 2 = Hard, 3 = SoftCurve 1 is without output constraints, which i
3 Designing Controllers Using the Design Tool GUI3-44In general, you'll have to experiment to determine the settings that provide appropriatetrad
Design Controller Using the Design Tool3-45The default behavior is to export the selected controller to the workspace. Click Exportto confirm. You ca
3 Designing Controllers Using the Design Tool GUI3-46Dialog Box for Saving a Controller Design ProjectThe default behavior saves the current project (
Design Controller Using the Design Tool3-47You could define the required MPC2 object in one of the following ways:• Import MPC2 from a MAT-file (assu
3 Designing Controllers Using the Design Tool GUI3-48Test Controller RobustnessIt's good practice to test your controller's sensitivity to p
Test Controller Robustness3-49Copy Accurate Model. Rename the copy Perturbed Model, and set its Plant option toCSTRp. Thus, both scenarios use the sa
Kommentare zu diesen Handbüchern