Skip to main content

## Comments

1 comment

• Gurobi Staff

The syntax you are using is very reasonable, but unfortunately the expression y*y, which I would interpret as a quadratic expression of shape (5,), is not yet supported by gurobipy (all quadratic expressions must evaluate to a scalar). Extending this initial step towards a matrix friendly API taken in version 9.0 to include more general expressions is on the roadmap.

For now you can resort to the scalar level in your example, i.e.,

import gurobipy as gpimport numpy as npm = gp.Model("model")x = m.addMVar(shape=(10), name="x")y = m.addMVar(shape=(5), name="y")A = np.random.rand(5, 10)m.addConstrs((A[i,:] @ x - (y[i]@y[i]) <= A[i,0] for i in range(5)),name="const")m.setObjective(x.sum() - y @ y, gp.GRB.MAXIMIZE)

It's a bit more cumbersome but it should work.

Please sign in to leave a comment.