Embedded Code Generation With CVXPY

Maximilian Schaller, Goran Banjac, Steven Diamond, Akshay Agrawal, Bartolomeo Stellato, Stephen Boyd

Research output: Contribution to journalArticlepeer-review

2 Scopus citations


We introduce CVXPYgen, a tool for generating custom C code, suitable for embedded applications, that solves a parameterized class of convex optimization problems. CVXPYgen is based on CVXPY, a Python-embedded domain-specific language that supports a natural syntax (that follows the mathematical description) for specifying convex optimization problems. Along with the C implementation of a custom solver, CVXPYgen creates a Python wrapper for prototyping and desktop (non-embedded) applications. We give two examples, position control of a quadcopter and back-testing a portfolio optimization model. CVXPYgen outperforms a state-of-the-art code generation tool in terms of problem size it can handle, binary code size, and solve times. CVXPYgen and the generated solvers are open-source.

Original languageEnglish (US)
Pages (from-to)2653-2658
Number of pages6
JournalIEEE Control Systems Letters
StatePublished - 2022

All Science Journal Classification (ASJC) codes

  • Control and Systems Engineering
  • Control and Optimization


  • Computational methods
  • Embedded systems
  • Optimization


Dive into the research topics of 'Embedded Code Generation With CVXPY'. Together they form a unique fingerprint.

Cite this