Welcome to CVXPY 1.8ΒΆ
Convex optimization, for everyone.
We are hosting a CVXPY community workshop on Feb 20 and 21, virtually and at Stanford University! Sign up today!. We are inviting CVXPY users to share their experience with the library and their application area so we can better serve you! Sign up for a listening session!. We are building a CVXPY community on Discord. Join the conversation!
CVXPY is an open source Python-embedded modeling language for convex optimization problems. It lets you 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
np.random.seed(1)
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`.
print(x.value)
# The optimal Lagrange multiplier for a constraint is stored in
# `constraint.dual_value`.
print(constraints[0].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, mixed-integer convex programs, and quasiconvex programs.
For a guided tour of CVXPY, check out the tutorial. For applications to machine learning, control, finance, and more, browse the library of examples. For background on convex optimization, see the book Convex Optimization by Boyd and Vandenberghe.
CVXPY relies on the open source solvers Clarabel, OSQP, SCS, HIGHS. Additional solvers are supported, but must be installed separately.
Community.
The CVXPY community consists of researchers, data scientists, software engineers, and students from all over the world. We welcome you to join us!
To chat with the CVXPY community in real-time, join us on Discord.
To have longer, in-depth discussions with the CVXPY community, use Github discussions.
To share feature requests and bug reports, use the issue tracker.
Development.
CVXPY is a community project, built from the contributions of many researchers and engineers.
CVXPY is developed and maintained by Steven Diamond, Akshay Agrawal, Riley Murray, Philipp Schiele, Bartolomeo Stellato, and Parth Nobel 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, Jaehyun Park, Enzo Busseti, AJ Friend, Judson Wilson, Chris Dembia, and William Zhang.
We appreciate all contributions. To get involved, see our contributing guide and join us on Discord.
News.
CVXPY 1.8 includes many new solver interfaces such as MOREAU, KNITRO and COSMO, and it makes HiGHS its new default solver for MILPs. This release also includes many new features such as more complete support of ND expressions, unification of the quadratic conic canonicalization paths, and DPP support for complex expressions. For a complete list of changes, see the changelog.