Want to create or adapt books like this? Learn more about how Pressbooks supports open publishing practices.
14 Model Predictive Controller
Hongbo Zhang
1) Overview of Model Predictive Control
A Model Predicative Controller (MPC) is an optimal controller. This controller is used in practical control applications to not only control a system but also thoroughly consider the constraints of the system. MPC has been extensively used for process industries, power systems, automotive, and aerospace engineering. Interestingly, MPC also accommodates filtering the noise in a system to ensure noises would not adversely impact the system control performance.
A discrete state-space model for MPC is typically represented as:
where:
x(k) is the state vector at time step k .
u(k) is the control input vector.
d(k) is the disturbance vector.
y(k) is the output vector.
A, B, Bd, and C are matrices that define the system dynamics.
w(k) and v(k) are process and measurement noise, respectively.
Figure 14.1 shows an example of random noises of a system.
Such a discrete state space model is similar to the state space modeled previously. A notable difference, however, does exist. In contrast to the previous method, where the noises of the system are not explicitly considered, with this model, the noises of the system (including w(k), the process noise, and v(k), the measurement noise), are well considered.
Of these two different types of noises considered, the process noises w(k) are the noises embedded in the system. These can be illustrated through an example. Given an autonomous driving system, the system noise refers to the road surface variation, wind gusts, sensor inaccuracies, and actuator imperfections. On the other hand, an example of the measurement noises v(k) include the random errors or disturbances that affect the accuracy of measurements taken by sensors or instruments. More specifically, the measurements noises include thermal measurement noise, quantization noise (for the digital systems when continuous signals are converted to the discrete digital values.), the shot noise (noises associated with electric charge), environmental noise (such as electromagnetic interference), interference from other signals (such as radio frequency interference (RFI) and electromagnetic interference (EMI)), and human error.
2) Using a Kalman Filter to Reduce Noise
In order for MPC to perform optimal control, the noise of the system needs to be removed. MPC achieves noise filtering through the use of a Kalman filter or extended state observer (ESO). In our book, we will focus on the use of a Kalman filter to estimate the states and disturbances. To use a Kalman filter to extract noise from the system, the following the steps are needed.
The MPC is an optimal controller. Therefore, it involves a few steps to solve the optimization problem.
(A) Prediction Step:
Predict the next state:
Predict the error covariance:
Here, P is the error covariance matrix and Q is the process noise covariance.
(B) Update Step:
Compute the Kalman gain:
Update the state estimate:
Update the error covariance matrix:
Here, R is the measurement noise covariance.
The key idea of the Kalman filter is to compute the Kalman gain K and update the state estimate by the introduction of the error of covariance. Following the precise estimate of the state, it becomes possible to reject the noises from the system.
3) Model Predictive Control (MPC) Modeling
In this section, let us explore MPC modeling without noise. Following the use of the Kalman filter to filter out the noise from the system and estimate the true states, the MPC solver starts to solve the quadratic optimization problem in order to perform the control of the system.
At each time step, MPC solves an optimization problem to determine the optimal control input u(k). The optimization problem can be formulated with cost function J.
subject to the following constraints:
where:
N is the prediction horizon
is the reference state.
Q and R are the weighting matrices for the state and control input, respectively.
are the state constraints and the control inputs.
(1) First Example: MPC with Kalman Filter Modeling
Given the state space listed as follows, let’s define a simple system with:
The discrete state space is subject to the following constraints:
Control input constraints:
State constraints:
With the above parameters, we will solve the problem using MPC. Note that this example does not consider noises.
With the above formulation, we need to use a Kalman filter to estimate the state by observing the values of the measurements .
The above equation can be easily formulated through the following MPC formulation:
The solution steps:
Initialization: start with the initial state and the initial state estimate
Kalman Filter Update: For each step, at each time step k, update the state estimate using the Kalman filter.
Prediction: For each step, predict future states using the state-space model and the updated state estimate.
Optimization: Solve the optimization problem to find the optimal control inputs.
Apply Control: Apply the first control input to the system.
Update: Update the state using the applied control input and repeat the process.
The solution code is shown below in part (3) Solutions
(2) Second Example: MPC with Kalman Filter Modeling
Given the same system with noises, the state space can presented as follows.
We’ll define the process noise covariance and measurement noise covariance as follows:
For the noisy system condition, once the process noises and measurement noises are in existence in the system, the cost function should consider it as well. The noises are the process noise covariance and measurement noise covariance as follows:
where:
is the predicted state at time step
is the reference state at time step
Q is the state weighting matrix
is the control input at time step
R is the control input weighting matrix
is a weighting factor for the control effort
is the trace of the process noise covariance matrix
is the trace of the measurement noise covariance matrix
The solution code is shown below in part (3) Solutions
(3) Solutions
Solution to first example: The code used to implement the MPC system without noises is shown in below. More specifically, the given state space without noises can be presented as follows.
Solution to second example: The noises are added to the system as shown below, both process noise and measurement noise. Note that, the process noise is added to the state equation since the process noise is more related to the physical conditions (states) of the system. However, the measurement noise is added to the output of the state space, since it is not state-related.
Now that the system has noises, a Kalman filter is needed to filter the noises from the system. The Kalman filter predicates the states, updates the error covariance matrix, and calculates the Kalman gain.
The new cost function considering the noises is then used to replace the original cost function. Note that, the new cost function includes Q, the process noise covariance, and R, the measurement noise covariance.
Following the process above, we can obtain the following state results. The two results correspond to the two different conditions where either no noises exist (Figure 14.7), or process and measurement noises are in existence (Figure 14.8).
Evidently, the results of the states and the input have both satisfied the constraints. Therefore, we can confidently say that the proposed MPC is effective in solving the state space while considering both process and measurement noises in the system.