HPIPM Solver Paper
HPIPM Solver Paper
Abstract:
This paper introduces HPIPM, a high-performance framework for quadratic programming (QP),
designed to provide building blocks to efficiently and reliably solve model predictive control
arXiv:2003.02547v2 [math.OC] 6 Jun 2020
problems. HPIPM currently supports three QP types, and provides interior point method (IPM)
solvers as well (partial) condensing routines. In particular, the IPM for optimal control QPs is
intended to supersede the HPMPC solver, and it largely improves robustness while keeping the
focus on speed. Numerical experiments show that HPIPM reliably solves challenging QPs, and
that it outperforms other state-of-the-art solvers in speed.
The ill-conditioning arises from the fact that in HPIPM, as 3.4 Iterative refinement
in most IPM solvers, the slacks tk and the Lagrange mul-
tipliers λk are eliminated as a pre-processing step before In practice, due to the finite accuracy of numerical compu-
the actual factorization, as the resulting linear system is tations, any procedure for the solution of the KKT system
in the form of the KKT system of an equality-constrained (3) can compute the solution only up to a certain accuracy.
QP, and therefore efficient factorization procedures for this Especially in case of unstable or ill-conditioned systems,
class of systems can be employed. and in late IPM iterations, the ill-conditioning of the KKT
In HPIPM, the variables ∆taff and ∆λaff are eliminated, in system (3) can make the accuracy in the Newton step too
this order, from the KKT system in (3), and the resulting low to be useful for the IPM algorithm. In such cases,
system of linear equations it may be beneficial to employ a few iterative refinement
steps in order to attempt to improve the accuracy of the
H + C T Tk−1 Λk C −AT ∆yaff
= Newton step.
−A 0 ∆πaff
The iterative refinement residuals are defined as the resid-
r − C T (Tk−1 Λk rd − Tk−1 rm )
=− g (6) uals in the solution of the KKT system (3),
rb ir
rg H −AT −C T 0 ∆yaff rg
which is in the form of the KKT system of an equality con- rir −A 0
strained QP, is solved with structure-exploiting routines b
ir = 0 0 ∆π aff rb
r ˙ −C 0 +
operating on dense sub-matrices in case of all QP types d 0 I ∆λaff rd
currently supported. This approach corresponds to stati- rmir 0 0 Tk Λk ∆taff rm
cally selecting the pivoting sequence based solely on spar- In case they are not small enough, it is possible to solve
sity, and hand-crafting efficient factorization algorithms again a system in the form (3) with the same KKT
tailored to the QP type at hand. The alternative approach, matrix at the left hand side (LHS) and the iterative
which is currently not employed in HPIPM, is to directly refinement residuals as RHS, and compute a correction
factorize the KKT system in (3) using sparse LA, which term to iteratively improve the accuracy of the Newton
may additionally perform dynamic pivoting for stability in step. Since no new matrix factorization is performed, the
an attempt to keep the conditioning under control. computation of this correction term is cheap compared to
In HPIPM, in the case of the dense QP type, the linear the factorization and solution of the KKT system in (3),
system in (6) is solved using either the Schur-complement especially in case of large systems.
or the null-space methods (Nocedal and Wright, 2006).
In case the dense QPs arise from the condensing of the 3.5 Condensing and partial condensing
OCP QP type, there are no equality constraints, and the
factorization of the KKT matrix in (6) can be simply HPIPM provides a condensing module, which implements
performed using the dense Cholesky factorization. routines to convert an OCP QP into a dense QP by
eliminating the state variables at all stages except stage 0.
In the case of the OCP QP type, as proposed in the This is possible because such state variables are not real
MPC context by (Steinbach, 1994) and similarly to degrees of freedom, as they are determined uniquely from
HPMPC (Frison et al., 2014), the linear system in (6) the inputs and the state at stage 0 by using the dynamics
is factorized using a structure-exploiting backward Ric- equality constraints. The partial (or block) condensing
cati recursion. Two versions of the Riccati recursion are module, which converts an OCP QP into another OCP
available (Frison, 2015): (a) the classical implementation QP with smaller number of stages, is built on top of the
(which requires the reduced Hessian with respect to the condensing module in a modular fashion, by performing
dynamics equality constraints to be positive definite, but condensing on blocks of stages.
allows the full-space Hessian to be indefinite), and (b)
the square-root implementation (which in order to reduce There exist at least three Hessian condensing algorithms
the flop count employs the Cholesky factorization of the with different computational complexities, ranging be-
Riccati recursion matrix, and therefore requires the full- tween quadratic and cubic in both the number of states
space Hessian to be positive definite). In case the number and the number of stages (Frison, 2015). The algorithm
currently implemented in HPIPM is the algorithm pro- step length. This algorithm is indicated for small and
posed in (Frison et al., 2016), which has a computational well-conditioned systems, in case tight bounds on the
complexity quadratic in the number of stages and cubic solution accuracy are not required.
in the number of states. This algorithm is based on a speed The focus lies on the high solution speed, but the
backward recursion which has similarities to the Riccati more reliable IPM delta formulation is employed. The
recursion. As such, two versions of this condensing algo- KKT residuals are computed at each IPM iteration,
rithm are available: one analogous to the classical Riccati and exit conditions are additionally based on minimum
recursion and one analogous to the square-root Riccati re- residuals tolerance.
cursion, with similar requirements about Hessian positive balance In this mode, the accuracy of the KKT factor-
definiteness. This condensing algorithm is the fastest when ization is checked by computing its iterative refinement
the state at stage 0 is kept as an optimization variable residuals. In case accuracy is too low, the factorization
(such as in partial condensing) and in case of long horizons. is repeated by replacing all Cholesky factorizations of
normal matrices in the form A · AT with array algo-
4. IMPLEMENTATION rithms based on QR factorizations, which have better
numerical properties as they never explicitly form the
4.1 Linear algebra worse-conditioned normal matrix A · AT . Furthermore,
a few iterative refinement steps are performed on the
Algorithms in HPIPM are explicitly designed to exploit prediction-centering-correction direction, in case this is
the overall structure of the optimization algorithms. Spar- not accurate enough.
sity within data and working matrices is not considered. robust In this mode, the KKT factorization is always per-
Therefore, computations are cast in term of operations on formed using the more accurate array algorithms based
matrices with fixed structure, like e.g. dense, symmetric, on QR factorizations. A higher number of iterative re-
triangular or diagonal. finement steps is performed on the prediction-centering-
correction direction, in case this is not accurate enough.
In HPIPM, the KKT modules contain the most com-
putationally expensive routines, such as KKT system Some additional implementation choices are common to
factorization and solution, and residuals computation. all modes. The Mehrotra’s corrector step is implemented
Such operations have computational complexities cubic or conditionally, and is only applied if it is not increasing
quadratic in the number of (stage) variables. In case of the duality measure too much compared to the affine
all currently implemented QP types, in the KKT modules step; otherwise, a predictor-centering step is applied. The
HPIPM employs the structure-based interface in the high- Hessian matrix of both primal and dual variables can be
performance LA library BLASFEO (Frison et al., 2018) regularized by adding a scaled identity matrix during fac-
for such operations. These routines are designed to give torization; this regularization does not affect the original
close-to-peak performance for matrices of moderate size problem data, and therefore the effect of regularization on
(assumed to fit in cache) and are optimized for several the solution can be offset by means of iterative refinement.
hardware architectures (e.g. exploiting different classes of The value of the inequality constraint Lagrange multipliers
SIMD instructions). and slacks is bounded to a minimum value, in order to give
the possibility to bound the ill-conditioning of the KKT
The IPM core operations in HPIPM are independent of the system in late IPM iterations. Finally, it is possible to
specific QP type and solely operate on unstructured arrays provide a guess to warm start either the primal, or both
of doubles holding e.g. the set of all primal variables, or the primal and the dual variables (this second option is
Lagrange multipliers or slack variables. These operations particularly effective in SQP algorithms, since close to the
have computational complexity linear in the number of NLP solution a good guess for the primal variables is zero,
variables, and are currently offered in two implementa- and for the dual variables coincides with the Lagrange
tions, one coded in generic C and one using AVX intrinsics. multipliers of the NLP).
4.2 IPM implementation choices 5. NUMERICAL EXPERIMENTS
At a high-level, HPIPM implements an infeasible-start In this section, numerical experiments evaluate the relative
Mehrotra’s predictor-corrector IPM (Mehrotra, 1992), speed (Section 5.1) and robustness (Section 5.2) of the
proposed in the MPC context e.g. in (Rao et al., 1998). different HPIPM modes, and compare HPIPM to other
This standard algorithmic scheme is tweaked by several ar- state-of-the-art MPC solvers (Section 5.3).
guments, whose different choice gives rise to a family of al-
gorithms with different trade-offs between computational
5.1 Linear mass spring system
speed and reliability. A ‘mode’ argument is introduced in
order to select pre-defined sets of arguments tailored to a
particular purpose. The modes currently available are: The linear mass spring system is a scalable benchmark
commonly employed to evaluate linear MPC solvers (Wang
speed abs This mode selects an algorithm analogous to and Boyd, 2010). The variant proposed in (Domahidi et al.,
the one implemented in HPMPC. The focus lies on 2012) is considered, comprising a horizontal chain of M
the highest solution speed, and the IPM is based on masses connected to each other and to walls using springs,
the absolute formulation. The residuals are optionally and where the first M − 1 masses are controlled using a
computed only before returning, and therefore the IPM force. Therefore the number of states nx = 2M , inputs
loop exit conditions are only based on duality measure nu = M − 1 and box constraints nb = nx + nu = 3M − 1
tolerance, maximum number of iterations and minimum per stage scales with the number of masses.
Table 1. Comparison of solvers for box- 1
constrained linear MPC: speed abs, speed
and robust modes for HPIPM, low-level inter-
faces for HPMPC. M is the number of masses; 0.8