Let x
be the vector of n variables defined with: x = M.addMVar(shape = n, vtype = GRB.BINARY, name = "x")
. Let A
be an n by n matrix. Let v
be an n by 1 constant vector that consists of positive integers. The constraint that I am interested in:
np.multiply(v, x) <= A @ x
However, when I add this constraint in gurobi:
M.addConstr(np.multiply(v, x) <= A @ x, name = "c1")
It gives errors:
File "src/gurobipy/model.pxi", line 3325, in gurobipy.Model.addConstr
File "src/gurobipy/model.pxi", line 3586, in gurobipy.Model.addMConstr
TypeError: must be real number, not MLinExpr
Any idea why this happening? I have been working on a solution for hours. My current guess is that Gurobi is not happy with variables occurring on both sides of the inequality. However, I haven't figured out a workaround.