# do-mpc: Model Predictive Control in Python¶

do-mpc is a comprehensive open-source toolbox for robust Model Predictive Control (MPC) and Moving Horizon Estimation (MHE). It enables the efficient formulation and solution of control and estimation problems for nonlinear systems, including tools to deal with uncertainty and time discretization. The modular structure of do-mpc contains simulation, estimation and control components that can be easily extended and combined to fit many different applications.

In summary, do-mpc offers the following features:

• nonlinear and economic model predictive control
• robust multi-stage model predictive control
• moving horizon state and parameter estimation
• modular design that can be easily extended

​ The do-mpc software is Python based and works therefore on any OS with a Python 3.x distribution. do-mpc has been developed at the DYN chair of the TU Dortmund by Sergio Lucia and Alexandru Tatulea. The development is continued at the IOT chair of the TU Berlin by Felix Fiedler and Sergio Lucia.

## Example: Robust Multi-stage MPC¶

We showcase an example, where the control task is to regulate the rotating triple-mass-spring system as shown below:

Once excited, the uncontrolled system takes a long time to come to a rest. To influence the system, two stepper motors are connected to the outermost discs via springs. The designed controller will result in something like this:

Assume, we have modeled the system from first principles and identified the parameters in an experiment. We are especially unsure about the exact value of the inertia of the masses. With Multi-stage MPC, we can define different scenarios e.g. $$\pm 10\%$$ for each mass and predict as well as optimize multiple state and input trajectories. This family of trajectories will always obey to set constraints for states and inputs and can be visualized as shown below:

## Next steps¶

We suggest you start by skimming over the selected examples below to get an first impression of the above mentioned features. A great further read for interested viewers is the getting started: MPC page, where we show how to setup do-mpc for the robust control task of a triple-mass-spring system. A state and parameter moving horizon estimator is configured and used for the same system in getting started: MHE.

To install do-mpc please see our installation instructions.