python-mpc

MPC package for python


License
MIT
Install
pip install python-mpc==0.1.1

Documentation

pyMPC

Linear Constrained Model Predictive Control (MPC) in Python:

where .

Requirements

pyMPC requires the following packages:

  • numpy
  • scipy
  • OSQP
  • matplotlib

Installation

  1. Get a local copy the pyMPC project. For instance, run
git clone https://github.com/forgi86/pyMPC.git

in a terminal to clone the project using git. Alternatively, download the zipped pyMPC project from this link and extract it in a local folder

  1. Install pyMPC by running
pip install -e .

in the pyMPC project root folder (where the file setup.py is located).

Supported platforms

We successfully tested pyMPC on the following platforms:

  • Windows 10 on a PC with x86-64 CPU
  • Ubuntu 18.04 LTS on a PC with x86-64 CPU
  • Raspbian Buster on a Raspberry PI 3 rev B

Detailed instructions for the Raspberry PI platform are available here.

Usage

This code snippets illustrates the use of the MPCController class:

from pyMPC.mpc import MPCController

K = MPCController(Ad,Bd,Np=20, x0=x0,xref=xref,uminus1=uminus1,
                  Qx=Qx, QxN=QxN, Qu=Qu,QDu=QDu,
                  xmin=xmin,xmax=xmax,umin=umin,umax=umax,Dumin=Dumin,Dumax=Dumax)
K.setup()

...

xstep = x0
for i in range(nsim): 
  uMPC = K.output()
  xstep = Ad.dot(xstep) + Bd.dot(uMPC)  # system simulation steps
  K.update(xstep) # update with measurement

Full working examples are given in the examples folder:

Contributing

I am slowly adding new functionalities to pyMPC according to my research needs. If you also wanna contribute, feel free to write me an email: marco.forgione@idsia.ch

Citing

If you find this project useful, we encourage you to

  • Star this repository ⭐️
  • Cite the paper
@misc{efficient2019,
Author = {Forgione, Marco and Piga, Dario and Bemporad, Alberto},
Title = {Efficient Calibration of Embedded MPC},
Year = {2019},
Eprint = {arXiv:1911.13021},
}