QP Solvers¶
At each SSQP iteration, quadratizing the cost and linearizing the dynamics/constraints produces a Quadratic Program
with the same stagewise (banded) structure as the original OCP. QPSolver (ssqp::solvers::QPSolver) is the
abstract interface all QP backends implement:
virtual void reset() = 0;
virtual void increaseRegularization() = 0;
virtual SolverState solve(Solution &sol) = 0;
virtual uint iterations() const = 0;
Select the backend via ssqpParams.qp_solver_type (QPSolverType.ADMM, QPSolverType.HPIPM or
QPSolverType.PIQP); see
The SSQP Solver.
QP formulation¶
At each SSQP iterate \((\boldsymbol{x}, \boldsymbol{u})\), with multiplier estimates \(\boldsymbol{\lambda}\) (dynamics) and \(\boldsymbol{\mu}\) (constraints), the QP solvers find the update \((\Delta\boldsymbol{x}, \Delta\boldsymbol{u})\) that solves
The data comes from the stagewise functions of the model, all evaluated at the current iterate:
| Symbol | Meaning |
|---|---|
| \(\boldsymbol{q}^x_k\), \(\boldsymbol{q}^u_k\) | Cost gradients, \(\nabla_x \ell_k\) and \(\nabla_u \ell_k\) |
| \(\boldsymbol{Q}^{xx}_k\), \(\boldsymbol{Q}^{xu}_k\), \(\boldsymbol{Q}^{uu}_k\) | Hessian of the Lagrangian: the cost Hessian blocks plus the hessprod_* terms of the dynamics (against \(\boldsymbol{\lambda}_k\)) and the constraints (against \(\boldsymbol{\mu}_k\)) |
| \(\boldsymbol{A}_k\), \(\boldsymbol{B}_k\) | Dynamics Jacobians with respect to \(\boldsymbol{x}_k\) and \(\boldsymbol{u}_k\) |
| \(\boldsymbol{\gamma}_k\) | Dynamics gap, \(\boldsymbol{f}_k(\boldsymbol{x}_k, \boldsymbol{u}_k) \ominus \boldsymbol{x}_{k+1}\) |
| \(\boldsymbol{D}_k\), \(\boldsymbol{E}_k\) | Constraint Jacobians with respect to \(\boldsymbol{x}_k\) and \(\boldsymbol{u}_k\) |
| \(\boldsymbol{c}^l_k\), \(\boldsymbol{c}^u_k\) | Remaining room to the constraint bounds, here \(\boldsymbol{c}^l_k \ominus \boldsymbol{c}_k(\boldsymbol{x}_k, \boldsymbol{u}_k)\) and \(\boldsymbol{c}^u_k \ominus \boldsymbol{c}_k(\boldsymbol{x}_k, \boldsymbol{u}_k)\) |
The terminal stage has no controls. Stages without constraints have empty \(\boldsymbol{D}_k\), \(\boldsymbol{E}_k\), and equality constraints have equal \(\boldsymbol{c}^l_k\) and \(\boldsymbol{c}^u_k\). Since the initial state is fixed, \(\Delta\boldsymbol{x}_0\) is zero. For a manifold-valued state, all of these quantities live in the tangent space, so \(\Delta\boldsymbol{x}_k \in \mathcal{R}^{n_{dx}}\) (see Manifold-valued states). Besides \(\Delta\boldsymbol{x}\) and \(\Delta\boldsymbol{u}\), the solver returns the multipliers \(\boldsymbol{\lambda}\) and \(\boldsymbol{\mu}\) of the QP's dynamics and constraints, which become the next iterate's estimates.
ADMM¶
admm_qp is SSQP's own Alternating Direction Method of Multipliers implementation. It requires no extra
dependencies (unlike HPIPM and PIQP, see below) and is the default. Key parameters (admmParams, or admm_-prefixed
keyword arguments):
init_rho,alpha(over-relaxation),sigma(proximal regularization)- Adaptive \(\rho\) update:
rho_update,rho_min/rho_max,adaptive_rho_tolerance,rho_update_iter_freq - Termination:
max_iter,abs_tolerance/abs_tolerance_final,rel_tolerance/rel_tolerance_final(tolerance_update_stepsanneals both linearly, as with the outer SSQP tolerances) primal_infs_tolerance: everyrho_update_iter_freqiterations, ADMM checks whether the change in its dual variable \(y\) certifies that no trajectory satisfying the linearized dynamics can meet the constraint bounds. If so, it returnsPrimalInfeasible(seestop_on_qp_infeasibilityin Termination). Use -1.0 to disable the checkwarm_start: warm-start with the unconstrained solution (disable when usingInverseDynamicsmode)reset_rho/reset_y: whether to reset ADMM's \(\rho\) and \(y\) between successive SSQP formulations (disabling either can cause oscillations)
HPIPM¶
hpipm_qp wraps HPIPM (via BLASFEO), an
interior-point QP solver. It requires building SSQP with -DWITH_HPIPM=ON (see
Installation). Key parameters (hpipmParams, or
hpipm_-prefixed keyword arguments):
mode(HPIPMMode:Robust,Speed,Balance): trades off robustness against speedmax_iter,alpha_min,mu0(initial barrier parameter)tol_stat,tol_eq,tol_ineq,tol_comp: stationarity/equality/inequality/complementarity tolerancesreg_prim: primal regularizationwarm_start,prediction_correction,square_root_riccati,split_step
PIQP¶
piqp_qp wraps PIQP, a proximal interior-point QP solver, using its
multistage KKT solver, which exploits the stagewise structure of the QP. The multistage solver needs
BLASFEO, which is shared with HPIPM when both are enabled. It requires building SSQP
with -DSSQP_WITH_PIQP=ON, which is the default (see Installation).
Key parameters (piqpParams, or piqp_-prefixed keyword arguments):
max_itereps_abs,eps_rel: absolute and relative tolerancesrho_init,delta_init: initial primal and dual proximal regularizationreg_prim: primal regularization added to the Hessian diagonal, increased when the line search fails. It defaults to1e-4, far above HPIPM's, because PIQP solves the QP accurately enough that directions with little or no curvature (e.g. lightly weighted contact forces) otherwise produce very large steps that slow SSQP downparallel,num_threads: use PIQP's parallel multistage solver, which splits the horizon into segments that are factorized on separate threads, withnum_threadsthreads (0 uses the OpenMP default, all logical cores). This requires building with-DSSQP_PIQP_OPENMP=ON, and settingparallelotherwise raises an error. Withparalleloff, the serial solver runs on a single thread either way
The parallel solver mainly pays off for long horizons: on a 301-stage Go2 trajectory it roughly halves the QP solve
time with 8 threads, while the setup on the first solve stays sequential. Use about as many threads as the CPU has
performance cores, since more are usually slower. As PIQP's
documentation recommends, binding the threads to cores
(OMP_PLACES=cores OMP_PROC_BIND=close) also helps.
PIQP differs from the other backends in a few ways:
- It does not provide a feedback gain, so
MPC.feedbackGainraises an error with it - It reports
PrimalInfeasiblefor some infeasible QPs, but may also stall on one and stop atmax_iter - Its setup runs on the first solve after the QP solver is created. An
MPCcreates a new one whenever the problem dimensions change, e.g. when contact constraints are toggled, so each such step pays this cost again
LQR¶
ssqp::solvers::lqr is a Riccati-recursion based solver used internally to warm-start/solve the unconstrained
(equality-only) structure of the QP efficiently, exposing both a structural solve (output_structure, producing
gain matrices \(P, K\)) and a full unconstrained solve. It is not exposed as a standalone QPSolverType; instead it
backs the ADMM solver's per-iteration linear solves.
See the API reference for ssqpParams, admmParams, hpipmParams and piqpParams in
full.