Skip to main content

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

Project description

CVXPY

Build Status PyPI - downloads Conda - downloads Coverage Benchmarks OpenSSF Scorecard

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 Clarabel, 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.9
  • Clarabel >= 0.5.0
  • OSQP >= 0.6.2
  • SCS >= 3.2.4.post1
  • NumPy >= 1.20.0
  • SciPy >= 1.6.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, Philipp Schiele, 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, Jaehyun Park, Enzo Busseti, AJ Friend, Judson Wilson, Chris Dembia, and Parth Nobel.

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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

tyba_cvxpy-1.6.0-cp312-cp312-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.12 Windows x86-64

tyba_cvxpy-1.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

tyba_cvxpy-1.6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

tyba_cvxpy-1.6.0-cp311-cp311-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

tyba_cvxpy-1.6.0-cp311-cp311-macosx_10_9_universal2.whl (1.5 MB view details)

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

tyba_cvxpy-1.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

tyba_cvxpy-1.6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

tyba_cvxpy-1.6.0-cp310-cp310-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

tyba_cvxpy-1.6.0-cp310-cp310-macosx_10_9_universal2.whl (1.4 MB view details)

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

tyba_cvxpy-1.6.0-cp39-cp39-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.9 Windows x86-64

tyba_cvxpy-1.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

tyba_cvxpy-1.6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

tyba_cvxpy-1.6.0-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

tyba_cvxpy-1.6.0-cp39-cp39-macosx_10_9_universal2.whl (1.4 MB view details)

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

File details

Details for the file tyba_cvxpy-1.6.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 79f9f01648282d148ca92dc93dbc729975586e03f4c45066dd0e8666544f9a5f
MD5 4f1f93d8eb76f2ed8cd641dea2b21699
BLAKE2b-256 ff7e1c549cd0c62b037639c6e0c465cecaaa290397ac1781786c0ab36855abe4

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ada90219cc28aad3d8284963b6b87aa2a9392369e528103578a37e1c949a9c6b
MD5 deb99a6e47cd24d3b5fe6369490d4de5
BLAKE2b-256 7ba726950b43f49d925ebc256fd159cedf66cfb34cbb6fa4085c157c4c57ead2

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d7b83030d660f0fc2b454381ddcc7a96ddee07cac5aeac18365a94ce7b793725
MD5 8168b866a40c0a42f10b188c0d4a6c54
BLAKE2b-256 048d0520cdd6ba70dab0d3fb4180f6c637adb499ed1b67c304a9b79f10b3e29d

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e34c0cb1d206efa3cdb96c6d902e1fa0f6756f4374e66174023c9998505f2220
MD5 6ed30b808c942f33e748ad984e24eb1a
BLAKE2b-256 3acdbdcf9bd353c62549a4442e74b1e831a1650a1b55990dafff285fbaf75296

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 f194bfb45d6c99420a1f51935f66b59a82f839cfaad8a84231fc67d130cf4f13
MD5 011282f6cabff53e6a89d09999000b90
BLAKE2b-256 2aebf723cfac71ab17e310bd4ad46c4b080c2009b0678bbffaf2778e30030e38

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 431fd691237e1b6b7015261c63b6f76793d1c194c52a7b2cdc31e0f7d8eba2ca
MD5 9a9912ddc480bcde12a08e02915cbee2
BLAKE2b-256 6a9c57e202ff1f2f26ba41f7401a050a26079dd8270004918f99bca3959bc6fb

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 45275441b1f6283384f254ae6443dcb3461e491b1ae880a9c44af1226e14a6d9
MD5 adeb1283e2a7e7f5b900280f24ed8e3f
BLAKE2b-256 53e4a57f838691c55ffa37fb8f6f549ecab4be5612fddc5fb798a5979f907630

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 385fce9348bcecd4a6860952e81416c0a4667204ba5677b5a1c864cfd4d3c2cf
MD5 944d834fa717f110177992bd90a3a7fb
BLAKE2b-256 973ce51a4b48dff9a476c6baf02454f34e658d50c1b42725aa24a070773c7113

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 f6d92131877a82995b31084337b4d6ac4585cb8d6d2dde4e553d5038deb5d655
MD5 05a7622f212a246b150b4fd266c19fcf
BLAKE2b-256 4a4c4ffefd4a16f2f6e5ac2908b528cfb619daca425abfc951f943050b86bff4

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c9874b9381e955e8e78b6060bb1a346082808a7bba093de4743ed542add7b79d
MD5 054ace878b6e53a251e36b3c76ca7338
BLAKE2b-256 305c5772c806c5ebc81d55e1d6309584dd6836742604db1445200afdab496712

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9d4c136fbb84a5a42a657ce730edf94be41dcca4b3aec5a4c54b17b8062e399c
MD5 b13e64dfc0a28d5d67a47cfb053fb752
BLAKE2b-256 8ae8faf1752e0a5e63aa129b5b5e63395ba50841ab53227cc52649444c554437

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e6b450411aef4b6816758ce36259ef52f207f4099a3066898cf86b49111d00a0
MD5 3c2cbea34366b7d304667453328835c0
BLAKE2b-256 2a6fb0af7ddcbb6bb5058bac0e747fac3943038857cb3ff05a3ee8794af0bdde

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3981f1c9c0166a2c1283b170be3e885671c0d901fe648c804abc3425d4967398
MD5 396dc299ff0ab9f28aa13e6747a4bf94
BLAKE2b-256 813707c1bbf519647a60b21fe945d49fca9f404edb7ea5479ea48ede7b028583

See more details on using hashes here.

File details

Details for the file tyba_cvxpy-1.6.0-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for tyba_cvxpy-1.6.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 fe04b3991a826fea30e6a3b23fc2c5bd4858d77998be429d364057f27cc1d3b1
MD5 ef18b6741ec962cb93d7032184bba3b8
BLAKE2b-256 3c77645becdfe11ea5c6e6e08cbe59526009cc324f66a34c0cc4fcb16635972b

See more details on using hashes here.

Supported by

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