网页
综合
更新时间 2026-11-14 17:02:17
FAQ -
自动蜘蛛
www.cvxpy.org
正文约 3423 字
⏱️ Help us benchmark CVXPY solvers! Contribute problems and results to the Solver Benchmarks project. Read our new paper on the CVXPY internals!
You can post questions about how to use CVXPY on StackOverflow or on the CVXPY mailing list. If you’ve found a bug in CVXPY or have a feature request, create an issue on the CVXPY Github issue tracker.
The book Convex Optimization by Boyd and Vandenberghe is available for free online and has extensive background on convex optimization. To learn more about disciplined convex programming, visit the DCP tutorial website.
To check which version of CVXPY you have installed, run the following code snippet in the Python prompt:
The problems you solve in CVXPY must follow the rules of disciplined convex programming (DCP). DCP is like a type system for optimization problems. For more about DCP, see the DCP tutorial section or the DCP tutorial website.
You can test whether a problem, objective, constraint, or expression satisfies the DCP rules by calling object.is_dcp(). If the function returns False, there is a DCP error in that object.
Sometimes solvers encounter numerical issues and fail to solve a problem, in which case CVXPY raises a SolverError. If this happens to you, try using different solvers on your problem, as discussed in the Choosing a solver section. If the solver CVXOPT fails, try using the solver option kktsolver=ROBUST_KKTSOLVER.
See the Solve method options section for a list of the solvers CVXPY supports. If you would like to use a solver CVXPY does not support, make a feature request on the CVXPY Github issue tracker.
The solvers support different classes of problems and occupy different points on the Pareto frontier of speed, accuracy, and open source vs. closed source. For more details, please refer to the “Solve method options” section.
This error likely means you are chaining constraints (e.g., writing an expression like 0 <= x <= 1) or using the built-in Python max and min functions on CVXPY expressions. It is not possible for CVXPY to correctly handle these use cases, so CVXPY throws an (admittedly cryptic) exception.
No, you can only use CVXPY functions on CVXPY objects. If you use a NumPy function on a CVXPY object, it will probably fail in a confusing way.
Yes, they are fully supported.
Please refer to the Semidefinite matrices section.
Please refer to the Attributes section.
Create one variable with each desired property, and then set them all equal by adding equality constraints.
You must mimic the extra dimensions using a dict, as described in this Github issue.
Yes, CVXPY supports shallow and deep copying using the copy and deepcopy functions from the copy module.
A (shallow) copy refers to the same leaf nodes (Variables, Constants, and Parameters) as the original object. Non-leaf nodes are recreated. Constraints keep their .id attribute, as it is used to propagate dual variables.
A deepcopy creates an independent copy of the object while maintaining the relationship between the nodes in the expression tree.
In general, you should vectorize CVXPY expressions whenever possible if you care about performance (e.g., write A * x == b instead of a_i * x == b_i for every row a_i of A). Consult this IPython notebook for details.
The fundamental concepts behind CVXPY are discussed in this paper.
If you use CVXPY for published work, we encourage you to cite the software. Use the following BibTeX citation:
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。