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