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 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.8
  • Clarabel >= 0.5.0
  • OSQP >= 0.6.2
  • ECOS >= 2
  • SCS >= 3.0
  • 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, 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, Michael Sommerauer, Jaehyun Park, Enzo Busseti, AJ Friend, Judson Wilson, and Chris Dembia.

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.4.2.tar.gz (1.6 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.4.2-cp311-cp311-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.11Windows x86-64

cvxpy-1.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cvxpy-1.4.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

cvxpy-1.4.2-cp311-cp311-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

cvxpy-1.4.2-cp311-cp311-macosx_10_9_universal2.whl (1.4 MB view details)

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

cvxpy-1.4.2-cp310-cp310-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.10Windows x86-64

cvxpy-1.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

cvxpy-1.4.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

cvxpy-1.4.2-cp310-cp310-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

cvxpy-1.4.2-cp310-cp310-macosx_10_9_universal2.whl (1.4 MB view details)

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

cvxpy-1.4.2-cp39-cp39-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9Windows x86-64

cvxpy-1.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

cvxpy-1.4.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

cvxpy-1.4.2-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

cvxpy-1.4.2-cp39-cp39-macosx_10_9_universal2.whl (1.4 MB view details)

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

cvxpy-1.4.2-cp38-cp38-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.8Windows x86-64

cvxpy-1.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

cvxpy-1.4.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

cvxpy-1.4.2-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

cvxpy-1.4.2-cp38-cp38-macosx_10_9_universal2.whl (1.4 MB view details)

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

File details

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

File metadata

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

File hashes

Hashes for cvxpy-1.4.2.tar.gz
Algorithm Hash digest
SHA256 0a386a5788dbd78b7b20dd071524ec636c8fa72b3628e69f1abc714c8f9811e5
MD5 790776f7380bc1285c559fbb6c1d2d01
BLAKE2b-256 30646dcaa7799d2f06e359189fe135118e1fe707bcacdeec733abe45f9e63205

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: cvxpy-1.4.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for cvxpy-1.4.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 78560a02607d16fbb26db6306e7ce6d8e4fcda49cf04578d199ac050c2e74daa
MD5 bfdb718d34519100bbc848d061ef1f2f
BLAKE2b-256 38855f46779431dd978f62a1f5bd64df05d9a1418cc50d7294e98bf445e31068

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fea513f4bf83491a1c9e5366faa4ca9fc21ec9522c30bcd55e49de9bb85fe9a2
MD5 63e4f814b2166fc1c5503eb8d59ad067
BLAKE2b-256 c932b70d79bc5412cf1db141d69c931c2ecf351c839e6d24441056b10ba20f48

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c6551ef3b325d707e98f920dd120ebaa968f3ac3484c21f8567f2081967d26f0
MD5 7e6e1b9426ca543687fbea6c36122796
BLAKE2b-256 3632cdcf69431b95418d904d43e31e4846fc3bd63a64b398b560c383d93250f3

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f8419dffcadefc16e6fcbe8a088068c29edb1f28ea90582f075a96f21ae7ff11
MD5 ad2300861c97191892e7a797f99ed557
BLAKE2b-256 875af86e039c09694b7d3370b4f1d219c40d8396add76d4584dd98bd190b5ff2

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 079fe6aeaeec2ddf6163ff8ca6510afd5c2b66ea391605791a77b51e534b935e
MD5 2a2b99f6dd30bbd702a507f1bd0642d5
BLAKE2b-256 7bc6c8961d51b6edfec8de5f36218ee91bcd04973f3d68781f4b562504457a31

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cvxpy-1.4.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for cvxpy-1.4.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2a09ebd8f7a8b6b5d026d03295daee0780e2f6847fbe6f207e9764045ffbbfc9
MD5 fa6518d155fb9f708a00202ed49b56d5
BLAKE2b-256 0a92125e680682ef7350e828735778b9b5b0d458226dd61b3609af485d0ff18a

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba9d006f76925127cd42b80e2d98c950a8339f8204b4c23fa25af83d895e95fa
MD5 04a6c0b576bd7b8ed40ff3f9f42f46ee
BLAKE2b-256 d345b0a318a7601985a3cb2262bbfc936389aeb33cf2faf65123acf2663c0776

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 38c2191d4142baac206ac590ba9e5cb1c6e025ac95d0a746692c9cf8d1afd46e
MD5 052477736a1d116089615d14ec3ce0ba
BLAKE2b-256 eaf43e72ff523590a35728df6f9bd151eab696222266c5533b11f430dbcd82d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f257971b007261d53ec7f50618f0c6a511387dd7df6cd686d2647c3fa91da0eb
MD5 b3466029f41c2ec631c8d46f659f205c
BLAKE2b-256 f833ea201eeac09f7b58150a29fd54c8b09780e2712fcade5e2322c4677d0ae7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 06231c0b2a65f7c8ba32c2772576c24e93e1ca964444b90c6bad366b9c0a5bdc
MD5 d99be48084a5405f4ade07cef01ec313
BLAKE2b-256 b6f4c9913b0291addabeaccd3082555a6e887774d7a12cf9ace23c6f4c7bca5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cvxpy-1.4.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • 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.4.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b7cfc6be34b288acade31b58a1e88b119487165d0ed877db9decf7fd676502f6
MD5 2e784b8d97e5700d7ed71b5e92db6535
BLAKE2b-256 962a6fa0f96bc56dcd16fd112519c7d848a013b99f2859ac5cbb4ac18d284830

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d3f73ff4f0e7bff1e438dc2b02490d7a8e1027c421057a7971b4ca4982c28d60
MD5 68cf3e50994b62c5619011760c050181
BLAKE2b-256 05a7888a95f635959f7b313008a20a463462be2dc1472df3e86ffe426f8de23f

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 20015b82117c0253ca803c4e174010067bda0eedb539503ba58b98e00acdd0f2
MD5 de022487728ac6803f08b75ac385a138
BLAKE2b-256 94961274790b4d9a1c83b6d38ccbb43611b680405029d9639d7fad91a01bf718

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 63102885fdfd3eae716c042ee7aad9439d0b71ba22e5432c85f0e35056fcb159
MD5 4df71ca596ac7af4a3187687a651cd9a
BLAKE2b-256 f6c7113cb8997ce479e996212d85e858b22d13329e1feee2c3185c5b0e347de1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cvxpy-1.4.2-cp39-cp39-macosx_10_9_universal2.whl
  • Upload date:
  • Size: 1.4 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.18

File hashes

Hashes for cvxpy-1.4.2-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 bb1d6af8406efa1de0408d0a76c248da3185cade49f45c443239772830b7d6bb
MD5 ee45d225b5e5a7cf6ed216789811ed81
BLAKE2b-256 e4f7900f90efc5f5c023a24734dbcd58cf1f024f92f2897b5e1556d1daf92ae1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cvxpy-1.4.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • 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.4.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 779c19be964f7a586337fd4d017c7a0202bf845e08b04a174850f962b45b2a00
MD5 66d56128747c6ad38861d74fa529d291
BLAKE2b-256 dce39909149d77ca4c341870d065feff1a825adb947103c42652f457272b7925

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec30efa81d1f79f668b0fa6e8ac654047db7a3e844ab16022e1b5dcf52177192
MD5 74190bf08e25299b1be14061fa671ff0
BLAKE2b-256 820aa78a7646a941ee588e30d7682d6b2796d7f41499c5f6fb0913e4ecd5f06f

See more details on using hashes here.

File details

Details for the file cvxpy-1.4.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 213b465450f4254226e6c18c70e25e911ae2c60176621f1bc2d9a0eb874288db
MD5 7b8b8c7b5af1e6f4c97f0a0c7a255790
BLAKE2b-256 e34df54fa5876fed9d2c3e1afe1af6e14f1ea8ccc95383457edb55b806a33f1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cvxpy-1.4.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 32999d550a923c9448d973ef9d3ab75d73e1bdf56102fc32fe7ccb5e0cb5d7a3
MD5 19987fb3405e21e986b4b2bf90611e57
BLAKE2b-256 33a6d004aa6aa085ae4abff5dc8168075c31ec701da67c35bd843dcfdd8d2bff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cvxpy-1.4.2-cp38-cp38-macosx_10_9_universal2.whl
  • Upload date:
  • Size: 1.4 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.18

File hashes

Hashes for cvxpy-1.4.2-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 9817cf8da86641e2d322911844e86b8e7b1d93d9b2d57ae6d33e84be430e1e04
MD5 6e1bbff943bbabdedb6f30463870f8a3
BLAKE2b-256 45fe665fb2cbf423e9642c21501f36a0867e4173ae42be51289ba0eeaf753e09

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