picos.expressions.exp_quadratic¶
Implements QuadraticExpression
.
Classes

class
picos.expressions.exp_quadratic.
QuadraticExpression
(string, quadraticPart={}, affinePart=<1×1 Real Constant: 0>, scalarFactors=None, copyDecomposition=None)[source]¶ Bases:
picos.expressions.expression.Expression
A scalar quadratic expression of the form .

__init__
(string, quadraticPart={}, affinePart=<1×1 Real Constant: 0>, scalarFactors=None, copyDecomposition=None)[source]¶ Initialize a scalar quadratic expression.
This constructor is meant for internal use. As a user, you will most likely want to build expressions starting from
variables
or aConstant
. Parameters
string (str) – A symbolic string description.
quadraticPart – A
dict
mapping PICOS variable pairs to CVXOPT matrices. Each entry represents a quadratic form where and refer to the isometric realvectorizations
that are used by PICOS internally to store the variables and , respectively. The quadratic part of the expression is then given as .affinePart (AffineExpression) – The affine part of the expression.
scalarFactors – A pair with both and scalar real affine expressions representing a known factorization of the expression.
copyDecomposition (QuadraticExpression) – Another quadratic expression with equal quadratic part whose quadratic part decomposition shall be copied.

property
A
¶ An affineaugmented quadratic coefficient matrix, condensed.
For a quadratic expression , this is but with zero rows and columns removed.
The vector
y
is a condensed version of that refers to this matrix, so thatq.y.T*q.A*q.y
equals the expressionq
. Raises
ValueError – When the expression is zero.

property
L
[source]¶ The of an Cholesky decomposition of
Q
. Returns
A CVXOPT lower triangular sparse matrix.
 Raises
ValueError – When the quadratic part is zero.
ArithmeticError – When the expression is not convex, that is when the matrix
Q
is not numerically positive semidefinite.

property
M
[source]¶ The of an Cholesky decomposition of
A
. Returns
A CVXOPT lower triangular sparse matrix.
 Raises
ValueError – When the expression is zero.
ArithmeticError – When the expression can not be written as a squared norm, that is when the extended matrix
A
is not numerically positive semidefinite.

property
Q
¶ The coefficient matrix of the expression, condensed.
This equals the of the quadratic expression but with zero rows and columns removed.
The vector
x
is a condensed version of that refers to this matrix, so thatq.x.T*q.Q*q.x
equals the quadratic part of the expressionq
. Raises
ValueError – When the quadratic part is zero.

property
fullroot
[source]¶ Affine expression whose squared norm equals the expression.
For a convex quadratic expression
q
, this is equal to the vectorq.M.T*q.y
with zero rows removed. Construction
For a quadratic expression with positive semidefinite, let be a Cholesky decomposition. Let further . Then,
Note that removing zero rows from does not affect the norm.
 Raises
ValueError – When the expression is zero.
ArithmeticError – When the expression is not convex, that is when the quadratic part is not numerically positive semidefinite.

property
is0
¶ Whether the quadratic expression is zero.

property
is_squared_norm
¶ Whether the expression can be written as a squared norm.
If this is
True
, then the there is a coefficient vector such thatIf the expression is also nonzero, then
fullroot
is with zero entries removed.

property
quadratic_forms
¶ The quadratic forms as a map from variable pairs to sparse matrices.
Warning
Do not modify the returned matrices.
Deprecated since version 2.2: This property will be removed in a future release.

property
quadroot
[source]¶ Affine expression whose squared norm equals .
For a convex quadratic expression
q
, this is equal to the vectorq.L.T*q.x
with zero rows removed. Construction
Let be the quadratic part of the expression with positive semidefinite and a Cholesky decomposition. Then,
Note that removing zero rows from does not affect the norm.
 Raises
ValueError – When the quadratic part is zero.
ArithmeticError – When the expression is not convex, that is when the quadratic part is not numerically positive semidefinite.

property
rank
¶ The length of the vector
quadroot
.Up to numerical considerations, this is the rank of the (convex) quadratic coefficient matrix of the expression.
 Raises
ArithmeticError – When the expression is not convex, that is when the quadratic part is not numerically positive semidefinite.

property
scalar_factors
¶ Decomposition into scalar real affine expressions.
If the expression is known to be equal to for scalar real affine expressions and , this is the pair
(a, b)
. Otherwise, this isNone
.Note that if , then also
a is b
in the returned tuple.

property
x
¶ The stacked variable vector of the expression, condensed.
This equals the of the quadratic expression but entries corresponding to zero rows and columns in
Q
are removed, so thatq.x.T*q.Q*q.x
equals the part of the expressionq
. Raises
ValueError – When the quadratic part is zero.

property
y
¶ See
A
. Raises
ValueError – When the expression is zero.

Objects

picos.expressions.exp_quadratic.
PSD_PERTURBATIONS
¶ Maximum number of singular quadratic form perturbations.
PICOS uses NumPy either or CHOLMOD to compute a Cholesky decomposition of a positive semidefinite quadratic form . Both libraries require to be nonsingular, which is not a requirement on PICOS’ end. If either library rejects , then PICOS provides a sequence of
PSD_PERTURBATIONS
perturbed quadratic forms for increasing until the perturbed matrix is found positive definite or until the largest was tested unsuccessfully.If this is zero, PICOS will only decompose quadratic forms that are nonsingular. If this is one, then only the largest epsilon is tested.
 Default value
3