A grammar for convexity. Write your problem using approved atoms and composition rules, and a solver can automatically verify and solve it.
Determining whether a problem is convex can be difficult. Even if it is convex, converting it to a form that a solver accepts (like an LP or QP) requires expertise. Disciplined Convex Programming (DCP) automates both steps.
A DCP problem has this structure:
The key grammar rules for constraints ensure that the feasible set is always convex: a convex function ≤ a concave function defines a convex region, and affine equalities define hyperplanes (also convex).
The building blocks of DCP expressions are atoms — functions and sets with known curvature, monotonicity, and range:
| Atom | Curvature | Monotonicity | Range |
|---|---|---|---|
| exp(x) | Convex | Increasing | ≥ 0 |
| log(x), x > 0 | Concave | Increasing | R |
| xp, x ≥ 0, p > 1 | Convex | Increasing | ≥ 0 |
| max(x, y) | Convex | Increasing in both | R |
| x + y | Affine | Increasing in both | R |
The library is extensible — domain experts can add new atoms with verified curvature properties.
A product-free expression has the form a + b>x + c1f1(·) + ... + cqfq(·). The sign rules determine when such an expression is convex or concave based on the signs of the constants c:
| fj curvature | For cjfj to be convex | For cjfj to be concave |
|---|---|---|
| Convex | cj ≥ 0 | cj ≤ 0 |
| Concave | cj ≤ 0 | cj ≥ 0 |
| Affine | Any sign | Any sign |
The composition rules determine the curvature of f(g(x)) from the properties of f and g:
| f curvature | f monotonicity | g curvature | f(g(x)) curvature |
|---|---|---|---|
| Convex | Nondecreasing | Convex | Convex |
| Convex | Nonincreasing | Concave | Convex |
| Concave | Nondecreasing | Concave | Concave |
| Concave | Nonincreasing | Convex | Concave |
DCP verification is a recursive tree walk. Starting from the root expression, apply the sign rules and composition rules at each node. If every node passes, the expression is verified as convex (or concave).
Range analysis propagates bounds upward through the expression tree, using interval arithmetic to determine whether the argument of each atom falls within a domain where its curvature holds.
Once verified, the problem must be transformed into a standard form that a solver can handle (typically a conic program or semidefinite program). Each atom has a canonicalization recipe that introduces auxiliary variables and constraints to linearize nonlinear terms.
For example, exp(x) ≤ t is canonicalized using the exponential cone. The norm ||x|| ≤ t is canonicalized using a second-order cone constraint. The system applies these recipes recursively to flatten the entire expression tree.
After canonicalization, the problem is passed to a conic solver such as SCS, ECOS, or Mosek. These solvers use interior point methods (Chapter 10) tailored to conic structure.
Frameworks implementing DCP include Convex.jl (Julia), CVXPY (Python), and CVX (MATLAB). These tools let you write optimization problems in a natural mathematical syntax and automatically verify, canonicalize, and solve them.
| Concept | Key Fact |
|---|---|
| DCP grammar | Rules that guarantee convexity of composed expressions |
| Atom library | Functions with known curvature, monotonicity, and range |
| Sign rules | Positive scaling preserves curvature; negative scaling flips it |
| Composition rules | f(g(x)) curvature from f's curvature + monotonicity + g's curvature |
| Canonicalization | Automatic transformation to conic form for solving |