Nonlinear model predictive control (NMPC) is a popular control method for multivariable control problems with important process constraints. The dynamic equation system is assumed to be given by differential algebraic equations (DAE). The code is mostly meant to be used as a way to verify the performance of more novel algorithms against an implementation more likely to be found in industry. It has the following features:
- Cheap NMPC implementation for both receding and shrinking time horizons
- Parameter and state estimation using the UKF
- Efficient solution of nonlinear dynamic optimization formulation using automatic differentiation
- Always feasible due to soft-constraints
Example
This is a basic nonlinear model predictive control (NMPC) implementation in Python with soft constraints, which uses an Unscented Kalman filter for state estimation. The NMPC algorithm does not consider possible uncertainties and is therefore referred to as nominal. For more information on the required modules and packages refer to section Technical requirements [1][2]. Simulation should run the pre-defined problem. Once this works the problem definition can be edited in Problem_definition to define your own problem.
References
The code was written using CasADi in Python 3.9 and hence requires CasADi with all its sub-dependencies. Simply download a Python distribution and install CasADi following the instructions. In addition, it uses the Unscented Kalman filter implementation from filterpy.
[1] Output feedback stochastic nonlinear model predictive control for batch processes.
[2] Economic stochastic model predictive control using the unscented Kalman filter.