Author: Mazen Alamir (Research Director at CNRS)
Website: www.mazenalamir.fr
This page is the 2021-2022 year page for the optimal and predictive control course given by the author at the univesity of Grenoble-Alpes, Grenoble, France.
MPCTable of contentsMPC in few wordsThe course material The checkpointsThe reportsContents of the notebooksMPC-series-1: IntroductionMPC-series-2: Model-Based PredictionMPC-series-3: Optimal Control FormulationMPC-series-4: Optimal Control problems' solution via the Casadi/Ipopt frameworkMPC-series-5: Closing the loop via MPC state feedbackMPC-series-6: Your first complete Nonlinear MPC exampleMPC-series-7: NLP versus QP solvers for QP problemsMPC-series-8: Linear MPCPython?References
Model Predictice Control is a control design methodology that enables to handle nonlinear systems, with multiple inputs and multiple output while handling constraints of any kind (inputs, state). Moreover, the controller is oriented torwards the minimisation of some cost function (or the maximisation for some performance index).
These feature explain why MPC is presently the most popular advanced control design methodology.
The course is composed of several python-jupyter notebooks that are desribed above in details. The notebooks can be exectued within the google-colab framework without the need of any personal python-packages installation.
The course contains several checkpoints distributed over the notebook and that light serve as a working topics.
Students are strongly encouraged to work out these checkpoints and produce the associated required report as soon as the notebooks leading to these checkpoint are considered in the course. No need to wait for the supervised working sessions in order to work them out. The time associated to the working session might not be sufficient.
The positions of the checkpoint within the notebooks is mentioned below when the notebooks are individually described.
| Checkpoint | # Notebook | Objective | Estimated time |
| 1 | 1 | General questions on MPC keywords! | 5 min |
| 2 | 2 | How to simulate a model given by its Ordinary differential Equation | 30 min |
| 3 | 3 | General questions on optimization and optimal control | 15 min |
| 4 | 4 | Solving a general optimal control problem | 30 min |
| 5 | 6 | Check the robustness of MPC controller to model discrepancy | 45 min |
| 6 | 8 | Designing a linear MPC | 60 min |
A single report is required at the end of the course. The report should be organized so that each checkpoint is clearly addressed within the report. In the answer to each checkpoint, make sure that the following items are precisely present:
The ojective of this notebook is to understand the MPC in the overall framework of control design for a dynamic system.
This first notebook takes you from the very simple concept of a dynamical system on which one can act using actuators to achieve some goal (control objective) to the role of MPC design as a way to elaborate a selective dynamic inversion of the model (objective -> actions) based on a dynamical modeling of the system.
This inversion is done using optimization procedure that will be studied later on. The notebook also shows some examples of the penetration of MPC in the academic and industrial world. It also shows some example of use of the MPC control design in the Gipsa-lab (where the author works!).
The previous notebook showed that MPC control design involves three main keywords that we recall hereafter:
In this notebook, we shall learn a little bit more about The first weyword, namely:Model-Based Prediction. It is shown how starting from a Ordinary Differential Equations (ODEs) representation of a dynamical system, one can design a prediction engine via three different ODE's integration options.
In the previous noteboook, we learned how a dynamic model (in ODE form) can be used to make prediction (simulate) the dynamical system for given initial state x0 and a given set of parameters that define the dynamical beaviour of the system. As it has been mentioned in the first note book, this sequence 𝑈 has to be chosen so that the resulting trajectory (given the initial state 𝑥0) achieves in the best possible way the control objectives. In other words, the sequence has to be chosen to be the sequence that minimizes some cost function (or maximizes some performance index), namley, it has to be the optimal choice that solves an optimization problem.
This is more formally presented in this notebook!
Once the optimal control problem is formalized, a first attempt to solve it using the scipy.optimize module is studied In order to show that it is not compatible with real-time computation of MPC. This will justify the need for the next notebook.
In the previous noteboook, we showed that using the general purposes nonlinear programming solvers in order to solve the constrained open-loop optimal control problems can lead to computation times that might be too large to be compatible with repetitive solution of these problem as it is required in the MPC implementation.
That is the reason why a dedicated solvers have been developed these last years in order to come out with NLP frameworks that might solve the underlying problem in faster way.
One of these framework has been developed by researchers from the control system community or associated to it. This is the Casadi framework.
In the previous noteboook, we showed that using the general purposes nonlinear programming solvers in order to solve the constrained open-loop optimal control problems can lead to computation times that might be too large to be compatible with repetitive solution of these problem as it is required in the MPC implementation.
That is the reason why a dedicated solvers have been developed these last years in order to come out with NLP frameworks that might solve the underlying problem in faster way.
One of these framework has been developed by researchers from the control system community or associated to it. This is the Casadi framework.
In the previous notebook entitled, it has been shown how to use the Casadi framework in order to formulate and solve the open-loop optimal control problem. The result of the solution step is hopefully the best sequence of actions, namely, the one that minimizes the cost function while respecting the constraints.
Now because of the presence of uncertainties and model mismatch, applying this sequence in open-loop (without feedback based on the measurement) might lead to undesired drift or even instability of the resulting behaviour.
That is the reason why the MPC implementation consists in applying the first control in the optimal sequence until the next sampling instant and at the new reached state, formulate the new problem and solve it to get the new best sequence of actions, apply the first control in this new sequence and so on.
This is what we are going to do in this notebook. More precisely:
This notebook presents the most important checkpoint of this course since it is here where the complete solution of a state feedback design is done on the crane example. The system's equations are given as well some elementary functions that you have then to use in order to design the MPC state feedback.
The feedback is then applied to a detuned model of the system (different from the one used in the design of the MPC feedback) in order to check the robustness of the solution to model mismatches that are unavoidable in the real-life.
In the previous notebook, it has been shown how to design a General Nonlinear MPC control for any system that is given by general set of nonlinear ordinary differential equations and using a general expression of the constraints function.
It is a fact however that in many situations, people work with a linearized model around some operating point and would like to handle constraints that are affine in the state and the control vectors. Moreover, it is very often that the cost function is expressed via a quandratic form of the state and the control trajectories.
This notebook show via a simple example that when the problem to be solved is a Quadratic Programming problem, it is better to solve it using a dedicated QP solver rather that using a general purpose solver.
The previous notebook underlined the fact that knowing that the underlying optimal control problem is quadratic can help us accelerating the resolution of the optimization problem by a significant facor thanks to the far more efficient QP solvers.
In this notebook, we shall through the steps that enables to put the underlying problems into QP form. This is possible under the following conditions:
In this notebook, we restrict ourselves to the particular case where the constraints are box constraints (saturation) in the state and the control. It is left to the reader to generalize to the complete general case without difficulties.
The notebooks are in python! You might ask why?
A course on MPC without concrete implementation would be obviously inappropriate, so a language should be chosen anyway. Python appeared to be the appropriate choice for the following reasons:
Rawlings, J. B. and D. Mayne. Model Predictive Control Theory and Design. ISBN-10: 0975937707, Nob Hill Pub, Llc, 2009.
Alamir, M. A Pragmatic Story of Model Predictive Control: Self Contained Algorithms and Cases Studies. CreateSpace Independent Publishing Platform. ISBN-10 1489541349. 2013.
For an easy and fast python learning and reference: https://scipy-lectures.org/intro/