Implements QuadraticExpression.

Classes

A scalar quadratic expression of the form .

__init__(string, quadraticPart={}, affinePart=<1×1 Real Constant: 0>, scalarFactors=None, copyDecomposition=None)[source]

This constructor is meant for internal use. As a user, you will most likely want to build expressions starting from variables or a Constant.

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 real vectorizations 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.

property A

An affine-augmented 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 that q.y.T*q.A*q.y equals the expression q.

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
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 that q.x.T*q.Q*q.x equals the quadratic part of the expression q.

Raises

ValueError – When the quadratic part is zero.

property aff[source]

Affine part of the quadratic expression.

property cst[source]

Constant part of the quadratic expression.

property fullroot[source]

Affine expression whose squared norm equals the expression.

For a convex quadratic expression q, this is equal to the vector q.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 that If the expression is also nonzero, then fullroot is with zero entries removed.

property lin[source]

Linear part of the quadratic expression.

The number of terms in the simplified quadratic form.

Quadratic part of the quadratic expression.

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.

Affine expression whose squared norm equals .

For a convex quadratic expression q, this is equal to the vector q.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 is None.

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 that q.x.T*q.Q*q.x equals the part of the expression q.

Raises

ValueError – When the quadratic part is zero.

property y

See A.

Raises

ValueError – When the expression is zero.

Objects

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.
3