Skip to content

Repository files navigation

Mini Model Predictive Control

A collection of from-scratch, zero-dependency C implementations of model predictive control (MPC) theory — spanning linear, nonlinear, explicit, economic, stochastic, robust, distributed, and real-time MPC formulations. Each module translates textbook equations into runnable C code, bridging the gap between advanced control theory and practical implementation.

Sub-Modules

Sub-Module Topics Key Courses
mini-linear-mpc Linear MPC, state-space dynamics, constraint formulation, QP solvers, receding horizon, terminal costs ETH 151-0660, Stanford AA203
mini-nonlinear-mpc Nonlinear MPC, multiple shooting, direct collocation, OCP formulation, cost functions (quadratic/economic/absolute) ETH 151-0660, MIT 6.832
mini-explicit-mpc Multi-parametric QP, piecewise affine (PWA) control, polyhedral region partitioning, region search ETH 151-0660, Stanford AA203
mini-economic-mpc Economic MPC, dissipativity theory, turnpike property, asymptotic average performance, transient optimality ETH 151-0660, Oxford B4
mini-stochastic-mpc Chance constraints, scenario trees, stochastic cost evaluation, risk measures (CVaR), uncertain dynamics ETH 151-0660, Stanford AA203
mini-tube-based-robust-mpc Tube-based robust MPC, minimal robust positively invariant (mRPI) sets, ancillary feedback, constraint tightening ETH 151-0660, Oxford B4
mini-distributed-mpc Distributed MPC, multi-agent optimization, ADMM-based coordination, consensus constraints, coupling dynamics ETH 227-0224, MIT 6.832
mini-real-time-iteration Real-time iteration (RTI), condensing algorithm, multiple shooting discretization, sensitivity computation, control-space QP ETH 151-0660, ETH 227-0216

Design Philosophy

  • Zero external dependencies — pure C (C99/C11), only libc and libm
  • Self-contained modules — each directory has its own Makefile, include/, src/, examples/, demos/, tests/
  • Theory-to-code mapping — every module includes docs/ with course-alignment notes and literature references
  • Practical demos — DC motor, quadrotor, chemical reactor, and academic benchmark problems for each MPC variant

Building

Each module is standalone. Navigate to a module directory and run:

cd mini-linear-mpc
make all    # build everything
make test   # run tests

Requires GCC and GNU Make.

Project Structure

mini-model-predictive-control/
├── mini-linear-mpc/               # Linear MPC: constraints, QP, receding horizon
├── mini-nonlinear-mpc/            # Nonlinear MPC: shooting, collocation, OCP formulation
├── mini-explicit-mpc/             # Explicit MPC: multi-parametric QP, PWA law, region search
├── mini-economic-mpc/             # Economic MPC: dissipativity, turnpike, average performance
├── mini-stochastic-mpc/           # Stochastic MPC: chance constraints, scenario trees, risk measures
├── mini-tube-based-robust-mpc/    # Tube-based robust MPC: mRPI sets, constraint tightening
├── mini-distributed-mpc/          # Distributed MPC: multi-agent, ADMM consensus, coupling
└── mini-real-time-iteration/      # Real-time iteration (RTI): condensing, sensitivity, fast QP

License

MIT

About

Model predictive control built from scratch, learn linear, nonlinear, robust & stochastic MPC via practical C coding

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages