Optimization and Engineering

, Volume 13, Issue 1, pp 1–27

CVXGEN: a code generator for embedded convex optimization



CVXGEN is a software tool that takes a high level description of a convex optimization problem family, and automatically generates custom C code that compiles into a reliable, high speed solver for the problem family. The current implementation targets problem families that can be transformed, using disciplined convex programming techniques, to convex quadratic programs of modest size. CVXGEN generates simple, flat, library-free code suitable for embedding in real-time applications. The generated code is almost branch free, and so has highly predictable run-time behavior. The combination of regularization (both static and dynamic) and iterative refinement in the search direction computation yields reliable performance, even with poor quality data. In this paper we describe how CVXGEN is implemented, and give some results on the speed and reliability of the automatically generated solvers.


Convex optimization Code generation Embedded optimization 


  1. Bacher R (1996) Automatic generation of optimization code based on symbolic non-linear domain formulation. In: Proceedings international symposium on symbolic and algebraic computation, pp 283–291 Google Scholar
  2. Bacher R (1997) Combining symbolic and numeric tools for power system network optimization. Maple Tech Newsl 4(2):41–51 Google Scholar
  3. Bertsekas DP (1975) Necessary and sufficient conditions for a penalty method to be exact. Math Program 9(1):87–99 MathSciNetMATHCrossRefGoogle Scholar
  4. Boyd S, Barratt C (1991) Linear controller design: limits of performance. Prentice-Hall, New York MATHGoogle Scholar
  5. Boyd S, Vandenberghe L (2004) Convex optimization. Cambridge University Press, Cambridge MATHGoogle Scholar
  6. Boyd S, El Ghaoui L, Feron E, Balakrishnan V (1994) Linear matrix inequalities in system and control theory. SIAM, Philadelphia MATHCrossRefGoogle Scholar
  7. Boyd S, Kim S-J, Patil D, Horowitz MA (2005) Digital circuit optimization via geometric programming. Oper Res 53(6):899–932 MathSciNetMATHCrossRefGoogle Scholar
  8. Calvin R, Ray C, Rhyne V (1969) The design of optimal convolutional filters via linear programming. IEEE Trans Geosci Electron 7(3):142–145 CrossRefGoogle Scholar
  9. Cristianini N, Shawe-Taylor J (2000) An introduction to support vector machines and other kernel-based learning methods. Cambridge University Press, Cambridge Google Scholar
  10. Cornuejols G, Tütüncü R (2007) Optimization methods in finance. Cambridge University Press, Cambridge MATHGoogle Scholar
  11. Davis TA (2003) UMFPACK User Guide.Available from http://www.cise.ufl.edu/research/sparse/umfpack
  12. Davis TA (2006) CHOLMOD User Guide. Available from http://www.cise.ufl.edu/research/sparse/cholmod/
  13. Dahleh MA, Diaz-Bobillo IJ (1995) Control of uncertain systems: a linear programming approach. Prentice-Hall, New York MATHGoogle Scholar
  14. Duff IS, Erisman AM, Reid JK (1989) Direct methods for sparse matrices. Oxford University Press, London MATHGoogle Scholar
  15. Eldar YC, Megretski A, Verghese GC (2003) Designing optimal quantum detectors via semidefinite programming. IEEE Trans Inf Theory 49(4):1007–1012 MathSciNetMATHCrossRefGoogle Scholar
  16. Grant M, Boyd S (2008a) CVX: Matlab software for disciplined convex programming (web page and software). http://www.stanford.edu/~boyd/cvx/, July 2008
  17. Grant M, Boyd S (2008b) Graph implementations for nonsmooth convex programs. In: Blondel V, Boyd S, Kimura H (eds) Recent advances in learning and control (a tribute to M. Vidyasagar). Springer, Berlin, pp 95–110 CrossRefGoogle Scholar
  18. Grant M, Boyd S, Ye Y (2006) Disciplined convex programming. In: Liberti L, Maculan N (eds) Global optimization: from theory to implementation: nonconvex optimization and its applications. Springer, New York, pp 155–210 Google Scholar
  19. Graham R, Grötschel M, Lovász L (1996) Handbook of combinatorics, vol 2. MIT Press, Cambridge, Chap 28 Google Scholar
  20. Grant M (2004) Disciplined convex programming. PhD thesis, Department of Electrical Engineering, Stanford University, December 2004 Google Scholar
  21. Gill PE, Saunders MA, Shinnerl JR (1996) On the stability of Cholesky factorization for symmetric quasidefinite systems. SIAM J Matrix Anal Appl 17(1):35–46 MathSciNetMATHCrossRefGoogle Scholar
  22. del Mar Hershenson M, Boyd S, Lee TH (2001) Optimal design of a CMOS op-amp via geometric programming. IEEE Trans Comput-Aided Des Integr Circuits Syst 20(1):1–21 CrossRefGoogle Scholar
  23. del Mar Hershenson M, Mohan SS, Boyd S, Lee TH (1999) Optimization of inductor circuits via geometric programming. In: Design automation conference. IEEE Computer Society, Los Alamitos, pp 994–998 Google Scholar
  24. Johnson SC (1975) Yacc: Yet another compiler-compiler. Computing Science Technical Report, 32 Google Scholar
  25. Kant E (1993) Synthesis of mathematical-modeling software. IEEE Softw 10(3):30–41 CrossRefGoogle Scholar
  26. Kelly FP, Maulloo AK, Tan DKH (1998) Rate control for communication networks: shadow prices, proportional fairness and stability. Journal of the Operational Research society, 237–252, Google Scholar
  27. Löfberg J (2004) YALMIP: a toolbox for modeling and optimization in MATLAB. In: Proceedings of the CACSD conference, Taipei, Taiwan. http://control.ee.ethz.ch/~joloef/yalmip.php Google Scholar
  28. Markowitz H (1952) Portfolio selection. J Finance 7(1):77–91 CrossRefGoogle Scholar
  29. Mattingley J, Boyd S (2008) CVXMOD: convex optimization software in Python (web page and software). http://cvxmod.net/, August 2008
  30. Mattingley JE, Boyd S (2009a) Automatic code generation for real-time convex optimization. In: Palomar DP, Eldar YC (eds) Convex optimization in signal processing and communications. Cambridge University Press, Cambridge Google Scholar
  31. Mattingley JE, Boyd S (2009b) Real-time convex optimization in signal processing. IEEE Signal Process Mag 23(3):50–61 Google Scholar
  32. Mattingley JE, Wang Y, Boyd S (2010) Code generation for receding horizon control. In: Proceedings IEEE multi-conference on systems and control, September 2010, pp 985–992 Google Scholar
  33. Mehrotra S (1992) On the implementation of a primal-dual interior point method. SIAM J Optim 2:575 MathSciNetMATHCrossRefGoogle Scholar
  34. Nesterov Y, Nemirovskii A (1994) Interior point polynomial algorithms in convex programming, vol 13. SIAM, Philadelphia MATHCrossRefGoogle Scholar
  35. Nocedal J, Wright SJ (1999) Numerical optimization. Springer, Berlin MATHCrossRefGoogle Scholar
  36. Saunders MA (1995) Solution of sparse rectangular systems using LSQR and CRAIG. BIT Numer Math 35:588–604 MathSciNetMATHCrossRefGoogle Scholar
  37. Saunders MA (1996) Cholesky-based methods for sparse least squares: the benefits of regularization. In: Adams L, Nazareth JL (eds) Linear and nonlinear conjugate gradient-related methods. Proceedings of AMS-IMS-SIAM joint summer research conference. SIAM, Philadelphia, pp 92–100 Google Scholar
  38. Shi C, Brodersen RW (2004) Automated fixed-point data-type optimization tool for signal processing and communication systems. In: ACM IEEE design automation conference, pp 478–483 Google Scholar
  39. IEEE Journal of Selected Topics in Signal Processing, December 2007, Special Issue on Convex Optimization Methods for Signal Processing Google Scholar
  40. Sturm J (1999) Using SeDuMi 1.02, a MATLAB toolbox for optimization over symmetric cones. Optim Methods Softw 11:625–653. Software available at http://sedumi.ie.lehigh.edu/ MathSciNetCrossRefGoogle Scholar
  41. Sturm JF (2002) Implementation of interior point methods for mixed semidefinite and second order cone optimization problems. Optim Methods Softw 17(6):1105–1154 MathSciNetMATHCrossRefGoogle Scholar
  42. Toh KC, Todd MJ, Tütüncü RH (1999) SDPT3—a Matlab software package for semidefinite programming, version 1.3. Optim Methods Softw 11(1):545–581 MathSciNetCrossRefGoogle Scholar
  43. Tuma M (2002) A note on the LDL T decomposition of matrices from saddle-point problems. SIAM J Matrix Anal Appl 23(4):903–915 MathSciNetMATHCrossRefGoogle Scholar
  44. Vanderbei RJ (1995) Symmetric quasi-definite matrices. SIAM J Optim 5(1):100–113 MathSciNetMATHCrossRefGoogle Scholar
  45. Vandenberghe L (2010) The cvxopt linear and quadratic cone program solvers. http://abel.ee.ucla.edu/cvxopt/documentation/coneprog.pdf, March 2010
  46. Vapnik VN (2000) The nature of statistical learning theory, 2nd edn. Springer, Berlin MATHGoogle Scholar
  47. Vanderbei RJ, Carpenter TJ (1993) Symmetric indefinite systems for interior point methods. Math Program 58(1):1–32 MathSciNetMATHCrossRefGoogle Scholar
  48. Wang Y, Boyd S (2008) Fast model predictive control using online optimization. In: Proceedings IFAC world congress, July 2008, pp 6974–6997 Google Scholar
  49. Wei DX, Jin C, Low SH, Hegde S (2006) FAST TCP: motivation, architecture, algorithms, performance. IEEE/ACM Trans Netw 14(6):1246–1259 CrossRefGoogle Scholar
  50. Wright SJ (1997) Primal-dual interior-point methods. SIAM, Philadelphia MATHCrossRefGoogle Scholar
  51. Ye Y (1997) Interior point algorithms: theory and analysis. Wiley, New York MATHCrossRefGoogle Scholar

Copyright information

© Springer Science+Business Media, LLC 2011

Authors and Affiliations

  1. 1.Electrical EngineeringStanford UniversityStanfordUSA

Personalised recommendations