do-mpc is a python 3.x package. Follow this guide to install do-mpc.

If you are new to Python, please read this article about Python environments. We recommend using a new Python environment for every project and to manage it with miniconda.


do-mpc requires the following Python packages and their dependencies:

  • numpy
  • CasADi
  • matplotlib

Option 1: PIP

Simply use PIP and install do-mpc from the terminal. This has the advantage that do-mpc is always in your Python path and can be used throughout your projects.

  1. Install do-mpc:
pip install do-mpc

Tested on Windows and Linux (Ubuntu 19.04).

PIP will also take care of dependencies and you are immediately ready to go.

Use this option if you plan to use do-mpc without altering the source code, e.g. write extensions.

  1. Get example documents:

All resources can be obtained from our release notes page. Please find the example files that match your currently installed do-mpc version in the respective section.

Option 2: Clone from Github

More experienced users are advised to clone or fork the most recent version of do-mpc from GitHub:

git clone

In this case, the dependencies from above must be manually taken care of. You have immediate access to our examples.

HSL linear solver for IPOPT

The standard configuration of do-mpc is based on IPOPT to solve the nonlinear constrained optimization problems that arise with the MPC and MHE formulation. The computational bottleneck of this method is repeatedly solving a large-scale linear systems for which IPOPT is offering a an interface to a variety of sparse symmetric indefinite linear solver. IPOPT and thus do-mpc comes by default with the MUMPS solver. It is suggested to try a different linear solver for IPOPT with do-mpc. Typically, a significant speed boost can be achieved with the HSL MA27 solver.

Option 1: Pre-compiled binaries

When installing CasADi via PIP or Anaconda (happens automatically when installing do-mpc via PIP), you obtain the pre-compiled CasADi package. To use MA27 (or other HSL solver in this setup) please follow these steps:


(Tested on Ubuntu 19.10)

  1. Obtain the HSL shared library. Choose the personal licence.
  2. Unpack the archive and copy its content to a destination of your choice. (e.g. /home/username/Documents/coinhsl/)
  3. Rename to CasADi is searching for the shared libraries under a depreciated name.
  4. Locate your .bashrc file on your home directory (e.g. /home/username/.bashrc)
  5. Add the previously created directory to your LD_LIBRARY_PATH, by adding the following line to your .bashrc
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/ffiedler/Documents/coinhsl/lib"
  1. Install libgfortran with Anaconda:
conda install -c anaconda libgfortran


To check if MA27 can be used as intended, please first change the solver according to do_mpc.controller.MPC.set_param(). When running the examples, inspect the IPOPT output in the console. Two possible errors are expected:

Tried to obtain MA27 from shared library "", but the following error occured: cannot open shared object file: No such file or directory

This error suggests that step three above wasn’t executed or didn’t work.

Tried to obtain MA27 from shared library "", but the following error occured: cannot open shared object file: No such file or directory

This error suggests that step six wasn’t executed or didn’t work.

Option 2: Compile from source

Please see the comprehensive guide on the CasADi Github Wiki.