ParNMPC : A Parallel Computing Toolbox for Nonlinear MPC
Introduction
ParNMPC
is a MATLAB real-time optimization toolkit for nonlinear model predictive control (NMPC).
ParNMPC
can utilize multiple CPU cores to solve the optimal control problem, and thus can be very fast (the computation time is usually in the range of \mus).
The purpose of ParNMPC
is to provide an easy-to-use environment for NMPC problem formulation, closed-loop simulation and deployment.
Features
- Symbolic problem representation
- Automatic parallel C/C++ code generation with OpenMP
- Fast rate of convergence (up to be superlinear)
- Highly parallelizable (capable of using at most N cores, N is the # of discretization steps)
- High speedup ratio
- MATLAB & Simulink
What Kind of Problems Supported in ParNMPC
?
The optimization control problem (OCP) supported in ParNMPC
is defined as follows:
Here,
Sign | Size | Description | Sign | Size | Description |
---|---|---|---|---|---|
u | [uDim,1] |
Input vector | L | [1,1] |
Cost function |
x | [xDim,1] |
State vector | C | [muDim,1] |
Equality constraint function |
p | [pDim,1] |
Given parameter vector | f | [xDim,1] |
Dynamics |
T | [1,1] |
Prediction horizon | M | [xDim,1] |
(Optional, e.g., Lagrange model) |
\bar{x}_0 | [xDim,1] |
Current state vector |
Note
- NMPC with inequality constraints can be transfered into equality constrained problems. For detailed instructions, check Tips > Handling Inequality Constraints.
- Varying dynamics, prediction horizon and references, and terminal cost function can be achieved by utilizing the parameter p.
How ParNMPC
Solves the OCP?
Discretization
ParNMPC
discretizes the OCP defined above into the following problem with N steps:
Here, the continuous-time state equation \dot{x}(t)=f(u(t),x(t),p(t)) (if M is not imposed) is discretized using the reverse-time discretization method, e.g., the backward Euler's method with F(u_i,x_i,p_i) = f(u_i,x_i,p_i)\Delta\tau - x_i, where \Delta\tau=T/N.
Note
Higher order discretization methods such as the explicit Runge-Kutta method with order 4 can also be utilized in a reverse-time manner.
Karush-Kuhn-Tucker (KKT) conditions
Then, ParNMPC
derives the KKT conditions for the discretized OCP as:
Here, \lambda is the Lagrange multiplier for the state equation, \mu is the Lagrange multiplier for the equality constraint, H(\lambda,\mu,u,x,p) = L(u,x,p)+\lambda^{T}F(u,x,p)+\mu^{T}C(u,x,p) is called the Hamiltonian, \{p_i\}_{i=1}^{N} are given, x_0=\bar{x}_0, and \lambda_{N+1}=0.
Solving the KKT conditions iteratively in parallel
Next, ParNMPC
solves the KKT conditions iteratively in parallel for a given initial state \bar{x}_0 and given parameters \{p_i\}_{i=1}^{N}.
The NMPC controller is implemented by applying the first optimal control input u_1^* as the actual input.
Note
- The iterative solver of
ParNMPC
relies on warm start.ParNMPC
provides tools for solving the very first OCP offline. ParNMPC
provides tools to define the controlled plant model for simulation.