Skip to main content
Log in

OSQP: an operator splitting solver for quadratic programs

  • Full Length Paper
  • Published:
Mathematical Programming Computation Aims and scope Submit manuscript

Abstract

We present a general-purpose solver for convex quadratic programs based on the alternating direction method of multipliers, employing a novel operator splitting technique that requires the solution of a quasi-definite linear system with the same coefficient matrix at almost every iteration. Our algorithm is very robust, placing no requirements on the problem data such as positive definiteness of the objective function or linear independence of the constraint functions. It can be configured to be division-free once an initial matrix factorization is carried out, making it suitable for real-time applications in embedded systems. In addition, our technique is the first operator splitting method for quadratic programs able to reliably detect primal and dual infeasible problems from the algorithm iterates. The method also supports factorization caching and warm starting, making it particularly efficient when solving parametrized problems arising in finance, control, and machine learning. Our open-source C implementation OSQP has a small footprint, is library-free, and has been extensively tested on many problem instances from a wide variety of application areas. It is typically ten times faster than competing interior-point methods, and sometimes much more when factorization caching or warm start is used. OSQP has already shown a large impact with tens of thousands of users both in academia and in large corporations.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5

Similar content being viewed by others

References

  1. Agrawal, A., Verschueren, R., Diamond, S., Boyd, S.: A rewriting system for convex optimization problems. J. Control Decis. 5(1), 42–60 (2018). https://doi.org/10.1080/23307706.2017.1397554

    Article  MathSciNet  Google Scholar 

  2. Allgöwer, F., Badgwell, T.A., Qin, J.S., Rawlings, J.B., Wright, S.J.: Nonlinear Predictive Control and Moving Horizon Estimation–An Introductory Overview, pp. 391–449. Springer, London (1999)

    Google Scholar 

  3. Amestoy, P.R., Davis, T.A., Duff, I.S.: Algorithm 837: AMD, an approximate minimum degree ordering algorithm. ACM Trans. Math. Softw. 30(3), 381–388 (2004)

    MathSciNet  MATH  Google Scholar 

  4. Balakrishnan, H., Hwang, I., Tomlin, C.J.: Polynomial approximation algorithms for belief matrix maintenance in identity management. In: IEEE Conference on Decision and Control (CDC), pp. 4874–4879 (2004)

  5. Banjac, G., Goulart, P.: Tight global linear convergence rate bounds for operator splitting methods. IEEE Trans. Autom. Control 63(12), 4126–4139 (2018). https://doi.org/10.1109/TAC.2018.2808442

    Article  MathSciNet  MATH  Google Scholar 

  6. Banjac, G., Goulart, P., Stellato, B., Boyd, S.: Infeasibility detection in the alternating direction method of multipliers for convex optimization. J. Optim. Theory Appl. 183(2), 490–519 (2019). https://doi.org/10.1007/s10957-019-01575-y

    Article  MathSciNet  MATH  Google Scholar 

  7. Banjac, G., Stellato, B., Moehle, N., Goulart, P., Bemporad, A., Boyd, S.: Embedded code generation using the OSQP solver. In: IEEE Conference on Decision and Control (CDC) (2017)

  8. Bauschke, H.H., Borwein, J.M.: On projection algorithms for solving convex feasibility problems. SIAM Rev. 38(3), 367–426 (1996)

    MathSciNet  MATH  Google Scholar 

  9. Bauschke, H.H., Combettes, P.L.: Convex Analysis and Monotone Operator Theory in Hilbert Spaces, 1st edn. Springer, Berlin (2011)

    MATH  Google Scholar 

  10. Belotti, P., Kirches, C., Leyffer, S., Linderoth, J., Luedtke, J., Mahajan, A.: Mixed-integer nonlinear optimization. Acta Numer. 22, 1–131 (2013)

    MathSciNet  MATH  Google Scholar 

  11. Benzi, M.: Preconditioning techniques for large linear systems: a survey. J. Comput. Phys. 182(2), 418–477 (2002)

    MathSciNet  MATH  Google Scholar 

  12. Borrelli, F., Bemporad, A., Morari, M.: Predictive Control for Linear and Hybrid Systems. Cambridge University Press, Cambridge (2017)

    MATH  Google Scholar 

  13. Boyd, S., Busseti, E., Diamond, S., Kahn, R.N., Koh, K., Nystrup, P., Speth, J.: Multi-period trading via convex optimization. Found. Trends Optim. 3(1), 1–76 (2017). https://doi.org/10.1561/2400000023

    Article  Google Scholar 

  14. Boyd, S., El Ghaoui, L., Feron, E., Balakrishnan, V.: Linear Matrix Inequalities in System and Control Theory. Society for Industrial and Applied Mathematics, Philadelphia (1994)

    MATH  Google Scholar 

  15. Boyd, S., Mueller, M.T., O’Donoghue, B., Wang, Y.: Performance bounds and suboptimal policies for multi-period investment. Found. Trends Optim. 1(1), 1–72 (2014)

    Google Scholar 

  16. Boyd, S., Parikh, N., Chu, E., Peleato, B., Eckstein, J.: Distributed optimization and statistical learning via the alternating direction method of multipliers. Found. Trends Mach. Learn. 3(1), 1–122 (2011)

    MATH  Google Scholar 

  17. Boyd, S., Vandenberghe, L.: Convex Optimization. Cambridge University Press, Cambridge (2004)

    MATH  Google Scholar 

  18. Bradley, A.: Algorithms for the equilibration of matrices and their application to limited-memory quasi-Newton methods. Ph.D. thesis, Stanford University (2010)

  19. Candés, E.J., Wakin, M.B., Boyd, S.: Enhancing sparsity by reweighted \(\ell _1\) minimization. J. Fourier Anal. Appl. 14(5), 877–905 (2008)

    MathSciNet  MATH  Google Scholar 

  20. Cornuejols, G., Tütüncü, R.: Optimization Methods in Finance. Finance and Risk. Cambridge University Press, Cambridge (2006)

    MATH  Google Scholar 

  21. Cortes, C., Vapnik, V.: Support-vector networks. Mach. Learn. 20(3), 273–297 (1995)

    MATH  Google Scholar 

  22. Dantzig, G.B.: Linear Programming and Extensions. Princeton University Press, Princeton (1963)

    MATH  Google Scholar 

  23. Davis, T.A.: Algorithm 849: a concise sparse Cholesky factorization package. ACM Trans. Math. Softw. 31(4), 587–591 (2005)

    MathSciNet  MATH  Google Scholar 

  24. Davis, T.A.: Direct Methods for Sparse Linear Systems. Society for Industrial and Applied Mathematics, Philadelphia (2006)

    MATH  Google Scholar 

  25. Davis, T.A., Hu, Y.: The University of Florida sparse matrix collection. ACM Trans. Math. Softw. 38(1), 1:1–1:25 (2011). https://doi.org/10.1145/2049662.2049663

    Article  MathSciNet  MATH  Google Scholar 

  26. Diamond, S., Boyd, S.: CVXPY: a python-embedded modeling language for convex optimization. J. Mach. Learn. Res. 17(83), 1–5 (2016)

    MathSciNet  MATH  Google Scholar 

  27. Diamond, S., Boyd, S.: Stochastic matrix-free equilibration. J. Optim. Theory Appl. 172(2), 436–454 (2017)

    MathSciNet  MATH  Google Scholar 

  28. Diehl, M., Ferreau, H.J., Haverbeke, N.: Efficient Numerical Methods for Nonlinear MPC and Moving Horizon Estimation, pp. 391–417. Springer, Berlin (2009)

    MATH  Google Scholar 

  29. Dolan, E.D., Moré, J.J.: Benchmarking optimization software with performance profiles. Math. Program. 91(2), 201–213 (2002)

    MathSciNet  MATH  Google Scholar 

  30. Domahidi, A., Chu, E., Boyd, S.: ECOS: an SOCP solver for embedded systems. In: European Control Conference (ECC), pp. 3071–3076 (2013)

  31. Douglas, J., Rachford, H.H.: On the numerical solution of heat conduction problems in two and three space variables. Trans. Am. Math. Soc. 82(2), 421–439 (1956)

    MathSciNet  MATH  Google Scholar 

  32. Duff, I.S., Erisman, A.M., Reid, J.K.: Direct Methods for Sparse Matrices. Oxford University Press, London (1989)

    MATH  Google Scholar 

  33. Dunning, I., Huchette, J., Lubin, M.: JuMP: a modeling language for mathematical optimization. SIAM Rev. 59(2), 295–320 (2017)

    MathSciNet  MATH  Google Scholar 

  34. Eckstein, J.: Parallel alternating direction multiplier decomposition of convex programs. J. Optim. Theory Appl. 80(1), 39–62 (1994)

    MathSciNet  MATH  Google Scholar 

  35. Eckstein, J., Ferris, M.C.: Operator-splitting methods for monotone affine variational inequalities, with a parallel application to optimal control. INFORMS J. Comput. 10(2), 218–235 (1998)

    MathSciNet  MATH  Google Scholar 

  36. Ferreau, H.J., Kirches, C., Potschka, A., Bock, H.G., Diehl, M.: qpOASES: a parametric active-set algorithm for quadratic programming. Math. Program. Comput. 6(4), 327–363 (2014)

    MathSciNet  MATH  Google Scholar 

  37. Fletcher, R., Leyffer, S.: Numerical experience with lower bounds for MIQP branch-and-bound. SIAM J. Optim. 8(2), 604–616 (1998)

    MathSciNet  MATH  Google Scholar 

  38. Fougner, C., Boyd, S.: Parameter Selection and Preconditioning for a Graph Form Solver, pp. 41–61. Springer, Berlin (2018). https://doi.org/10.1007/978-3-319-67068-3_4

    Book  MATH  Google Scholar 

  39. Frank, M., Wolfe, P.: An algorithm for quadratic programming. Naval Res. Log. Q. 3(1–2), 95–110 (1956)

    MathSciNet  Google Scholar 

  40. Gabay, D.: Chapter IX applications of the method of multipliers to variational inequalities. Stud. Math. Appl. 15, 299–331 (1983)

    Google Scholar 

  41. Gabay, D., Mercier, B.: A dual algorithm for the solution of nonlinear variational problems via finite element approximation. Comput. Math. Appl. 2(1), 17–40 (1976)

    MATH  Google Scholar 

  42. García, C.E., Prett, D.M., Morari, M.: Model predictive control: theory and practice—a survey. Automatica 25(3), 335–348 (1989)

    MATH  Google Scholar 

  43. Gertz, E.M., Wright, S.J.: Object-oriented software for quadratic programming. ACM Trans. Math. Softw. 29(1), 58–81 (2003)

    MathSciNet  MATH  Google Scholar 

  44. Ghadimi, E., Teixeira, A., Shames, I., Johansson, M.: Optimal parameter selection for the alternating direction method of multipliers (ADMM): quadratic problems. IEEE Trans. Autom. Control 60(3), 644–658 (2015)

    MathSciNet  MATH  Google Scholar 

  45. Gill, P.E., Murray, W., Saunders, M.A., Tomlin, J.A., Wright, M.H.: On projected Newton barrier methods for linear programming and an equivalence to Karmarkar’s projective method. Math. Program. 36(2), 183–209 (1986)

    MathSciNet  MATH  Google Scholar 

  46. Giselsson, P., Boyd, S.: Metric selection in fast dual forward–backward splitting. Automatica 62, 1–10 (2015)

    MathSciNet  MATH  Google Scholar 

  47. Giselsson, P., Boyd, S.: Linear convergence and metric selection for Douglas–Rachford splitting and ADMM. IEEE Trans. Autom. Control 62(2), 532–544 (2017)

    MathSciNet  MATH  Google Scholar 

  48. Glowinski, R., Marroco, A.: Sur l’approximation, par éléments finis d’ordre un, et la résolution, par pénalisation-dualité d’une classe de problèmes de dirichlet non linéaires. ESAIM: Mathematical Modelling and Numerical Analysis - Modélisation Mathématique et Analyse Numérique 9(R2), 41–76 (1975)

    MATH  Google Scholar 

  49. Golub, G.H., Van Loan, C.F.: Matrix Computations, 3rd edn. Johns Hopkins University Press, Baltimore (1996)

    MATH  Google Scholar 

  50. Goulart, P., Stellato, B., Banjac, G.: QDLDL (2018). https://github.com/oxfordcontrol/qdldl. Accessed 6 Feb 2020

  51. Gould, N., Scott, J.: A note on performance profiles for benchmarking software. ACM Trans. Math. Softw. 43(2), 15:1–15:5 (2016). https://doi.org/10.1145/2950048

    Article  MathSciNet  MATH  Google Scholar 

  52. Greenbaum, A.: Iterative Methods for Solving Linear Systems. Society for Industrial and Applied Mathematics, Philadelphia (1997)

    MATH  Google Scholar 

  53. Gurobi Optimization Inc.: Gurobi optimizer reference manual (2016). http://www.gurobi.com. Accessed 6 Feb 2020

  54. He, B.S., Yang, H., Wang, S.L.: Alternating direction method with self-adaptive penalty parameters for monotone variational inequalities. J. Optim. Theory Appl. 106(2), 337–356 (2000)

    MathSciNet  MATH  Google Scholar 

  55. Huber, P.J.: Robust estimation of a location parameter. Ann. Math. Stat. 35(1), 73–101 (1964)

    MathSciNet  MATH  Google Scholar 

  56. Huber, P.J.: Robust Statistics. Wiley, New York (1981)

    MATH  Google Scholar 

  57. Intel Corporation: Intel Math Kernel Library. User’s Guide (2017)

  58. Jerez, J.L., Goulart, P.J., Richter, S., Constantinides, G.A., Kerrigan, E.C., Morari, M.: Embedded online optimization for model predictive control at megahertz rates. IEEE Trans. Autom. Control 59(12), 3238–3251 (2014)

    MathSciNet  MATH  Google Scholar 

  59. Kantorovich, L.: Mathematical methods of organizing and planning production. Manag. Sci. 6(4), 366–422 (1960). English translation

  60. Karmarkar, N.: A new polynomial-time algorithm for linear programming. Combinatorica 4(4), 373–395 (1984)

    MathSciNet  MATH  Google Scholar 

  61. Kelley, C.: Iterative Methods for Linear and Nonlinear Equations. Society for Industrial and Applied Mathematics, Philadelphia (1995)

    MATH  Google Scholar 

  62. Klee, V., Minty, G.: How good is the simplex algorithm. Department of Mathematics, University of Washington, Technical report (1970)

  63. Knight, P.A., Ruiz, D., Uçar, B.: A symmetry preserving algorithm for matrix scaling. SIAM J. Matrix Anal. Appl. 35(3), 931–955 (2014)

    MathSciNet  MATH  Google Scholar 

  64. Lions, P.L., Mercier, B.: Splitting algorithms for the sum of two nonlinear operators. SIAM J. Numer. Anal. 16(6), 964–979 (1979)

    MathSciNet  MATH  Google Scholar 

  65. Löfberg, J.: YALMIP: a toolbox for modeling and optimization in MATLAB. In: IEEE International Conference on Robotics and Automation, pp. 284–289 (2004). https://doi.org/10.1109/CACSD.2004.1393890

  66. Mangasarian, O.L., Musicant, D.R.: Robust linear and support vector regression. IEEE Trans. Pattern Anal. Mach. Intell. 22(9), 950–955 (2000). https://doi.org/10.1109/34.877518

    Article  Google Scholar 

  67. Markowitz, H.: Portfolio selection. J. Finance 7(1), 77–91 (1952)

    Google Scholar 

  68. Maros, I., Mészáros, C.: A repository of convex quadratic programming problems. Optim. Methods Softw. 11(1–4), 671–681 (1999)

    MathSciNet  MATH  Google Scholar 

  69. Mattingley, J., Boyd, S.: Real-time convex optimization in signal processing. IEEE Signal Process. Mag. 27(3), 50–61 (2010)

    MATH  Google Scholar 

  70. Mattingley, J., Boyd, S.: CVXGEN: a code generator for embedded convex optimization. Optim. Eng. 13(1), 1–27 (2012)

    MathSciNet  MATH  Google Scholar 

  71. Mehrotra, S.: On the implementation of a primal–dual interior point method. SIAM J. Optim. 2(4), 575–601 (1992)

    MathSciNet  MATH  Google Scholar 

  72. Mittelmann, H.: Benchmarks for optimization software. http://plato.asu.edu/bench.html. Accessed 08 Nov 2019

  73. MOSEK ApS: The MOSEK optimization toolbox for MATLAB manual. Version 8.0 (Revision 57) (2017). http://docs.mosek.com/8.0/toolbox/index.html. Accessed 6 Feb 2020

  74. Nesterov, Y., Nemirovskii, A.: Interior-Point Polynomial Algorithms in Convex Programming. Society for Industrial and Applied Mathematics, Philadelphia (1994)

    MATH  Google Scholar 

  75. Nishihara, R., Lessard, L., Recht, B., Packard, A., Jordan, M.I.: A general analysis of the convergence of ADMM. In: International Conference on Machine Learning (ICML), pp. 343–352 (2015)

  76. Nocedal, J., Wright, S.J.: Numerical Optimization. Springer Series in Operations Research and Financial Engineering. Springer, Berlin (2006)

    Google Scholar 

  77. O’Donoghue, B., Chu, E., Parikh, N., Boyd, S.: Conic optimization via operator splitting and homogeneous self-dual embedding. J. Optim. Theory Appl. 169(3), 1042–1068 (2016)

    MathSciNet  MATH  Google Scholar 

  78. O’Donoghue, B., Stathopoulos, G., Boyd, S.: A splitting method for optimal control. IEEE Trans. Control Syst. Technol. 21(6), 2432–2442 (2013)

    Google Scholar 

  79. Pock, T., Chambolle, A.: Diagonal preconditioning for first order primal–dual algorithms in convex optimization. In: 2011 International Conference on Computer Vision, pp. 1762–1769 (2011)

  80. Raghunathan, A.U., Di Cairano, S.: ADMM for convex quadratic programs: Q-linear convergence and infeasibility detection (2014). arXiv:1411.7288

  81. Raghunathan, A.U., Di Cairano, S.: Infeasibility detection in alternating direction method of multipliers for convex quadratic programs. In: IEEE Conference on Decision and Control (CDC), pp. 5819–5824 (2014). https://doi.org/10.1109/CDC.2014.7040300

  82. Rawlings, J.B., Mayne, D.Q.: Model Predictive Control: Theory and Design. Nob Hill Publishing, San Francisco (2009)

    Google Scholar 

  83. Reuther, A., Kepner, J., Byun, C., Samsi, S., Arcand, W., Bestor, D., Bergeron, B., Gadepally, V., Houle, M., Hubbell, M., Jones, M., Klein, A., Milechin, L., Mullen, J., Prout, A., Rosa, A., Yee, C., Michaleas, P.: Interactive supercomputing on 40,000 cores for machine learning and data analysis. In: 2018 IEEE High Performance extreme Computing Conference (HPEC), pp. 1–6 (2018). https://doi.org/10.1109/HPEC.2018.8547629

  84. Rockafellar, R.T., Wets, R.J.B.: Variational Analysis. Grundlehren der mathematischen Wissenschaften. Springer, Berlin (1998)

    Google Scholar 

  85. Ruiz, D.: A scaling algorithm to equilibrate both rows and columns norms in matrices. Technical Report RAL-TR-2001-034, Rutherford Appleton Laboratory, Oxon, UL (2001)

  86. Sinkhorn, R., Knopp, P.: Concerning nonnegative matrices and doubly stochastic matrices. Pac. J. Math. 21(2), 343–348 (1967)

    MathSciNet  MATH  Google Scholar 

  87. Stathopoulos, G., Shukla, H., Szucs, A., Pu, Y., Jones, C.N.: Operator splitting methods in control. Found. Trends Syst. Control 3(3), 249–362 (2016)

    Google Scholar 

  88. Stellato, B., Banjac, G.: Benchmark examples for the OSQP solver (2019). https://github.com/oxfordcontrol/osqp_benchmarks. Accessed 6 Feb 2020

  89. Takapoui, R., Javadi, H.: Preconditioning via diagonal scaling (2014). https://web.stanford.edu/~hrhakim/projects/EE364B.pdf. Accessed 6 Feb 2020

  90. Tibshirani, R.: Regression shrinkage and selection via the lasso. J. R. Stat. Soc. Ser. B 58(1), 267–288 (1996)

    MathSciNet  MATH  Google Scholar 

  91. Vanderbei, R.: Symmetric quasi-definite matrices. SIAM J. Optim. 5(1), 100–113 (1995)

    MathSciNet  MATH  Google Scholar 

  92. Wilkinson, J.H.: Rounding Errors in Algebraic Processes. Prentice Hall, Englewood Cliffs (1963)

    MATH  Google Scholar 

  93. Wohlberg, B.: ADMM penalty parameter selection by residual balancing (2017). arXiv:1704.06209v1

  94. Wolfe, P.: The simplex method for quadratic programming. Econometrica 27(3), 382–398 (1959)

    MathSciNet  MATH  Google Scholar 

  95. Wright, S.: Primal–Dual Interior-Point Methods. Society for Industrial and Applied Mathematics, Philadelphia (1997)

    MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Bartolomeo Stellato.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

This work was supported by the People Programme (Marie Curie Actions) of the European Union Seventh Framework Programme (FP7/2007–2013) under REA Grant agreement No. 607957 (TEMPO).

Problem classes

Problem classes

In this section we describe the random problem classes used in the benchmarks and derive formulations with explicit linear equalities and inequalities that can be directly written in the form \(Ax \in {\mathcal {C}}\) with \({\mathcal {C}} = [l, u]\).

1.1 Random QP

Consider the following QP

$$\begin{aligned} \begin{array}{ll} \text{ minimize } &{}\quad (1/2) x^TP x + q^Tx \\ \text{ subject } \text{ to } &{}\quad l \le A x \le u. \end{array} \end{aligned}$$

Problem instances The number of variables and constraints in our problem instances are n and \(m=10n\). We generated random matrix \(P= M M^T+ \alpha I\) where \(M\in {\mathbf{R}}^{n \times n}\) and \(15 \%\) nonzero elements \(M_{ij}\sim {\mathcal {N}}(0,1)\). We add the regularization \(\alpha I\) with \(\alpha = 10^{-2}\) to ensure that the problem is not unbounded. We set the elements of \(A\in {\mathbf{R}}^{m \times n}\) as \(A_{ij} \sim {\mathcal {N}}(0,1)\) with only \(15 \%\) being nonzero. The linear part of the cost is normally distributed, i.e., \(q_i \sim {\mathcal {N}}(0,1)\). We generated the constraint bounds as \(u_i \sim {\mathcal {U}}(0,1)\), \(l_i \sim -{\mathcal {U}}(0,1)\).

1.2 Equality constrained QP

Consider the following equality constrained QP

$$\begin{aligned} \begin{array}{ll} \text{ minimize } &{}\quad (1/2) x^TP x + q^Tx \\ \text{ subject } \text{ to } &{}\quad A x = b. \end{array} \end{aligned}$$

This problem can be rewritten as (1) by setting \(l = u = b\).

Problem instances The number of variables and constraints in our problem instances are n and \(m=\lfloor n/2\rfloor \).

We generated random matrix \(P= M M^T+ \alpha I\) where \(M\in {\mathbf{R}}^{n \times n}\) and \(15 \%\) nonzero elements \(M_{ij}\sim {\mathcal {N}}(0,1)\). We add the regularization \(\alpha I\) with \(\alpha = 10^{-2}\) to ensure that the problem is not unbounded. We set the elements of \(A\in {\mathbf{R}}^{m \times n}\) as \(A_{ij} \sim {\mathcal {N}}(0,1)\) with only \(15 \%\) being nonzero. The vectors are all normally distributed, i.e., \(q_i, b_i \sim {\mathcal {N}}(0,1)\).

Iterative refinement interpretation Solution of the above problem can be found directly by solving the following linear system

$$\begin{aligned} \begin{bmatrix} P &{}\quad A^T\\ A &{}\quad 0\end{bmatrix} \begin{bmatrix}x \\ \nu \end{bmatrix} = \begin{bmatrix} -q \\ b \end{bmatrix}. \end{aligned}$$
(35)

If we apply the ADMM iterations (15)–(19) for solving the above problem, and by setting \(\alpha =1\) and \(y^0=b\), the algorithm boils down to the following iteration

$$\begin{aligned} \begin{bmatrix} x^{k+1} \\ \nu ^{k+1} \end{bmatrix} = \begin{bmatrix} x^k \\ \nu ^k \end{bmatrix} + \begin{bmatrix} P + \sigma I &{}\quad A^T\\ A &{}\quad -\rho ^{-1} I \end{bmatrix}^{-1}\left( \begin{bmatrix} -q \\ b \end{bmatrix} - \begin{bmatrix} P &{}\quad A^T\\ A &{}\quad 0\end{bmatrix} \begin{bmatrix} x^k \\ \nu ^k \end{bmatrix} \right) , \end{aligned}$$

which is equivalent to (31) with \(g = (-q, b)\) and \({\hat{t}}^k = (x^k,\nu ^k)\). This means that Algorithm 1 applied to solve an equality constrained QP is equivalent to applying iterative refinement [32, 92] to solve the KKT system (35). Note that the perturbation matrix in this case is

$$\begin{aligned} \varDelta K = \begin{bmatrix} \sigma I \\ &{}\quad -\rho ^{-1} I \end{bmatrix}, \end{aligned}$$

which justifies using a low value of \(\sigma \) and a high value of \(\rho \) for equality constraints.

1.3 Optimal control

We consider the problem of controlling a constrained linear time-invariant dynamical system. To achieve this, we formulate the following optimization problem [12]

$$\begin{aligned} \begin{array}{ll} \text{ minimize } &{}\quad x_T^TQ_T x_T + \sum \limits _{t=0}^{T-1} x_t^TQ x_t + u_t^TR u_t \\ \text{ subject } \text{ to } &{}\quad x_{t+1} = Ax_t + Bu_t \\ &{} \quad x_t \in {\mathcal {X}}, u_t \in {\mathcal {U}} \\ &{} \quad x_0 = x_{\mathrm{init}}. \end{array} \end{aligned}$$
(36)

The states \(x_t\in {\mathbf{R}}^{n_x}\) and the inputs \(u_k\in {\mathbf{R}}^{n_u}\) are subject to polyhedral constraints defined by the sets \({\mathcal {X}}\) and \({\mathcal {U}}\). The horizon length is T and the initial state is \(x_{\mathrm{init}}\in {\mathbf{R}}^{n_x}\). Matrices \(Q\in {\mathbf{S}}^{n_x}_+\) and \(R\in {\mathbf{S}}^{n_u}_{++}\) define the state and input costs at each stage of the horizon, and \(Q_T\in {\mathbf{S}}^{n_x}_+\) defines the final stage cost.

By defining the new variable \(z = (x_0, \ldots , x_{T}, u_0, \ldots , u_{T-1})\), problem (36) can be written as a sparse QP of the form (2) with a total of \(n_x(T+1) + n_u T\) variables.

Problem instances We defined the linear systems with \(n = n_x\) states and \(n_u = 0.5n_x\) inputs. We set the horizon length to \(T=10\). We generated the dynamics as \(A = I + \varDelta \) with \(\varDelta _{ij} \sim {\mathcal {N}}(0, 0.01)\). We chose only stable dynamics by enforcing the norm of the eigenvalues of A to be less than 1. The input action is modeled as B with \(B_{ij} \sim {\mathcal {N}}(0, 1)\).

The state cost is defined as \(Q = {\mathbf{diag}}(q)\) where \(q_i \sim {\mathcal {U}}(0, 10)\) and \(70\%\) nonzero elements in q. We chose the input cost as \(R = 0.1I\). The terminal cost \(Q_T\) is chosen as the optimal cost for the linear quadratic regulator (LQR) applied to ABQR by solving a discrete algebraic Riccati equation (DARE) [12]. We generated input and state constraints as

$$\begin{aligned} {\mathcal {X}} = \{x_t \in {\mathbf{R}}^{n_x} \mid -{\overline{x}} \le x_t \le {\overline{x}} \}, \qquad {\mathcal {U}}=\{u_t \in {\mathbf{R}}^{n_u} \mid -{\overline{u}} \le u_t \le {\overline{u}}\}, \end{aligned}$$

where \({\overline{x}}_i\sim {\mathcal {U}}(1, 2)\) and \({\overline{u}}_i \sim {\mathcal {U}}(0, 0.1)\). The initial state is uniformly distributed with \(x_{\mathrm{init}} \sim {\mathcal {U}}(-0.5{\overline{x}}, 0.5{\overline{x}})\).

1.4 Portfolio optimization

Portfolio optimization is a problem arising in finance that seeks to allocate assets in a way that maximizes the risk adjusted return [13, 15, 67, 17, §4.4.1],

$$\begin{aligned} \begin{array}{ll} \text{ maximize } &{}\quad \mu ^Tx - \gamma (x^T\varSigma x) \\ \text{ subject } \text{ to } &{}\quad {\mathbf {1}}^Tx = 1 \\ &{} \quad x \ge 0, \end{array} \end{aligned}$$

where the variable \(x \in {\mathbf{R}}^{n}\) represents the portfolio, \(\mu \in {\mathbf{R}}^{n}\) the vector of expected returns, \(\gamma > 0\) the risk aversion parameter, and \(\varSigma \in {\mathbf{S}}_+^n\) the risk model covariance matrix. The risk model is usually assumed to be the sum of a diagonal and a rank \(k < n\) matrix

$$\begin{aligned} \varSigma = FF^T+ D, \end{aligned}$$

where \(F\in {\mathbf{R}}^{n\times k}\) is the factor loading matrix and \(D\in {\mathbf{R}}^{n\times n}\) is a diagonal matrix describing the asset-specific risk.

We introduce a new variable \(y=F^Tx\) and solve the resulting problem in variables x and y

$$\begin{aligned} \begin{array}{ll} \text{ minimize } &{}\quad x^TD x + y^Ty - \gamma ^{-1} \mu ^Tx \\ \text{ subject } \text{ to } &{}\quad y=F^Tx \\ &{}\quad {\mathbf {1}}^Tx = 1 \\ &{}\quad x \ge 0, \end{array} \end{aligned}$$
(37)

Note that the Hessian of the objective in (37) is a diagonal matrix. Also, observe that \(FF^T\) does not appear in problem (37).

Problem instances We generated portfolio problems for increasing number of factors k and number of assets \(n=100k\). The elements of matrix F were chosen as \(F_{ij} \sim {\mathcal {N}}(0,1)\) with \(50 \%\) nonzero elements. The diagonal matrix D is chosen as \(D_{ii} \sim {\mathcal {U}}[0, \sqrt{k}]\). The mean return was generated as \(\mu _i \sim {\mathcal {N}}(0,1)\). We set \(\gamma = 1\).

1.5 Lasso

The least absolute shrinkage and selection operator (Lasso) is a well known linear regression technique obtained by adding an \(\ell _1\) regularization term in the objective [19, 90]. It can be formulated as

$$\begin{aligned} \begin{array}{ll} \text{ minimize }&\quad \Vert Ax - b\Vert _2^2 + \lambda \Vert x\Vert _1, \end{array} \end{aligned}$$

where \(x\in {\mathbf{R}}^{n}\) is the vector of parameters and \(A\in {\mathbf{R}}^{m \times n}\) is the data matrix and \(\lambda \) is the weighting parameter.

We convert this problem to the following QP

$$\begin{aligned} \begin{array}{ll} \text{ minimize } &{}\quad y^Ty + \lambda {\mathbf {1}}^Tt\\ \text{ subject } \text{ to } &{}\quad y = Ax - b\\ &{}\quad -t \le x \le t, \end{array} \end{aligned}$$

where \(y\in {\mathbf{R}}^{m}\) and \(t\in {\mathbf{R}}^{n}\) are two newly introduced variables.

Problem instances The elements of matrix A are generated as \(A_{ij} \sim {\mathcal {N}}(0,1)\) with \(15 \%\) nonzero elements. To construct the vector b, we generated the true sparse vector \(v\in {\mathbf{R}}^{n}\) to be learned

$$\begin{aligned} v_i \sim {\left\{ \begin{array}{ll} 0 &{}\quad \text{ with } \text{ probability } p=0.5\\ {\mathcal {N}}(0, 1/n) &{} \quad \text{ otherwise }. \end{array}\right. } \end{aligned}$$

Then we let \(b=Av + \varepsilon \) where \(\varepsilon \) is the noise generated as \(\varepsilon _i \sim {\mathcal {N}}(0, 1)\). We generated the instances with varying n features and \(m = 100n\) data points. The parameter \(\lambda \) is chosen as \((1/5)\Vert A^Tb\Vert _{\infty }\) since \(\Vert A^Tb\Vert _{\infty }\) is the critical value above which the solution of the problem is \(x=0\).

1.6 Huber fitting

Huber fitting or the robust least-squares problem performs linear regression under the assumption that there are outliers in the data [55, 56]. The fitting problem is written as

$$\begin{aligned} \begin{array}{ll} \text{ minimize }&\quad \sum \nolimits _{i=1}^m \phi _{\mathrm{hub}}(a_i^T x - b_i), \end{array} \end{aligned}$$
(38)

with the Huber penalty function \(\phi _{\mathrm{hub}}:{\mathbf{R}}\rightarrow {\mathbf{R}}\) defined as

$$\begin{aligned} \phi _{\mathrm{hub}}(u) = {\left\{ \begin{array}{ll} u^2 &{}\quad |u| \le M \\ M(2|u|-M) &{}\quad |u| > M. \end{array}\right. } \end{aligned}$$

Problem (38) is equivalent to the following QP [66, Eq. (24)]

$$\begin{aligned} \begin{array}{ll} \text{ minimize } &{}\quad u^Tu + 2M {\mathbf {1}}^T(r + s) \\ \text{ subject } \text{ to } &{}\quad Ax - b - u = r - s \\ &{} \quad r \ge 0 \\ &{} \quad s \ge 0. \end{array} \end{aligned}$$

Problem instances We generate the elements of A as \(A_{ij} \sim {\mathcal {N}}(0,1)\) with \(15 \%\) nonzero elements. To construct \(b\in {\mathbf{R}}^m\) we first generate a vector \(v\in {\mathbf{R}}^n\) as \(v_i \sim {\mathcal {N}}(0,1/n)\) and a noise vector \(\varepsilon \in {\mathbf{R}}^m\) with elements

$$\begin{aligned} \varepsilon _i \sim {\left\{ \begin{array}{ll} {\mathcal {N}}(0,1/4) &{}\quad \hbox { with probability}\ p=0.95 \\ {\mathcal {U}}[0,10] &{} \quad \text {otherwise}. \end{array}\right. } \end{aligned}$$

We then set \(b = Av + \varepsilon \). For each instance we choose \(m=100n\) and \(M=1\).

1.7 Support vector machine

Support vector machine problem seeks an affine function that approximately classifies the two sets of points [21]. The problem can be stated as

$$\begin{aligned} \begin{array}{ll} \text{ minimize }&\quad x^Tx + \lambda \sum \nolimits _{i=1}^m \max (0, b_i a_i^T x + 1), \end{array} \end{aligned}$$

where \(b_i \in \{ -1, +1 \}\) is a set label, and \(a_i\) is a vector of features for the ith point. The problem can be equivalently represented as the following QP

$$\begin{aligned} \begin{array}{ll} \text{ minimize } &{}\quad x^Tx + \lambda {\mathbf {1}}^Tt \\ \text{ subject } \text{ to } &{}\quad t \ge {\mathbf{diag}}(b)Ax + {\mathbf {1}}\\ &{}\quad t \ge 0, \end{array} \end{aligned}$$

where \({\mathbf{diag}}(b)\) denotes the diagonal matrix with elements of b on its diagonal.

Problem instances We choose the vector b so that

$$\begin{aligned} b_i = {\left\{ \begin{array}{ll} +1 &{}\quad i \le m/2 \\ -1 &{}\quad \text {otherwise}, \end{array}\right. } \end{aligned}$$

and the elements of A as

$$\begin{aligned} A_{ij} \sim {\left\{ \begin{array}{ll} {\mathcal {N}}(+1/n,1/n) &{} \quad i \le m/2 \\ {\mathcal {N}}(-1/n,1/n) &{} \quad \text {otherwise}, \end{array}\right. } \end{aligned}$$

with \(15\%\) nonzeros per case.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Stellato, B., Banjac, G., Goulart, P. et al. OSQP: an operator splitting solver for quadratic programs. Math. Prog. Comp. 12, 637–672 (2020). https://doi.org/10.1007/s12532-020-00179-2

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s12532-020-00179-2

Keywords

Mathematics Subject Classification

Navigation