Skip to content

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:

\begin{align} \min_{x(\cdot),\ u(\cdot)}&\int^{T}_{0}L\left(u(t),x(t),p(t)\right)dt \\ \text{s.t.}\quad &x(0) = \bar{x}_0,\\ &M\left(u(t),x(t),p(t)\right)\dot{x}(t)=f\left(u(t),x(t),p(t)\right),\quad t\in[0,T],\\ & C(u(t),x(t),p(t))=0,\quad t\in[0,T]. \end{align}

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:

\begin{align} \min_{X,\ U}\sum_{i=1}^{N}&L(u_i,x_i,p_i) \\ \text{s.t.}\quad & x_0 = \bar{x}_0,\\ &x_{i-1}+ F(u_i,x_i,p_i)=0, \quad i\in\{1,\cdots,N\},\\ & C(u_i,x_i,p_i)=0,\quad i\in\{1,\cdots,N\}. \end{align}

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:

\begin{align} &x_{i-1}+F(u_{i},x_i,p_i)=0,\ i\in\{1,\cdots,N\},\\ &C(u_{i},x_i,p_i)=0,\ i\in\{1,\cdots,N\},\\ &H_{u}^{T}(\lambda_{i},\mu_{i},u_{i},x_{i},p_i)=0,\ i\in\{1,\cdots,N\},\\ &\lambda_{i+1}+H_{x}^{T}(\lambda_{i},\mu_{i},u_{i},x_{i},p_i)=0,\ i\in\{1,\cdots,N\}. \end{align}

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.