|
| | QPSolver (const QPSettings &settings=QPSettings()) |
| | ~QPSolver () |
| | QPSolver (const QPSolver &other) |
| QPSolver & | operator= (const QPSolver &other) |
| | QPSolver (QPSolver &&other) noexcept |
| QPSolver & | operator= (QPSolver &&other) noexcept |
| void | setup (const Matrix &P, const Vector &q, const Matrix &C, const Vector &l, const Vector &u) |
| | Set the matrices and the bounds, and factorise the matrix of the iterations.
|
| void | setup (index_t n, const std::vector< QPEntry > &P, const Vector &q, index_t m, const std::vector< QPEntry > &C, const Vector &l, const Vector &u) |
| | The same, with P, n x n, and C, m x n, given by their non-zeros: the solver works with sparse matrices inside, so a problem with mostly zeros, as in model predictive control, costs only its non-zeros. Entries at the same place are added up.
|
| void | update (const Vector &q, const Vector &l, const Vector &u) |
| | Change q and the bounds, keeping P and C and the factorisation.
|
| QPStatus | solve () |
| | Solve, starting from the last solution.
|
| void | warm_start (const Vector &x) |
| | Start the next solve from x, and from no constraint being active.
|
| void | reset () |
| | Forget the last solution: the next solve starts from zero.
|
| const Vector & | solution () const noexcept |
| const Vector & | duals () const noexcept |
| uint_t | iterations () const noexcept |
| real_t | primal_residual () const noexcept |
| real_t | dual_residual () const noexcept |
| QPStatus | status () const noexcept |
| const QPSettings & | settings () const noexcept |
A solver of the convex quadratic program.
\[\min_x \tfrac{1}{2} x^T P x + q^T x \quad \text{subject to} \quad l \le C x \le u ,
\]
with P symmetric positive semi-definite, by the alternating direction method of multipliers (ADMM) of OSQP (Stellato et al., OSQP: an operator splitting solver for quadratic programs, 2020). A row with \(l_i = u_i\) is an equality, and a bound of \(\pm\infty\) is no bound.
Every iteration solves one linear system with the matrix \(P + \sigma I + C^T \rho C\), factorised with a sparse Cholesky factorisation, so an iteration costs two sparse triangular solves. As in OSQP, the problem is first equilibrated: the variables, the constraints and the cost are scaled so that the rows and the columns of its matrices have similar norms, which ADMM needs to converge in reasonable time when the numbers of the problem span orders of magnitude. And \(\rho\) adapts to balance the primal and the dual residuals; that needs a new factorisation, so it changes only when it is off by a factor of 5. The tolerances apply to the problem as it was given.
It suits the problems of model predictive control, with a few thousand variables at most. The solver keeps its last solution, and the next solve starts from it, which in MPC, where one problem is much like the last, saves most of the iterations. ADMM converges to a modest accuracy quickly and to a high one slowly: the default tolerances, 1e-4, are enough for control, and much tighter ones can take thousands of iterations.