Skip to main content

A domain-specific language for modeling convex optimization problems in Python.

Project description

CVXPY

Build Status

The CVXPY documentation is at cvxpy.org.

Join the CVXPY discord, and use the issue tracker and StackOverflow for the best support.

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 where the variable is constrained by lower and upper bounds:

import cvxpy as cp
import numpy

# Problem data.
m = 30
n = 20
numpy.random.seed(1)
A = numpy.random.randn(m, n)
b = numpy.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 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)

CVXPY is not a solver. It relies upon the open source solvers ECOS, SCS, and OSQP. Additional solvers are available, but must be installed separately.

CVXPY began as a Stanford University research project. It is now developed by many people, across many institutions and countries.

Installation

CVXPY is available on PyPI, and can be installed with

pip install cvxpy

CVXPY can also be installed with conda, using

conda install -c conda-forge cvxpy

CVXPY has the following dependencies:

  • Python >= 3.6
  • OSQP >= 0.4.1
  • ECOS >= 2
  • SCS >= 1.1.6
  • NumPy >= 1.15
  • SciPy >= 1.1.0

For detailed instructions, see the installation guide.

Getting started

To get started with CVXPY, check out the following:

Issues

We encourage you to report issues using the Github tracker. We welcome all kinds of issues, especially those related to correctness, documentation, performance, and feature requests.

For basic usage questions (e.g., "Why isn't my problem DCP?"), please use StackOverflow instead.

Communication

To communicate with the CVXPY developer community, create a Github issue or use the CVXPY mailing list. Please be respectful in your communications with the CVXPY community, and make sure to abide by our code of conduct.

Contributing

We appreciate all contributions. You don't need to be an expert in convex optimization to help out.

You should first install CVXPY from source. Here are some simple ways to start contributing immediately:

If you'd like to add a new example to our library, or implement a new feature, please get in touch with us first to make sure that your priorities align with ours.

Contributions should be submitted as pull requests. A member of the CVXPY development team will review the pull request and guide you through the contributing process.

Before starting work on your contribution, please read the contributing guide.

Citing

If you use CVXPY for academic work, we encourage you to cite our papers. If you use CVXPY in industry, we'd love to hear from you as well; feel free to reach out to the developers directly.

Team

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cvxpy-base-1.1.17.tar.gz (1.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cvxpy_base-1.1.17-cp39-cp39-win_amd64.whl (853.0 kB view details)

Uploaded CPython 3.9Windows x86-64

cvxpy_base-1.1.17-cp39-cp39-manylinux_2_24_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64

cvxpy_base-1.1.17-cp39-cp39-macosx_10_9_x86_64.whl (875.8 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

cvxpy_base-1.1.17-cp38-cp38-win_amd64.whl (852.1 kB view details)

Uploaded CPython 3.8Windows x86-64

cvxpy_base-1.1.17-cp38-cp38-manylinux_2_24_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.24+ x86-64

cvxpy_base-1.1.17-cp38-cp38-macosx_10_9_x86_64.whl (874.9 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

cvxpy_base-1.1.17-cp37-cp37m-win_amd64.whl (851.6 kB view details)

Uploaded CPython 3.7mWindows x86-64

cvxpy_base-1.1.17-cp37-cp37m-manylinux_2_24_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.24+ x86-64

cvxpy_base-1.1.17-cp37-cp37m-macosx_10_9_x86_64.whl (874.0 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

cvxpy_base-1.1.17-cp36-cp36m-win_amd64.whl (851.6 kB view details)

Uploaded CPython 3.6mWindows x86-64

cvxpy_base-1.1.17-cp36-cp36m-manylinux_2_24_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.24+ x86-64

cvxpy_base-1.1.17-cp36-cp36m-macosx_10_9_x86_64.whl (874.0 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

File details

Details for the file cvxpy-base-1.1.17.tar.gz.

File metadata

  • Download URL: cvxpy-base-1.1.17.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for cvxpy-base-1.1.17.tar.gz
Algorithm Hash digest
SHA256 d2b5a88516909f684199efc533ded70fbfd0f733e5ec5cc43bf2ee9832eb550b
MD5 eb112ef6c6c667186d0837c135d8caf9
BLAKE2b-256 212f052fe895615f96e50103b1a959a16cd4c4b6bd941cb02c6213794730e68d

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 853.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for cvxpy_base-1.1.17-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d5da67e9ca13a90d39ff4e3abe8a023f327665783f98509c88e5f6fc5bdc1af9
MD5 638601c497dfa26e9ed4464e5f81b438
BLAKE2b-256 c438292b25dbd43672570f137fbc7bfe8a0437151b78d85a98780896be2668b0

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for cvxpy_base-1.1.17-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 90a6c1f6301d165105ae8a2e0429b707d6a7041b9b4916a4c9f2001b646d31e1
MD5 4224b54d044c8f9c5fcdaad0275084b6
BLAKE2b-256 b3b6d9c4575a01f4d5246d881a3290227cd4cc094f6f8f8cd6072fc9b4e68aa7

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 875.8 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for cvxpy_base-1.1.17-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d43cfa31420a799973156de7204e56c430b552b9094f6f5f9d2220032a5bbe1a
MD5 69477d936ac1e03ebc73db45c1906a6a
BLAKE2b-256 fef903cf1ba937b06d8b6ec8c43e70731e8e9825a20da7b465318beebf185cc5

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 852.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for cvxpy_base-1.1.17-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ad7d599af3748dc48e91c2b81fbf234914017a6d32585e248b173c958c31593a
MD5 07c9a3fe18a894d322d50ead4423915b
BLAKE2b-256 e7e386391a161c33cbdcb56e1c47d7d04b6ff6a47f7395c1ce40f221e1be94f8

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp38-cp38-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp38-cp38-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for cvxpy_base-1.1.17-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 6aba988e59ac04fdf354362f01a74d1d7bbafed6fdd9e3e56c9a478f30f638e0
MD5 e6b35152b0436b2204d17afea38c2b4f
BLAKE2b-256 52454c22c01b827c3b4d85c79fe3976a9965fe896236136feca090158eb93008

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 874.9 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for cvxpy_base-1.1.17-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0b4bcc0f64381c184d6781f996e0e3f9bee76f1a8ca6db89737fee25f020406d
MD5 b52112ab848ea8fb78cbeca4645e9009
BLAKE2b-256 d87dcd42c3b83d353779d04d7a464725f4c18fea683c3de0e54d7a06c38c58b0

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 851.6 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for cvxpy_base-1.1.17-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 94f66ada349014b9d5d5b03e4ac93cb0b4a20221c6b6e5ad7e8d8f023d989e94
MD5 bab3d1a9e03d5da23c0af7fe14ab2508
BLAKE2b-256 ac6692c31b38da23caeb40ae72167528cfa3b6057e73131efd5e887a0deed133

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp37-cp37m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp37-cp37m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for cvxpy_base-1.1.17-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 e13badf5a6bedab06d8fa2296edc775c7f137a4f0c3f57e5d024c53d650196ee
MD5 54529162ce6c8f757ad5c45702fbb117
BLAKE2b-256 8a2ef993406484711d02f459cb702908f88778e71a3c8c0b9945bc3540aad2e5

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 874.0 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for cvxpy_base-1.1.17-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b22f7537948ca950a66e2ff9241a41d07c53e1362cd61fa35965b5e58c3b0607
MD5 0877c66f9e4e826e3fa62ca1ee350637
BLAKE2b-256 3648342fe5497e4c4e2048ef175e13dd6c30cc20ceaacd8ab5c6552d3bce174e

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 851.6 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.8

File hashes

Hashes for cvxpy_base-1.1.17-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 38013558cfdcc75057169d94e40cf347efc162fc6506d388b24903a0833b479e
MD5 d89557c5be91eb1560e7bbb417e998a6
BLAKE2b-256 f44bf20d932bb6726895c39f450236737a37b74fe9ffab4d7bf7222397bb814b

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp36-cp36m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp36-cp36m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.15

File hashes

Hashes for cvxpy_base-1.1.17-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 c13e3187c03def9ae32e577cb3ad5efa33c4ee43681800802062cb2d60fc9f71
MD5 667156712ab852429d6e13c57e67d668
BLAKE2b-256 6cec4c37e2ebf8273daa86933c336b09f29aa4eb9a6cf24a8f3ef7f0e5d49595

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.1.17-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cvxpy_base-1.1.17-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 874.0 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.15

File hashes

Hashes for cvxpy_base-1.1.17-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 05c64f1028eeed8d7f77ecb0710bc3e1c33e95643e99cf985ec861a361bcbe0b
MD5 100b711b0e7ef1666eb7dbaceb69663b
BLAKE2b-256 1f72dfb3ae99f26cda97804a9f9f1b9a9e96abde52d56b84e9b14562c6ceb7f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page