picos.constraints.con_soc¶
Second order conce constraints.
Classes
- class picos.constraints.con_soc.SOCConstraint(normedExpression, upperBound, customString=None)[source]¶
Bases:
ConicConstraint
Second order (
-norm, Lorentz) cone membership constraint.
- __init__(normedExpression, upperBound, customString=None)[source]¶
Construct a
SOCConstraint
.- Parameters
normedExpression (AffineExpression) – Expression under the norm.
upperBound (AffineExpression) – Upper bound on the normed expression.
customString (str) – Optional string description.
- property conic_membership_form[source]¶
Implement for
ConicConstraint
.
- property unit_ball_form[source]¶
The constraint in Euclidean norm unit ball membership form.
If this constraint has the form
with
constant and
an affine expression of a single (matrix) variable
with
for some invertible matrix
and a vector
, then we have
and we can write the elementwise vectorization of the constraint’s feasible region as
Therefor we can repose the constraint as two constraints:
This method returns the quadruple
where
is a fresh real variable vector (the same for subsequent calls) and
is the Euclidean norm unit ball.
- Returns
A quadruple
(X, aff_y, y, B)
of type (BaseVariable
,AffineExpression
,RealVariable
,Ball
) such that the two constraintsX.vec == aff_y
andy << B
combined are equivalent to this one.- Raises
NotImplementedError – If the expression under the norm does not reference exactly one variable or if that variable does not use a trivial vectorization format internally.
ValueError – If the upper bound is not constant, not positive, or if the matrix
is not invertible.
- Example
>>> import picos >>> A = picos.Constant("A", [[2, 0], ... [0, 1]]) >>> x = picos.RealVariable("x", 2) >>> P = picos.Problem() >>> P.set_objective("max", picos.sum(x)) >>> C = P.add_constraint(abs(A*x + 1) <= 10) >>> _ = P.solve(solver="cvxopt") >>> print(x) [ 1.74e+00] [ 7.94e+00] >>> Q = picos.Problem() >>> Q.set_objective("max", picos.sum(x)) >>> x, aff_y, y, B, = C.unit_ball_form >>> _ = Q.add_constraint(x == aff_y) >>> _ = Q.add_constraint(y << B) >>> _ = Q.solve(solver="cvxopt") >>> print(x) [ 1.74e+00] [ 7.94e+00] >>> round(abs(P.value - Q.value), 4) 0.0 >>> round(y[0]**2 + y[1]**2, 4) 1.0