The MPC Simulink Library A. Bemporad M. Morari N. L. Ricker User's Guide Version 1
The MPC Simulink Library User’s Guide Version 1 A. Bemporad M. Morari N. L. Ricker
Preface Disclaimer State of Development The MPC Simulink Library is in a developmental(beta)stage. It is not an official MathWorks product. It has been teste extensively, but it is likely that some problems remain. Please review all calculations with a critical eye We will also be improving features in response to your comments In Case of Difficulty This beta version of the MPC Simulink Library is not being supported by The MathWorks. If you encounter a problem, please check the FAQ (see"Updates"below). If that doesnt help, please send a detailed description by e-mail to A Bemporad at the following address bemporadeaut. ee ethz. ch He would also be happy to have your suggestions for improvements in the usability of the MPC Simulink Library, its documentation, and the MPC Toolbox in general Updates The FAQ and latest beta version of the MPC Simulink Library will be maintained for download at http://control.ethz./-bemporad/toolbox/mpclib.html Ackn。 wledgements We appreciate the help of Federica Rusconi, Domenico Mignone, Carles Pedret Ferre, Adrian Toller, Konrad Stadler Tobias raithel, Kazuro Tsuda, Jay lee, Pascal Gahinet, and greg wolodkin
vi Preface Disclaimer State of Development The MPC Simulink Library is in a developmental (beta) stage. It is not an official MathWorks product. It has been tested extensively, but it is likely that some problems remain. Please review all calculations with a critical eye. We will also be improving features in response to your comments. In Case of Difficulty This beta version of the MPC Simulink Library is not being supported by The MathWorks. If you encounter a problem, please check the FAQ (see "Updates" below). If that doesn’t help, please send a detailed description by e-mail to A. Bemporad at the following address: bemporad@aut.ee.ethz.ch He would also be happy to have your suggestions for improvements in the usability of the MPC Simulink Library, its documentation, and the MPC Toolbox in general. Updates The FAQ and latest beta version of the MPC Simulink Library will be maintained for download at http://control.ethz./~bemporad/toolbox/mpclib.html Acknowledgements We appreciate the help of Federica Rusconi, Domenico Mignone, Carles Pedret Ferre, Adrian Toller, Konrad Stadler, Tobias Raithel, Kazuro Tsuda, Jay Lee, Pascal Gahinet, and Greg Wolodkin
Introduction MPC Simulink Library Overview Options 1-2 Starting the mPc simulink Librar System Requirements Installation Quick Start eisurely start MPC Fundamentals
1 Introduction MPC Simulink Library Overview . . . . . . . . . . . . . . . 1-2 Options . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Starting the MPC Simulink Library . . . . . . . . . . . . . . 1-3 System Requirements . . . . . . . . . . . . . . . . . . . . 1-3 Installation . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Quick Start . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Leisurely Start . . . . . . . . . . . . . . . . . . . . . . . 1-4 MPC Fundamentals . . . . . . . . . . . . . . . . . . . . 1-5
MPC Simulink Library Overview The MPC Simulink Library is designed to help you analyze and simulate Model Predictive Control(MPC)modules within any Simulink description of the environment. ptions The MPC Simulink Library supports four controller blocks, to be connected in feedback with the system to regulate. Each block receives output measurements and returns the control input action to the system. The four blocks are the following Regulator. The MPC block regulates the output of the system to zero Controller. An additional reference signal is received by the MPC controller. The output of the system will track such a signal measured input disturbance signals entering the system is received by the mPC controller and taken into account in the computation of the control action Controller with Anticipation. Reference and measured disturbance signals are read from file. This allows knowing future samples when computing the control action 1-2
1 Introduction 1-2 MPC Simulink Library Overview The MPC Simulink Library is designed to help you analyze and simulate Model Predictive Control (MPC) modules within any Simulink description of the environment. Options The MPC Simulink Library supports four controller blocks, to be connected in feedback with the system to regulate. Each block receives output measurements and returns the control input action to the system. The four blocks are the following: • Regulator. The MPC block regulates the output of the system to zero. • Controller. An additional reference signal is received by the MPC controller. The output of the system will track such a signal. • Controller with Measured Disturbance Rejection. An additional information about measured input disturbance signals entering the system is received by the MPC controller and taken into account in the computation of the control action. • Controller with Anticipation. Reference and measured disturbance signals are read from file. This allows knowing future samples when computing the control action
Starting the MPC Simulink Library System Requirement You ll need the following matlab software MPC Toolbox for MATLAB Version 5, including the MPC Simulink Library files (which are currently an add-on to the standard MPC Tools release MATLAB Version 5.3 or greater Simulink version 3.0 or greater · Control toolbox. Installation 1 Make a backup copy of your MPC Tools directory(which should be located in your MATLAB directory,e.g, MATLAB/toolbox/mpc). This will allow you to restore your original state if the GUI installation interferes in some unexpected way 2 Download the latest version of the MPC Simulink Library from http://control.ethz.ch/-bemporad/toolbox/mpclib.html Its a ZiP archive. Extract the contents using one of the many available utility programs (e.g, WinZip). This should create a new mpclib directory within the mpc directory IMPORTANTa The Zip archive is not a full version of mpc tools. You must have existing mpc/mpccmds and mpc/mpcdemos directories. The files from the archive only update these directories 3 Set your MATLAB Path so the new mpc/mpclib directory is included. Verify that the original mpc/mpccmds and mpc/mpcdemos directories are also on the path 4 Type"mpclib"in the MATLAB Command window. You should see the mPC Simulink library 5 If it doesn t work or you have other problems, see section In Case of Difficulty in the preface to this document
Starting the MPC Simulink Library 1-3 Starting the MPC Simulink Library System Requirements You’ll need the following MATLAB software: • MPC Toolbox for MATLAB Version 5, including the MPC Simulink Library files (which are currently an add-on to the standard MPC Tools release). • MATLAB Version 5.3 or greater. • Simulink Version 3.0 or greater. • Control Toolbox. Installation 1 Make a backup copy of your MPC Tools directory (which should be located in your MATLAB directory, e.g., MATLAB/toolbox/mpc). This will allow you to restore your original state if the GUI installation interferes in some unexpected way. 2 Download the latest version of the MPC Simulink Library from http://control.ethz.ch/~bemporad/toolbox/mpclib.html It’s a ZIP archive. Extract the contents using one of the many available utility programs (e.g., WinZip). This should create a new mpclib directory within the mpc directory. IMPORTANT: The ZIP archive is not a full version of MPC Tools. You must have existing mpc/mpccmds and mpc/mpcdemos directories. The files from the archive only update these directories. 3 Set your MATLAB Path so the new mpc/mpclib directory is included. Verify that the original mpc/mpccmds and mpc/mpcdemos directories are also on the path. 4 Type “mpclib” in the MATLAB Command window. You should see the MPC Simulink Library. 5 If it doesn’t work or you have other problems, see section In Case of Difficulty in the preface to this document
1 Type"mpclibdemo'"in the command window 2 Choose one of the tutorial examples 3 Examine the Simulink mdl file and the matlab m file for the demo 4 Try it with your own applications! ly Start The following sections of this document provide tutorial examples and additional details If possible, work through the steps in MATLAB/Simulink as you read
1 Introduction 1-4 Quick Start 1 Type “mpclibdemo” in the command window. 2 Choose one of the tutorial examples. 3 Examine the Simulink MDL file and the Matlab M file for the demo. 4 Try it with your own applications! Leisurely Start The following sections of this document provide tutorial examples and additional details. If possible, work through the steps in MATLAB/Simulink as you read
MPC Fundamentals MPC Fundamentals This section reviews MPC concepts and defines key terms. If you re already familiar with MPC you may prefer to read Chapter 2, "MPC Worksheet Basics"next Overview: single-input, single-output(SISO)MPC Figure 1-l shows a situation in which MPC is trying to hold a single variable, y, at a target value, r, by adjusting the"manipulated variable"(or"")u See Table 1-1 for a brief description of the signals appearing in Figure 1-1 The box labeled"plant"is the real process or mechanism that produces y. It responds to changes in u as well as to two types of disturbance signals: measured, v, and unmeasured, d (Some applications have unmeasured disturbances only; the v signal is optional. The unmeasured disturbance represents the usual mysterious events that upset plant operation, causing variations in y. The only sign that such an event has occured is a change in the measured output,y Measured Disturbance Noise Actuator MPC Plant Disturbance Measured Output( Controlled Variable) Figure 1-1 Block diagram of a single-input, single-output MPC application
MPC Fundamentals 1-5 MPC Fundamentals This section reviews MPC concepts and defines key terms. If you’re already familiar with MPC you may prefer to read Chapter 2, “MPC Worksheet Basics” next. Overview: single-input, single-output (SISO) MPC Figure 1-1 shows a situation in which MPC is trying to hold a single variable, , at a target value, r, by adjusting the “manipulated variable” (or “actuator”) u. See Table 1-1 for a brief description of the signals appearing in Figure 1-1. The box labeled “plant” is the real process or mechanism that produces . It responds to changes in u as well as to two types of disturbance signals: measured, v, and unmeasured, d. (Some applications have unmeasured disturbances only; the v signal is optional.) The unmeasured disturbance represents the usual mysterious events that upset plant operation, causing variations in . The only sign that such an event has occured is a change in the measured output, y. Figure 1-1 Block diagram of a single-input, single-output MPC application. y y y + + MPC Plant v r y d z y y u v Measured Disturbance Measured Output (Controlled Variable) Noise Setpoint Unmeasured Disturbance Actuator Plant Output
ntre Table 1-1 Summary of MPC signals(see also Figure 1-1). Symbol Description d Unmeasured disturbance. a disturbance unknown to MPC that affects the plant output. MPC provides feedback compensation r Setpoint (or reference signal). The target value for the Actuator (or manipulated variable). The signal MPC adjusts in order to achieve its control objectives Measured disturbance(optional). MPC feedforward compensation adjusts for such disturbances as they occur to minimize their impact on the controlled variable Controlled variable( or plant output). The signal to be held at the setpoint. This is the"true"value, uncorrupted by measurement noise Measurement of the controlled variable. Used to estimate the true value, y z Measurement noise Represents electrical noise, sampling errors,drifting calibration, and other effects that reduce the accuracy of the measurement The measured disturbance also affects y. The MPC block includes models of the way in which v and u affect y(symbolically, v-y and u-y). It uses this information to calculate u adjustments that keep y at its setpoint in spite of the(known)disturbance. This calculation considers the effect of any known constraints on the adjustments(e.g,an actuator at its upper or lower bound). If the models are accurate and the plant responds quickly to u, this"feedforward" compensation counteracts the effect of v perfectly
1 Introduction 1-6 The measured disturbance also affects . The MPC block includes models of the way in which v and u affect (symbolically, and ). It uses this information to calculate u adjustments that keep at its setpoint in spite of the (known) disturbance. This calculation considers the effect of any known constraints on the adjustments (e.g., an actuator at its upper or lower bound). If the models are accurate and the plant responds quickly to u, this “feedforward” compensation counteracts the effect of v perfectly. Table 1-1 Summary of MPC signals (see also Figure 1-1). Symbol Description d Unmeasured disturbance. A disturbance unknown to MPC that affects the plant output. MPC provides feedback compensation for such disturbances. r Setpoint (or reference signal). The target value for the controlled variable. u Actuator (or manipulated variable). The signal MPC adjusts in order to achieve its control objectives. v Measured disturbance (optional). MPC feedforward compensation adjusts for such disturbances as they occur to minimize their impact on the controlled variable. Controlled variable (or plant output). The signal to be held at the setpoint. This is the “true” value, uncorrupted by measurement noise. y Measurement of the controlled variable. Used to estimate the true value, . z Measurement noise. Represents electrical noise, sampling errors, drifting calibration, and other effects that reduce the accuracy of the measurement. y y y y v y ® u y ® y
MPC Fundamentals NOTE: One may also specify bounds on y. These constraint-handling properties are a distinguishing feature of MPC and can be particularly valuable when one has multiple control objectives to be achieved via multiple adjustments In reality, however, model imperfections, plant limitations, and unmeasured disturbances cause the measurement, y, to deviate from its expected value. Thus, MPC uses the output measurement and a"disturbance model"(d->y)to predict future changes in y. It then uses its u>y model to calculate appropriate adjustments(a form of feedback compensation). This calculation also considers the known constraints Various types of "noise" can corrupt the measurement. The signal z in Figure 1-1 represents such effects. They may vary randomly about a zero mean or exhibit a non-zero, drifting bias.MPC uses a :>y model in combination with its d-j model to remove the estimated noise component of the measurement("filtering") The above feedforward/feed back actions are mPC's"regulator mode. MPC also has a servo" mode, i.e., it adjusts u such that y tracks a time-varying setpoint. The tracking accuracy depends on the plant characteristics(including constraints), the accuracy of the l-y model, and whether or not future setpoint variations can be anticipated, i.e., known Details: siso case Sampling period and sampling instants MPC operates at discrete intervals of Af time units, the"sampling period. " Suppose that MPC starts at time t=0. The "sampling instants"are the times at which MPC adjusts the manipulated variable, u. They are integer multiples of the sampling period: 0, 4t, 24t, 341, kAt, where the integer index, k, represents the current sampling instant
MPC Fundamentals 1-7 NOTE: One may also specify bounds on . These constraint-handling properties are a distinguishing feature of MPC and can be particularly valuable when one has multiple control objectives to be achieved via multiple adjustments. In reality, however, model imperfections, plant limitations, and unmeasured disturbances cause the measurement, y, to deviate from its expected value. Thus, MPC uses the output measurement and a “disturbance model” ( ) to predict future changes in . It then uses its model to calculate appropriate adjustments (a form of “feedback” compensation). This calculation also considers the known constraints. Various types of “noise” can corrupt the measurement. The signalz in Figure 1-1 represents such effects. They may vary randomly about a zero mean or exhibit a non-zero, drifting bias. MPC uses a model in combination with its model to remove the estimated noise component of the measurement (“filtering”). The above feedforward/feedback actions are MPC’s “regulator” mode. MPC also has a “servo” mode, i.e., it adjusts u such that tracks a time-varying setpoint. The tracking accuracy depends on the plant characteristics (including constraints), the accuracy of the model, and whether or not future setpoint variations can be anticipated, i.e., known in advance. Details: SISO case Sampling period and sampling instants MPC operates at discrete intervals of Dt time units, the “sampling period.” Suppose that MPC starts at time t = 0. The “sampling instants” are the times at which MPC adjusts the manipulated variable, u. They are integer multiples of the sampling period: 0,Dt, 2Dt, 3Dt, ..., kDt, where the integer index, k, represents the current sampling instant. y d y ® y u y ® z y ® d y ® y u y ®
ast t future Reference r(t+k) Predicted outputs y(t+kt) output horizon t+l Manipulated u(t+k Inputs input horizon Figure 1-2 The MPC problem at the the sampling instant t An mPc pling instant for some time; k is the current sampling instant. The current measured output, 3, and a Figure 1-2 shows the state of a hypothetical SISO MPC system which has been operatin previous measurements, yk-l,yk.2,,are known and are the filled circles in Figure 1-2(a) The current measured disturbance, d, and its past values are also known(not shown
1 Introduction 1-8 Figure 1-2 The MPC problem at the the sampling instant t. An MPC sampling instant Figure 1-2 shows the state of a hypothetical SISO MPC system which has been operating for some time; k is the current sampling instant. The current measured output, yk , and previous measurements, yk-1, yk-2, ..., are known and are the filled circles in Figure 1-2 (a). The current measured disturbance, dk , and its past values are also known (not shown). (b) (a) input horizon output horizon t t+1 past future t t+1 t+m t+p Predicted outputs y(t+k|t) t+m t+p Manipulated (t u k+ ) Inputs Reference r(t+k) umin umax