affine_mpc¶
affine_mpc is a library for model predictive control of discrete-time affine systems, with C++ and Python interfaces.
It provides condensed and sparse MPC formulations, input trajectory parameterization through B-splines, OSQP-backed solves, and binary logging for simulation and analysis workflows.
Who It Is For¶
affine_mpc is aimed at researchers, students, and engineers who want a focused MPC library rather than a general optimization toolkit.
The Python interface is convenient for experimentation, analysis, and teaching.
The C++ interface is better suited for integration into performance-sensitive applications.
It is intended to lower the barrier to developing MPC controllers for discrete-time affine systems by packaging common formulations, constraints, and workflows into a focused library.
Start Here¶
If you are new to the project, the shortest path is:
- Read Concepts for the supported problem class.
- Choose Python or C++.
- Run the mass-spring-damper walkthrough in Examples.
- Inspect the generated outputs in Logging.
To contribute, see Development.
Choose Python if you want fast iteration, NumPy-based analysis, notebooks, or teaching workflows. Choose C++ if you want native integration, tighter runtime control, or lower-overhead deployment.
Core Workflow¶
No matter which interface you use, the main workflow is the same:
- Choose a
Parameterization - Select desired
Options - Construct
CondensedMPCorSparseMPC - Set model, limits, weights, and references
- Call
initializeSolver() - Call
solve(...)in a loop - Retrieve inputs and predicted trajectories
- Optionally log results with
MPCLogger