MOSEK 10.2 introduces a feature that we hope will be interesting for all users of our Python Fusion API, which we call Pythonic Fusion.
Pythonic Fusion is an overlay on top of the current Fusion API (or, as some would call it, syntactic sugar) which implements standard Python operators for Fusion objects (variables, parameters, expressions). There are operators for manipulating linear expressions:
+, -, *, @, [:], .T
relational operators for introducing constraints:
==, <=, >=
and operators for introducing AND- and OR-clauses in disjunctive constraints:
&, |
The operators are used in the most natural way familiar from NumPy, CVXPY, Pandas or any other data processing tool in Python, so we restrict to giving a simple example. The following Python Fusion constraint
M.constraint(Expr.mul(G, Expr.sub(x.transpose(), y.slice(0, n))), Domain.lessThan(c))
will be written in Pythonic Fusion as
M.constraint(G @ (x.T - y[:n]) <= c)
A more comprehensive introduction to the new syntax can be found in the manual. Examples using Pythonic Fusion are scattered throughout the manual, in particular in the portfolio optimization case study, and with time we will adapt our other Python Fusion resources to the new syntax. You are welcome to share your suggestions, comments or bug reports with us.
Important. In MOSEK 10.2 Pythonic Fusion is a separate add-on, available only after importing:
import mosek.fusion.pythonic