Skip to main content

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

Project description

CVXPY

Build Status PyPI - downloads Conda - downloads

The CVXPY documentation is at cvxpy.org.

We are building a CVXPY community on Discord. Join the conversation! For issues and long-form discussions, use Github Issues and Github Discussions.

Contents

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)

With CVXPY, you can model

  • convex optimization problems,
  • mixed-integer convex optimization problems,
  • geometric programs, and
  • quasiconvex programs.

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.

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 Github Issues.

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.

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, Riley Murray, and Bartolomeo Stellato, 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, Michael Sommerauer, Jaehyun Park, Enzo Busseti, AJ Friend, Judson Wilson, Chris Dembia, and Philipp Schiele.

For more information about the team and our processes, see our governance document.

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, on Discord or over email.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

cvxpy-1.2.3.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-1.2.3-cp310-cp310-win_amd64.whl (836.2 kB view details)

Uploaded CPython 3.10Windows x86-64

cvxpy-1.2.3-cp310-cp310-manylinux_2_24_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64

cvxpy-1.2.3-cp310-cp310-macosx_10_9_x86_64.whl (883.5 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

cvxpy-1.2.3-cp310-cp310-macosx_10_9_universal2.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

cvxpy-1.2.3-cp39-cp39-win_amd64.whl (836.1 kB view details)

Uploaded CPython 3.9Windows x86-64

cvxpy-1.2.3-cp39-cp39-manylinux_2_24_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64

cvxpy-1.2.3-cp39-cp39-macosx_10_9_x86_64.whl (883.5 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

cvxpy-1.2.3-cp39-cp39-macosx_10_9_universal2.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

cvxpy-1.2.3-cp38-cp38-win_amd64.whl (836.2 kB view details)

Uploaded CPython 3.8Windows x86-64

cvxpy-1.2.3-cp38-cp38-manylinux_2_24_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.24+ x86-64

cvxpy-1.2.3-cp38-cp38-macosx_10_9_x86_64.whl (883.9 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

cvxpy-1.2.3-cp38-cp38-macosx_10_9_universal2.whl (1.1 MB view details)

Uploaded CPython 3.8macOS 10.9+ universal2 (ARM64, x86-64)

cvxpy-1.2.3-cp37-cp37m-win_amd64.whl (836.1 kB view details)

Uploaded CPython 3.7mWindows x86-64

cvxpy-1.2.3-cp37-cp37m-manylinux_2_24_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.24+ x86-64

cvxpy-1.2.3-cp37-cp37m-macosx_10_9_x86_64.whl (883.1 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

Details for the file cvxpy-1.2.3.tar.gz.

File metadata

  • Download URL: cvxpy-1.2.3.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.14

File hashes

Hashes for cvxpy-1.2.3.tar.gz
Algorithm Hash digest
SHA256 21a794b6fd2f760a9d766d68fbe4946534f65e89b73e89b889c5503985558b86
MD5 7d478c4e49837bf995e0fdf217aced2c
BLAKE2b-256 32cad1919f41f8ef77e464b15c4be2c356da224edad1a6b4a576ada8c89970e7

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: cvxpy-1.2.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 836.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for cvxpy-1.2.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d9efdf1fe8c8d881500c44ee11c33726de5b457cda8ea0073ae2346692e4d119
MD5 87149aa76103db9bc02bea1530da9fb1
BLAKE2b-256 2b8db7d62a1eb652b610f18d4b17f7542d61c41a451542343a0e136ddcd4bc98

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp310-cp310-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.2.3-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 69505db744df100efab5047b36eec1dd7bdd0617644117325c11c9c029b627d7
MD5 7f2ffbf5a34e7f1bbecdb07740dedbd8
BLAKE2b-256 313ff79b3c488109305f2258c99da817cd283ecbe62d5fcdadcf059d7edd2c81

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.2.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dc15d7e82ffe392962c26a470d7e9af7cfb779b9cd4fdcb3b7cd00794305b088
MD5 e93bd9adc521856586c6f33714fbc526
BLAKE2b-256 9323aecef54a27043d185d07f04e59955017d017c2abf6ce8ec7d157c3558aae

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for cvxpy-1.2.3-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a0c2f6c5d99026f431a0d5b544fe3abd42fdf8a73d0cf8a940c7be2a43fa8000
MD5 4538f1a319b28ced31f2435ef2fb5824
BLAKE2b-256 7540101c66cf30f3d18de4912265ce2dc960e34305d8c41dd0dfc9789a8bf130

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: cvxpy-1.2.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 836.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for cvxpy-1.2.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ab9b8702a041a45a88e0190bba4d1fb3050aa937bf0cee0c27a1a429e4b2a615
MD5 f6f8b98137bc5a43b4394cd481d92795
BLAKE2b-256 3e67580865ee73bf3fa0d67f71c3adcc8f6e07668661723f0ab2dec2c4d1e8a3

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.2.3-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 ff3438c801176f2ce639f2e144bbdc4a5897ef1396238a09cf7ef582c972b336
MD5 fa56076541ad67300613e7e28b6ab5f6
BLAKE2b-256 748aab987adf4ef988e99b55a5f88ada59e22e10326bd09bda6264130ec9b3c5

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.2.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ca0820e88e69bc85c18e23bfa3ad87e1c7219a699ec42fa720fd77882445e346
MD5 71459d62e70b124cb022fd42716ac56e
BLAKE2b-256 3670a9a89db7a44a603f58a67cebbeeded91980768499bda0720804cecf1d22e

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

  • Download URL: cvxpy-1.2.3-cp39-cp39-macosx_10_9_universal2.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.14

File hashes

Hashes for cvxpy-1.2.3-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 799139487bfbd9804fc661751b280db534a0e84453a6a2b848b5a14f9a4e1e7e
MD5 9ee7646e2a37b1b595567c78e9fa3aae
BLAKE2b-256 e63967d2c5ceecf920d71918a19b7e7e708c55850a5e57a19d537fb8e6e2eb95

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: cvxpy-1.2.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 836.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for cvxpy-1.2.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ade4f4028c5adb041dafd9ef3da82d428e1ea015f30b20949ccd325c42bda519
MD5 15c8f59798f6a6a616c130f03b0c026f
BLAKE2b-256 b1568237dbf333fd7501f686de876bc018bcc17adc5a45adc7cbf4a7401b6a88

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp38-cp38-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.2.3-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 ab4e80303f268315e5e216d7dbddd66e976f81573568e716f9f25197282cc5de
MD5 df1b252c96a08ef12071ec94c26cf177
BLAKE2b-256 03e63780f75141209c9ed88a1834450048f028913a1e1db931aacba3bbd55d87

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.2.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3767189e541cbcb1259ac28df2aaf5f69485dabb6c9b3884ea0264894e57ee50
MD5 1e89139022d485e89bc702df1a0b5162
BLAKE2b-256 730f192044948bb430f605b0839e9cb4d22f2da4d5ddf86acb6cf6c117eac0e4

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp38-cp38-macosx_10_9_universal2.whl.

File metadata

  • Download URL: cvxpy-1.2.3-cp38-cp38-macosx_10_9_universal2.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, macOS 10.9+ universal2 (ARM64, x86-64)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.14

File hashes

Hashes for cvxpy-1.2.3-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 77d6e649cb3cbd2f9df2a0714cf005edcc937cca8aed4a1db41a3f8f6c8311eb
MD5 640d07139904fd43086bb1344521e762
BLAKE2b-256 7b23457c59f3ee05cdeebe56e8db82365a587d04037977db91966fbb8320c7ae

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: cvxpy-1.2.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 836.1 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for cvxpy-1.2.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 dfb39124f0a5e39d592b39fd21f485b2159838e97c03407ba8439c15a4be9676
MD5 e89a714787879dee36f74665a2aa0532
BLAKE2b-256 e0d3ffea2c71eeeca489293f62501616ca59a2dafb679bb7dda22791f65ffbdc

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp37-cp37m-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.2.3-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 4072a76d9fa1d45a503284ba20a33a7b247bd6e273c4b01e0ce02bd866c8491b
MD5 ebe8e985c1882f1dd22fc804e0d0551a
BLAKE2b-256 b1f11c7aac64e4681632a821553ee61fdd2bfc3c9e290fc05ff3ba06ee1d8b8d

See more details on using hashes here.

File details

Details for the file cvxpy-1.2.3-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.2.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bedd6188d58c89dba55d12fa176a25ae32c9c30f70e8725ffcc8723309dc625b
MD5 685f55f158abff9c50fc6b3bc3ddbfc9
BLAKE2b-256 b58c14fb24f19954dc26dc7ce396e9bc7789d8b7f7c9188a08c8f1cc8425fe62

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