CVXMOD – Set relations

Alert!

CVXMOD is discontinued!

Unfortunately CVXMOD has not been developed since 2008. It is incomplete, somewhat buggy and not supported. Please instead try the replacement package CVXPY. Or, try CVXOPT if you are prepared to work at a lower level, CVX if you are ok with Matlab, or CVXGEN if you want small (but super high speed) QP solvers.

A set relation (set membership relation) is constructed with the ‘pseudo-operator’ |In|. The most common use for set relations is to restrict optvars to sets.

Syntax

expr |In| cvxmodset

There are several sets available.

  • norm2ball(n) is the n-dimensional Euclidean unit ball.

  • norminfball(n) is the n-dimensional unit box.

  • norm1ball(n, radius=1) is the n-dimensional norm-1 ball.

  • probsimp(n) is the n-dimensional probability simplex.

  • posorth(n) is the n-dimensional positive orthant.

  • negorth(n) is the n-dimensional negative orthant.

  • reals(n) is the set of all n-dimensional reals.

  • psdcone(n) is the ntimesn positive semidefinite cone.

  • nsdcone(n) is the ntimesn negative semidefinite cone.

Sets may be added to problems as constraints.

The logical value of set relations can be tested using value(srel). Set relations can also be analyzed for their convex properties.

  • isaffine(srel) returns True if srel is known to restrict optvars to a polyhedron.

  • isconvex(srel) returns True if srel is known to restrict optvars to a convex set.

  • classify(srel) prints a summary of the properties of srel.

Set membership
>>> x = optvar('x', 3)
>>> x |In| norm2ball(3)
<set relation x |In| norm2ball(3); optvars: x>
Only a pseudo-operator

It is not possible to create new operators in Python. Thus the |In| pseudo-operator is a workaround to make set membership statements relatively natural. When you use expr |In| set, you are in fact forming (expr | In) | set, where In is a special pseudo-operator and | is the standard ‘or’ operation in Python.