Topic 4 Notes - Model Predictive Control (MPC)
Topic 4 Notes - Model Predictive Control (MPC)
MPC FRAMEWORK
➢ Time is denoted by k, k+1 is the discrete time step ahead; k + p is the furthest and the prediction horizon.
➢ Based on the past the model of the system can be future values can be anticipated by the calculating
future control moves.
➢ The green line represents the future control moves, it is valve movement calculated by the MPC up to
the prediction horizon.
Page | 1
MODEL PREDICTIVE CONTROL (MPC)
➢ Calculated measurement output is what is being controlled, if it was a temperature and it has to be
brought up to the reference trajectory or the set point.
➢ MPC calculates the control moves (green line) for the border prediction horizon such that the error
between the predicted output and the reference trajectory is minimized.
➢ MPC needs a model-, needs to work out moves such that the errors are reduced.
➢ The output will be the first from k to k+1, the rest are disregarded then they are implemented on the
next pulse from k+1 to k+2.
Chess Example
➢ The controller makes moves based on what it anticipates, and the plant will move in the future.
➢ The controller works out all the possible scenarios or moves of the plant.
➢ With a highly complex model, more moves can be made.
Speeding Vehicle
➢ The accelerator pedal and the steering column are the variables.
➢ Assuming the vehicle is moving at a constant speed, accelerator pedal is not needed.
➢ The reference goes to the MPC controller, if the model has errors, the errors can be eliminated by
disturbance vectors, which are factored in the MPC algorithm.
➢ The ideal scenario is to get a linear model that gives good representation of the vehicle dynamics.
➢ The output is the relative angular displacement of the steering wheel, whether it is going to the right or
left, and how far left or right.
➢ Feedback in needed to give the MPC past values.
➢ The plant model computes all the scenarios and computes all the control moves so that the vehicle starts
from one position and end up to the reference input.
Reference
Vehicle
Page | 2
MODEL PREDICTIVE CONTROL (MPC)
MPC COMPONENTS
➢ In MPC different scenarios are solved in real time and implement control moves to control the plant.
1. Prediction horizon & Control horizon.
2. Modeling.
3. Performance index.
4. Degrees of freedom (DOF).
5. Constraint handling.
6. Multivariable control (MIMO)
1. Prediction Horizon – always predict beyond the process setting time, this is done to account for the overall
process dynamics.
Analogy of Car Breaking distance
• if there is a short prediction horizon and the speed is controlled this will create a scenario where the
driver will not be able to stop or take corrective action quick enough because the driver cannot see the
road.
• Prediction horizon is the time the optimizer needs to make a computation, viable for the capture of the
full process dynamics.
▪ Receding Horizon – the horizon is constantly moving away however it is still the same.
▪ Control Horizon – it is the control moves made, the moves that the controller needs to make.
2. Modelling – Modelling is the core part of MPC, it must be ideally linear, good enough to capture the
essence of the dynamic characteristics. Parameters are easily identifiable such that if there is a step input to
the plant there should be an appropriate response.
• Must give accurate long-range predictions.
• If the model is poorly designed, this can lead to calculation errors.
▪ These are the model input in different points in time, the actual system is the red line
(it is used for long range predictions, the predictions should be close enough to the
actual system.)
▪ Modelling is important when it comes to determining process parameters.
Page | 3
MODEL PREDICTIVE CONTROL (MPC)
3. Performance Index (J)
➢ The performance index is minimized using MPC.
3
4 1. Slow.
2
2. Oscillatory.
1 3. Unstable.
4. Ideal
➢ First order system will not capture all the dynamics of the process output.
➢ DOF linked to how complex the process is.
➢ Higher model, capturing all the dynamics can give a good prediction.
➢ Also relates to the order of the model that is being implemented to the MPC scheme.
4. Constraint Handling
➢ Control valve limits (0-100%).
➢ Vehicle throttle & steering limits.
➢ Critical to get robust control
➢ FCE limits (constraints) must be part of the prediction.
➢ There are two types of constraints
Page | 4
MODEL PREDICTIVE CONTROL (MPC)
▪ Hard Constraints – These are strict limits that the system must always adhere to. Violating a hard
constraint is not permissible. A control move cannot move beyond this constraint.
▪ Soft Constraints - These constraints are more flexible and can be violated, if necessary, but with a
penalty. They are often used when it’s acceptable to exceed the limit slightly under certain
conditions. For example, this constraint allows some degree of valve travel just outside of it.
5. Multivariable Control (MIMO)
➢ The system can be handled by MPC, e.g. 2 Inputs and 2 Outputs; an example of 2 inputs and 2 outputs
is a car.
➢ Distillation column is another example of a practical process environment; it has 4 inputs (Feed going
in, Temperature, Pressure and Reflux) and 2 outputs (Distillate, Concentrations (bottom & top)).
➢ With MPC there can be one framework, where all the inputs are fed into it, it will have models for
distillation column, temperature, pressure built into the MPC scheme; and it works out control moves
and implement the output to each valve and output signals.
➢ MPC can handle complex schemes.
MPC DRAWBACKS
➢ This technique has found great success in industry where conventional PID fails.
1. Requires a simple model (Identification, linearization, nonlinear systems, time variations).
2. Needs a “real-time” optimization to solve the control problem (quadratic equation).
3. If system is not well designed, it will lead to ill-opposed solutions and therefore result in poor control.
MPC MODELLING
➢ Use of mathematics to make models for predictions.
➢ Linear models are ideal and generally good enough. State models are used because they are simple to
implement in matrix.
Linear Models
➢ Transfer functions (not good for MIMO systems).
➢ Laplace transfer functions are not used because they are done in continuous time, and MPC is done in
discrete time.
➢ State space is used to show derivation of the prediction of the output.
Page | 5
MODEL PREDICTIVE CONTROL (MPC)
Continuous Versus Discrete Models
➢ Continuous algorithms need time to make control move decisions.
➢ Mathematical discrete is needed so that in between the sampling intervals calculations can be
implemented to determine the next prediction and then make a decision.
Sampling Rate
The prediction window must capture essence of the dynamics, capturing the principal dynamics used to
calculate and determine the prediction window.
Page | 6
MODEL PREDICTIVE CONTROL (MPC)
N-Step Ahead Predictions
➢ The previous time frame is used to work out the next ahead.
➢ A pattern is formed if the brackets are multiplied out.
Page | 7
MODEL PREDICTIVE CONTROL (MPC)
Output
Notations
Known Unknown
Known Unknown
Vector Notation
➢ Vector gives direction.
Page | 8
MODEL PREDICTIVE CONTROL (MPC)
Vector Notation (State)
➢ 𝒖𝒌 are all pulled out MPC has to work out decision variables to work out the output.
Page | 9
MODEL PREDICTIVE CONTROL (MPC)
➢ 𝒚𝒌+𝟏 is the predicted output
→
➢ 𝑷𝒙 are the model parameters, 1st matrix.
Performance Index Formulation
▪ MPC is based on optimal performance; Optimal Performance means that the control system is designed
to predict future behavior and make decisions that minimize a cost function, such as energy consumption
or deviation from a desired trajectory. This ensures that the system operates in the most efficient and
effective manner possible.
▪ Performance measure is formatted, so that the system can work out the best possible moves in terms of
the future which is the goal of an MPC.
▪ This is done by minimizing performance index (J).
▪ No easy analytical expressions for fastest settling time, smallest actuation energy, fastest rise time and
minimum error when there is a disturbance.
A Quadratic Function of The PI Is The Solution
➢ Quadratic functions are the best solution when state space models are determined.
➢ Performance measure is determined such that the minimum value is obtained so that the optimal
solution can be found for control move for 𝒖𝒌 .
Page | 10
MODEL PREDICTIVE CONTROL (MPC)
➢ The valve be implemented (𝒖𝒌 𝟐 ) as shown below.
➢ Lambda (𝜆) is the tunable parameter.
➢ How much the signal to the valve is moving can be chosen because too much of movement to the valve
can be penalized depending on the weighting factor lambda.
➢ Solution does not converge because it will try to minimize the error and the movement if the controller
output which is the signal to the valve. If the error and movement to the valve are zero, it will not be
possible.
➢ Then the performance measure will not be good enough.
➢ There is a system trajectory or set point, the output is worked out and modelled based on the equations
in the previous pages.
➢ The system will come rest at a certain time, whatever time will come to rest at will be the system steady
state as shown below.
Steady State
Page | 11
MODEL PREDICTIVE CONTROL (MPC)
MPC CONTROLLER DESIGN PROCEDURE
1. Determine the relevant CV’s, MV’s, and DV’s.
2. Conduct plant test: Vary MV’s and DV’s & record the response of CV’s.
3. Derive a dynamic model from the plant test data.
4. Configure the MPC controller and enter initial tuning parameters.
5. Test the controller off-line using closed loop simulation.
6. Download the configured controller to the destination machine (embedded system) and test the model
predictions in open-loop mode.
7. Commission the controller and refine the tuning as needed.
MATLAB IMPLEMENTATION
Model Predictive Control MATLAB Examples (Link)
MPC MATLAB FILES (Link)
Page | 12
MODEL PREDICTIVE CONTROL (MPC)