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
  • ECOS >= 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

cvxpy_base-1.5.4-cp312-cp312-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.12 Windows x86-64

cvxpy_base-1.5.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

cvxpy_base-1.5.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

cvxpy_base-1.5.4-cp312-cp312-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

cvxpy_base-1.5.4-cp312-cp312-macosx_10_9_universal2.whl (1.4 MB view details)

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

cvxpy_base-1.5.4-cp311-cp311-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.11 Windows x86-64

cvxpy_base-1.5.4-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

cvxpy_base-1.5.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

cvxpy_base-1.5.4-cp311-cp311-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

cvxpy_base-1.5.4-cp311-cp311-macosx_10_9_universal2.whl (1.4 MB view details)

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

cvxpy_base-1.5.4-cp310-cp310-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.10 Windows x86-64

cvxpy_base-1.5.4-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

cvxpy_base-1.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

cvxpy_base-1.5.4-cp310-cp310-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

cvxpy_base-1.5.4-cp310-cp310-macosx_10_9_universal2.whl (1.4 MB view details)

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

cvxpy_base-1.5.4-cp39-cp39-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.9 Windows x86-64

cvxpy_base-1.5.4-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

cvxpy_base-1.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

cvxpy_base-1.5.4-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

cvxpy_base-1.5.4-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 cvxpy_base-1.5.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d18e4e4129f2a347438afbf74b863b9acd3a4e88016b9081a12f953c65f1d807
MD5 7ac15ac559fa3683af50932b6fb278ab
BLAKE2b-256 7c080248ce6ce9fc523ce25de442b057d34e33160fccdfcfacad9af6cbbe36dc

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 447257756cd3bc5bea258d8df3f735392350df6c91369d5f0fa623b4232fe3aa
MD5 ae188a6e479ec144d2d5ad39dd7bfdfe
BLAKE2b-256 13c004bd91bc66c6de83e7ef0556c1f62bab6a81af1ceea47af2c34575e58851

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3fe37915b4c3dcb692b774b78b99781bb5c574a65241cefad438da7d365de735
MD5 5a6c8e787e0fc6dddc99bd6a7c1899b1
BLAKE2b-256 034018a65f6675e8cdea9d927be8412dfec1f819f5596b02d10b82bbd550fa80

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8a03e711f3a4e34503d9bf789f91b8a0d55cecb22a0bab6f09b3f50b387530ba
MD5 e986a0b25b4856136bfe14cac204d070
BLAKE2b-256 f0336a6bb2caac2222700237d4896a57fbcc2ca1268cb8fdc573a9f44ed3d38b

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp312-cp312-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp312-cp312-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 5aba80d1f3b073b745d177a23241a73d2de53b1932449660a6290026c3424134
MD5 7b91d0c623ec403ac273ec9c77d4e2bd
BLAKE2b-256 3ab72f4c8eb85e8b49ecb50aa3c3a35594a80eb1d4380846af0fe6aa1dbb69f3

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 72dca6ce8891128c0332e58a4db27c8e7454a156d64f9b1fbfa022396bbbd0e5
MD5 eb40d568ef062ac00bc31952a210c305
BLAKE2b-256 b4acfbf1c2623cd20ef22745665f16721f322b9b623c887d5d51ab8ba56c972c

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6adbf4c03797d74c3f57731c7ae5fbece8aaaddd4f91f4ea7c15336fcd4f7bad
MD5 615b1e78baf6a28ee6d80ac0935aaa34
BLAKE2b-256 61d74c3663f58dc80caee9f16111c217695aa79ee122777bb8da76c07f865c39

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 30c746501a55cb4be85bdfad97c6b9afca1c3f4dfe0b0cc3ee35663a4ddc6834
MD5 2bc949b5ce4232abecb664316d51c2fe
BLAKE2b-256 a683daae29af72f3884eb356d63c7ad911dd5fa325e99df9524f44ca17e537df

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dfb7b2a37d15861935b27df810681f7add6f8d13a55d4023c98775213f90359e
MD5 799353833b3e418aedee680b67476d67
BLAKE2b-256 b047bbb0cd800c28e32b396959d9cc77ade9bb8340056d2ef765c279e8e2b729

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 6d854ba7c93c8d2ad3c360a2e6d813cc8c1f40b50606579fa3e24bd5fec56a87
MD5 e994ec8fd8279a175d058ecea2af5a0b
BLAKE2b-256 f5b354d034081206b8b7797326ff01a5035a79725ade9eb34da8722223bf0384

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3da670a4ab581199cc8970eca882bd1ee71f8061e1e835cb1e142c794c252f33
MD5 af72765c942a538a3b2591c4715805e9
BLAKE2b-256 0d8e6da6148dfb2b69f129fbb2ed0042ad9b4f8e80789ebcd8fb7538ff988394

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f9f00a07c46e0fdfcbed20f8202d6564459113ebc0dbe1465acd44bb9e1549b4
MD5 b3f21e3aa23b53dc0efb5b540bb743f1
BLAKE2b-256 bd875c56ce77e80c6ed2d22c112750f36c6c3d9a2d7b4dd5f14f09dca74c8b34

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 582aa72f4d31e0f557e89578a3d93c50f32e75d6393758fb28a07a47e9a76848
MD5 1b5cfcec02e8de081469a590721a8e06
BLAKE2b-256 3d4b77c80fc6587c8242455a048049592c952577cbe1fa3533a9d2a524d1d219

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6a87947a654b6e832ac2d7b9241e05b9f7e30c6429d20ab17a8f0d87c15320f4
MD5 a4efc8fdf2e90f7ea09bbacc36276463
BLAKE2b-256 28f517afe2f6e0e837ac87109bd9445d989050b5dc1681a2bcafd35aeab46a05

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 9ca1a32f19fd6b10d75c466ac2246bfa5845471b7b714fcbd3f951d2bb9f88ab
MD5 ef4c67f13d7b66cd58da2bf028aab910
BLAKE2b-256 00133aac7cc7c6c28ecea364f4de2d377252fa169b466fac6f286ac6b49d0869

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1368ed976b26f4d1824dae1850e597bfaf8b6d3138e0a13b2968b146c4ee4a5f
MD5 17d6318129db51d7d7c8069b297317fa
BLAKE2b-256 89b3c5f7fee6d4c0f46530340b9cc85754b576515408216b20065fe2208baebd

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c1b7236164811eb588c279a0e990b2e6e98a6c52aa2b426729c9f6f6ac3ad810
MD5 e2383fea66220ce3af8b047a192ecb45
BLAKE2b-256 0b05e455e0a45e088361f21e65387c041a66d69b70cc94d0f15a46555a7d259b

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 871925ef474a55a45868a185bc0447fbd561422406e9218d89b3e11166ea154d
MD5 0edfb6c98f244b7c5b170ea3a1eb6f56
BLAKE2b-256 b3fd98a1c418172e071bc823ebd9b064fc252d64376d8189f508854c3756da5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a303eefcd41672aa9d8166e23781826ebd9b24e0552b3b8d2a768cd512bf9cf7
MD5 b4a7473392914b3743deba322138353f
BLAKE2b-256 672b693f817175e41e691d33c124d98c675addd3974d5bca912d81217b9aa568

See more details on using hashes here.

File details

Details for the file cvxpy_base-1.5.4-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for cvxpy_base-1.5.4-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a87d52c73c4c965109f72c7f60f7124215f33d74a2dc62f0b9c36b01aa32022a
MD5 c05c7a7ae23b261d5bd092aa8815519d
BLAKE2b-256 5d0565187fcff9f50dee6b18b2ee7c5c5ab951778648eeb5af2d3340e8cdc232

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