网页 综合 更新时间 2026-11-14 17:02:15

Constraints -

自动蜘蛛 www.cvxpy.org 正文约 3657 字
⏱️ Help us benchmark CVXPY solvers! Contribute problems and results to the Solver Benchmarks project. Read our new paper on the CVXPY internals!
A constraint is an equality or inequality that restricts the domain of an optimization problem. CVXPY has seven types of constraints: non-positive, equality or zero, positive semidefinite, second-order cone, exponential cone, 3-dimensional power cones, and N-dimensional power cones. The vast majority of users will need only create constraints of the first three types. Additionally, most users need not know anything more about constraints other than how to create them. The constraint APIs do nonetheless provide methods that advanced users may find useful; for example, some of the APIs allow you to inspect dual variable values and residuals.
The base class for constraints.
A constraint is an equality, inequality, or more generally a generalized inequality that is imposed upon a mathematical expression or a list of thereof.
A list of expression trees.
A unique id for the constraint.
Checks whether the constraint is DCP.
True if the constraint is DCP, False otherwise.
Checks whether the constraint violation is less than a tolerance.
The absolute tolerance to impose on the violation.
True if the violation is less than tolerance, False otherwise.
ValueError – If the constrained expression does not have a value associated with it.
The numeric residual of the constraint.
The violation is defined as the distance between the constrained expression’s value and its projection onto the domain of the constraint:
where \(v\) is the value of the constrained expression and \(\Pi\) is the projection operator onto the constraint’s domain .
ValueError – If the constrained expression does not have a value associated with it.
An inequality constraint of the form \(x \leq 0\).
The preferred way of creating an inequality constraint is through operator overloading. To constrain an expression x to be nonpositive, write x <= 0; to constrain x to be nonnegative, write x >= 0.
Dual variables associated with this constraint are nonnegative, rather than nonpositive. As such, dual variables to this constraint belong to the polar cone rather than the dual cone.
Note: strict inequalities are not supported, as they do not make sense in a numerical setting.
The expression to constrain.
A unique id for the constraint.
The value of the dual variable.
A NonPos constraint is DCP if its argument is convex.
The shape of the constrained expression.
The size of the constrained expression.
Checks whether the constraint violation is less than a tolerance.
The absolute tolerance to impose on the violation.
True if the violation is less than tolerance, False otherwise.
ValueError – If the constrained expression does not have a value associated with it.
The numeric residual of the constraint.
The violation is defined as the distance between the constrained expression’s value and its projection onto the domain of the constraint:
where \(v\) is the value of the constrained expression and \(\Pi\) is the projection operator onto the constraint’s domain .
ValueError – If the constrained expression does not have a value associated with it.
A constraint of the form \(x = 0\).
The preferred way of creating a Zero constraint is through operator overloading. To constrain an expression x to be zero, simply write x == 0. The former creates a Zero constraint with x as its argument.
A zero constraint is DCP if its argument is affine.
Checks whether the constraint violation is less than a tolerance.
The absolute tolerance to impose on the violation.
True if the violation is less than tolerance, False otherwise.
访问原文 返回搜索 https://www.cvxpy.org/api_reference/cvxpy.constraints.html
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。