Skip to content
Python code of the paper "Efficient Calibration of Embedded MPC" by Marco Forgione, Dario Piga, and Alberto Bemporad
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Efficient Calibration of Embedded MPC

This repository contains the Python code to reproduce the results of the paper Efficient Calibration of Embedded MPC by Marco Forgione, Dario Piga, and Alberto Bemporad.

The code performs an efficient data-driven MPC calibration by tuning:

  • MPC weight matrices
  • MPC sampling time
  • Prediction and control horizon
  • Kalman filter matrices
  • QP solver relative and absolute tolerances

to optimize a closed-loop objective function , under the constraint that where is the (worst-case) time required to compute the MPC control low. This constraints guarantees that the controller can run in real-time.

Main scripts:

The main script to be executed for MPC calibration is

The results of the MPC calibration are saved in the results_*.pkl file on the disk and are read by the script

that produces the relevant plots.

Other files:

  • dynamic equations of the pendulum
  • pendulum_MPC_sim: performs a single closed-loop MPC simulation
  • objective function
  • implements a kalman filter

Included dependencies:

Other dependencies:

Simulations were performed on a Python 3.6 conda environment with

  • numpy
  • scipy
  • matplotlib
  • OSQP (a QP solver used by the MPC controller)
  • python-control (used to solve the DARE of the Kalman Filter)
  • GPyOpt (for Bayesian Optimization, optional)

These dependencies may be installed through the commands:

conda install numpy scipy matplotlib
pip install osqp
pip install control
pip install gpyopt


If you find this project useful, we encourage you to

  • Star this repository
  • Cite the paper
Author = {Forgione, Marco and Piga, Dario and Bemporad, Alberto},
Title = {Efficient Calibration of Embedded MPC},
Year = {2019},
Eprint = {arXiv:1911.13021},
You can’t perform that action at this time.