This fork extends CVXPY to provide explicit control of warm start and update behavior for OSQP, SCS, QPALM, and PROXQP. More solvers may be supported in the future.
Version baseline:
- This modified fork is developed from CVXPY
v1.9.0.
In original CVXPY, warm start and update behavior is mostly tied to a single warm_start flag and internal cache behavior. This is limiting when:
- Solving many problems with similar structure, where reusing a small pool of
Probleminstances is preferred over storing every instance. - Needing to control update and warm start independently, or warm-start from user-provided values (not only from the previous solve).
The original CVXPY supports warm start from the previous solve and update, both from the internal cached data. I modify osqp_qpif. It supports lower-level control by passing extra data to the solver. An example is stored in test_new.py.
The table below summarizes the new options for controlling OSQP warm start and update behavior:
| Option Name | Where to Set (in data dict) |
Example Value / Usage |
|---|---|---|
| update | data['update'] |
True or False |
| warm start | data['warm_start'] |
True or False |
| warm start values | data['warm_start_solution_dict'] |
{'x': ndarray, 'y': ndarray} |
OSQP update semantics in this implementation:
- If
update=True, a cached solver instance must already exist from a previous solve on the sameProblemobject. update=Trueupdates solver data (q/l/u, andP/Avalues when changed) without rebuilding from scratch.- If
warm_start=True,warm_start_solution_dictmust contain bothxandywith valid lengths. - If
warm_start=False, the solver is explicitly warm-started from zeros.
The original CVXPY only supports warm start from the previous solve, by the internal cached data and no update is supported. I modify scs_conif.
The table below summarizes the new options for controlling SCS warm start and update behavior:
| Option Name | Where to Set (in data dict) |
Example Value / Usage |
|---|---|---|
| update | data['update'] |
True or False |
| warm start | data['warm_start'] |
True or False |
| warm start values | data['warm_start_solution_dict'] |
{'x': ndarray, 'y': ndarray, 's': ndarray} |
SCS update semantics in this implementation:
- If
update=True, a cached solver instance must already exist from a previous solve on the sameProblemobject. - Current update path calls
solver.update(b=..., c=...)(it does not updateA/Pstructure). - If
warm_start=True,warm_start_solution_dictaccepts keys in{x, y, s}with valid lengths. - If
warm_start=False, the solver runs without user-provided warm-start vectors. - For SCS v2, the custom mode keeps the
acceleration_lookback=0retry behavior whenupdate=Falseand no explicitacceleration_lookbackis provided.
The original CVXPY supports warm start from cached solver state for QPALM. I modify qpalm_qpif to expose separate custom controls for update and warm start.
The table below summarizes the new options for controlling QPALM warm start and update behavior:
| Option Name | Where to Set (in data dict) |
Example Value / Usage |
|---|---|---|
| update | data['update'] |
True or False |
| warm start | data['warm_start'] |
True or False |
| warm start values | data['warm_start_solution_dict'] |
{'x': ndarray, 'y': ndarray} |
QPALM update semantics in this implementation:
- If
update=True, a cached solver instance must already exist from a previous solve on the sameProblemobject. update=Trueupdates QPALM problem data (Q/A,q, and bounds) without rebuilding the solver object when possible.- If
warm_start=True,warm_start_solution_dictmust contain bothxandywith valid lengths. - If
warm_start=False, the solver is explicitly warm-started from zeros.
The original CVXPY supports warm start from cached solver state for PROXQP. I modify proxqp_qpif to expose separate custom controls for update and warm start.
The table below summarizes the new options for controlling PROXQP warm start and update behavior:
| Option Name | Where to Set (in data dict) |
Example Value / Usage |
|---|---|---|
| update | data['update'] |
True or False |
| warm start | data['warm_start'] |
True or False |
| warm start values | data['warm_start_solution_dict'] |
{'x': ndarray, 'y': ndarray, 'z': ndarray} |
PROXQP update semantics in this implementation:
- If
update=True, a cached solver instance must already exist from a previous solve on the sameProblemobject. update=Trueupdates solver data (q,b, bounds, andP/A/Fwhen changed) without rebuilding the solver object when possible.- If
warm_start=True,warm_start_solution_dictmust containx,y, andzwith valid lengths. - If
warm_start=False, the solver is explicitly warm-started from zeros.
NOTE: In this custom mode, include both
updateandwarm_startin thedatadict. NOTE:data['warm_start']controls warm start behavior. Thewarm_startargument passed tochain.solve_via_data(...)is ignored.
You may refer to the following minimal example usage (see test_new.py for more detail):
Because solver warm start operates on canonical (standard-form) data, this feature is implemented at the low level through get_problem_data and solve_via_data.
# prob is the predefined problem instance
# Compile
data, chain, inverse_data = prob.get_problem_data(solver = cp.OSQP)
# Set new options
data['update'] = True
data['warm_start'] = True
data['warm_start_solution_dict'] = {'x': previous_x, 'y': previous_y}
results = chain.solve_via_data(problem=prob, data=data, warm_start=False/True, verbose=False, solver_opts={'polishing': False})NOTE: The original
warm_startflag is ignored.
See test_new.py for concrete usage patterns.
Test files updated in this fork:
test_new.pydemonstrates end-to-end low-level usage for OSQP, SCS, QPALM, and PROXQP.cvxpy/tests/test_qp_solvers.pyincludes OSQP, QPALM, and PROXQP custom-path regression tests.cvxpy/tests/test_conic_solvers.pyincludes SCS custom-path regression tests.
pip install git+https://github.com/xuwkk/cvxpy.gitor
pip install git+https://github.com/xuwkk/cvxpy.git@v1.9.0-lapso.5For development, clone and install in development mode:
git clone https://github.com/xuwkk/cvxpy.git
pip install -e .After installation, use CVXPY as usual:
import cvxpy as cpNOTE: You should uninstall the original CVXPY installation before installing this modified version.
Below is the original README.md from the CVXPY repository.
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, SCS, OSQP and HiGHS. 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.
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.11
- Clarabel >= 0.5.0
- OSQP >= 1.0.0
- SCS >= 3.2.4.post1
- NumPy >= 2.0.0
- SciPy >= 1.13.0
- highspy >= 1.11.0
For detailed instructions, see the installation guide.
To get started with CVXPY, check out the following:
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.
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.
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:
- Read the CVXPY source code and improve the documentation, or address TODOs
- Enhance the website documentation
- Browse the issue tracker, and look for issues tagged as "help wanted"
- Polish the example library
- Add a benchmark
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.
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, Bartolomeo Stellato, and Parth Nobel, 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 William Zhang.
For more information about the team and our processes, see our governance document.
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.