CVXMOD – Set relations

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.