• Stars
    star
    189
  • Rank 204,649 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Model Predictive Control (MPC) Python library based on the OSQP solver.

pyMPC

Linear Constrained Model Predictive Control (MPC) in Python:

where

Requirements

pyMPC requires the following packages:

  • numpy
  • scipy
  • OSQP
  • matplotlib

Installation

Stable version from PyPI

Run the command

pip install python-mpc

This will install the stable version of pyMPC from the PyPI package repository.

Latest version from GitHub

  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: [email protected]

Citing

If you find this project useful, we encourage you to

  • Star this repository โญ
  • Cite the paper
@inproceedings{forgione2020efficient,
  title={Efficient Calibration of Embedded {MPC}},
  author={Forgione, Marco and Piga, Dario and Bemporad, Alberto},
  booktitle={Proc. of the 21st IFAC World Congress 2020, Berlin, Germany, July 12-17 2020},
  year={2020}
}

More Repositories

1

dynonet

"dynoNet: A neural network architecture for learning dynamical systems" by Marco Forgione and Dario Piga
Python
42
star
2

sysid-neural-continuous

Continuous-time system identification with neural networks
Python
24
star
3

efficient-calibration-embedded-MPC

Python code of the paper "Efficient Calibration of Embedded MPC" (2020 IFAC World Congress) by Marco Forgione, Dario Piga, and Alberto Bemporad
Python
24
star
4

pytorch-ident

System identification in PyTorch
Python
23
star
5

sysid-transfer-functions-pytorch

Codes accompanying the paper "Deep learning with transfer functions: new applications in system identification"
Python
19
star
6

sysid-neural-structures-fitting

Python code of the paper "Model structures and fitting criteria for system identification with neural networks" by Marco Forgione and Dario Piga.
Python
19
star
7

lru-reduction

Python code of the paper Model order reduction of deep structured state-space models: A system-theoretic approach
Python
12
star
8

sysid-transformers

Code to reproduce the results of the paper In-context learning for model-free system identification
Jupyter Notebook
12
star
9

sysid-neural-estimator

Code accompanying the paper "Learning neural state-space models: do we need a state estimator?"
Python
10
star
10

RNN-adaptation

Code accompanying the paper "On the adaptation of recurrent neural networks for system identification"
Python
9
star
11

sysid-neural-unc

Code of the paper "Neural state-space models: Empirical evaluation of uncertainty quantification"
Python
5
star
12

jax-ident

An experimental code base for system identification with Jax.
Python
4
star
13

sysid-transformers-transfer

Code of the paper "On the adaptation of in-context learners for system identification" by Dario Piga, Filippo Pura, and Marco Forgione
Jupyter Notebook
3
star
14

python-data-science-slides

An introduction to data processing & visualization with numpy, pandas, matplotlib, and plotly express
Jupyter Notebook
2
star
15

bayesian-optimization-examples

Bayesian Optimization examples
Python
2
star
16

sysid-pytorch-lru

Unofficial PyTorch implementation of DeepMind's LRU with a system identification example.
Jupyter Notebook
2
star
17

multilevel-excitation

Codes accompanying the paper "Experiment design for parameter estimation in nonlinear systems based on multilevel excitation"
MATLAB
1
star
18

calcolo_mutuo

Python
1
star