A rewriting system for convex optimization problems

Akshay Agrawal, Robin Verschueren, Steven Diamond, Stephen P. BoydJ. Control. Decis 2017 · DOI

Introduction

Convex optimization has become a foundational tool in fields ranging from machine learning to control systems. To bridge the gap between high-level mathematical modeling and the rigid requirements of numerical solvers, researchers utilize Domain-Specific Languages (DSLs) like CVXPY. However, the process of "canonicalization"—translating these human-readable models into solver-specific matrices and vectors—has historically relied on ad-hoc, hard-coded rules. This paper introduces a formalized, modular rewriting system that treats canonicalization as a compilation process, significantly improving the extensibility and efficiency of optimization software.

System Architecture

The proposed system adopts a three-phase architecture inspired by traditional software compilers, such as GCC or Clang. This modularity separates the user-facing mathematical expressions from the low-level solver interfaces.

The three-phase architecture of the rewriting system, from DSL input to solver output.
  1. Front End: This phase parses the DSL code into an intermediate representation, typically an abstract syntax tree (AST) of mathematical expressions.
  2. Analyzer: The analyzer inspects the problem's structure to determine its classification (e.g., Linear Program, Quadratic Program, etc.). It uses this information to select the most efficient numerical solver available.
  3. Back End: The back end translates the intermediate representation into the specific standard form required by the chosen solver.

The Reduction Mechanism

The core innovation of this architecture is the reduction. A reduction is a modular function that transforms a problem into an equivalent one. By formalizing these transformations, the system can chain multiple reductions together to reach a solver-compatible state.

The process of canonicalization and retrieval through a chain of problem reductions.

Each reduction consists of three primary components:

  • accepts: A check to verify if the reduction is applicable to the current problem.
  • apply: The transformation logic that converts the problem (e.g., converting a maximization to a minimization).
  • retrieve: A crucial inverse mapping that translates the solver's solution back into the original variable space, ensuring the user receives the answer in their expected format.

Key Insights

The transition to a compiler-like architecture provides several advantages:

  • Automated Solver Matching: Optimization problems exist in a hierarchy (e.g., $LP \subset QP \subset SOCP \subset SDP$). The system's analyzer can automatically route problems to the most specialized—and thus fastest—solver.
  • Unified Presolves: Generic optimization techniques, such as eliminating fixed variables or redundant constraints, can be implemented once as reductions rather than being re-implemented by every individual solver.
  • Extensibility: New solvers and problem classes can be added by simply defining new reductions, without modifying the core DSL logic.

Conclusion

The implementation of this rewriting system in CVXPY 1.0 demonstrates that treating optimization canonicalization as a formal compilation task provides a robust and maintainable framework. By utilizing modular reductions, the system automates complex transformations and solver selection, allowing researchers to focus on modeling rather than the intricacies of numerical implementation. While currently limited to Disciplined Convex Programming (DCP) compliant problems, future work aims to expand the library of reductions to include more advanced matrix decompositions and specialized presolves.

Summary updated

BibTeX
@article{agrawal2017rewriting,
  author = {Akshay Agrawal and Robin Verschueren and Steven Diamond and Stephen P. Boyd},
  title = {{A rewriting system for convex optimization problems}},
  journal = {J. Control. Decis.},
  year = {2017},
  doi = {10.1080/23307706.2017.1397554},
}
Figure