picos.constraints.con_soc

Second order conce constraints.

Classes

class picos.constraints.con_soc.SOCConstraint(normedExpression, upperBound, customString=None)[source]

Bases: picos.constraints.constraint.ConicConstraint

Second order (2-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 \lVert E(X) \rVert_F \leq c with c > 0 constant and E(X) an affine expression of a single (matrix) variable X with y := \operatorname{vec}(E(X)) =
A\operatorname{vec}(X) + b for some invertible matrix A and a vector b, then we have \operatorname{vec}(X) = A^{-1}(y -
b) and we can write the elementwise vectorization of the constraint’s feasible region as

&\left\{\operatorname{vec}(X) \mid
    \lVert E(X) \rVert_F \leq c \right\} \\
=~&\left\{\operatorname{vec}(X) \mid
    \lVert A\operatorname{vec}(X) + b \rVert_2 \leq c \right\} \\
=~&\left\{A^{-1}(y - b) \mid \lVert y \rVert_2 \leq c \right\} \\
=~&\left\{
    A^{-1}(y - b) \mid \lVert c^{-1}y \rVert_2 \leq 1
\right\} \\
=~&\left\{A^{-1}(cy - b) \mid \lVert y \rVert_2 \leq 1 \right\}.

Therefor we can repose the constraint as two constraints:

\lVert E(X) \rVert_F \leq c
    \Longleftrightarrow
\exists y :
\begin{cases}
    \operatorname{vec}(X) = A^{-1}(cy - b) \\
    \lVert y \rVert_2 \leq 1.
\end{cases}

This method returns the quadruple (X, A^{-1}(cy - b), y, B) where y is a fresh real variable vector (the same for subsequent calls) and B is the Euclidean norm unit ball.

Returns

A quadruple (X, aff_y, y, B) of type (BaseVariable, AffineExpression, RealVariable, Ball) such that the two constraints X.vec == aff_y and y << 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 A 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