Gurobi quadratic matrix expression object. Quadratic matrix expressions are used to build quadratic objective functions and quadratic constraints. They are temporary objects that typically have short lifespans.
You generally build quadratic matrix expressions using overloaded
operators. For example, if
x is an
MVar object and
A is a 2-D
matrix (dense or sparse), then
x @ A @ x and
x @ x
are both MQuadExpr objects.
Arithmetic operations supported on
are addition, subtraction (e.g.,
expr = x @ A @ x - y @ B @ y), and multiplication by a constant
expr = 2 * x @ A @ y).
The full list of overloaded operators
on MQuadExpr objects
is as follows:
In Python parlance, we've defined the following
Note that the Python matrix multiplication operator (
introduced in Python version 3.5; it isn't available from Python 2.7.
Note that quadratic matrix expressions always have shape
You can add linear terms into a quadratic matrix expression, but they
must also have shape