Welcome to CVXPY 1.1ΒΆ

Convex optimization, for everyone.

For the best support, join the CVXPY mailing list and post your questions on Stack Overflow.

CVXPY is a Python-embedded modeling language for convex optimization problems. It allows you to express your problem in a natural way that follows the math, rather than in the restrictive standard form required by solvers.

For example, the following code solves a least-squares problem with box constraints:

import cvxpy as cp
import numpy as np

# Problem data.
m = 30
n = 20
A = np.random.randn(m, n)
b = np.random.randn(m)

# Construct the problem.
x = cp.Variable(n)
objective = cp.Minimize(cp.sum_squares(A @ x - b))
constraints = [0 <= x, x <= 1]
prob = cp.Problem(objective, constraints)

# The optimal objective value is returned by `prob.solve()`.
result = prob.solve()
# The optimal value for x is stored in `x.value`.
# The optimal Lagrange multiplier for a constraint is stored in
# `constraint.dual_value`.

This short script is a basic example of what CVXPY can do; in addition to convex programming, CVXPY also supports a generalization of geometric programming.

For a guided tour of CVXPY, check out the tutorial. Browse the library of examples for applications to machine learning, control, finance, and more.



CVXPY relies on the open source solvers ECOS, OSQP, and SCS. Additional solvers are supported, but must be installed separately. For background on convex optimization, see the book Convex Optimization by Boyd and Vandenberghe.


CVXPY is a community project, built from the contributions of many researchers and engineers.

CVXPY is developed and maintained by Steven Diamond, Akshay Agrawal, and Riley Murray, with many others contributing significantly. A non-exhaustive list of people who have shaped CVXPY over the years includes Stephen Boyd, Eric Chu, Robin Verschueren, Bartolomeo Stellato, Jaehyun Park, Enzo Busseti, AJ Friend, Judson Wilson, and Chris Dembia.

We appreciate all contributions. To get involved, see our contributing guide and join us on Discord.