addConstrs for X @ Q @ X
Hi,
I am using python 3.9
G is a sparse diagonal matrix.
Z = m.addMVar((nS,nT), vtype="C", name="Z", lb=-inf, ub=inf)
Err = m.addMVar(nT, vtype="C", name="Err", lb=0, ub=inf)
m.addConstrs((Err[t] == Z[:, t] @ G @ Z[:, t] for t in range(0, nT)),
name="cErr")
I have no problem adding this constrain and solving the problem on my laptop with gurobi 9.1.2.
However, when I switch to my PC with gurobi 9.5, I cannot add this constraint. The error shows:
GurobiError: Unsupported type (<class 'gurobipy.MQuadExpr'>) for LinExpr addition argument.
I think it is because the indexing change in the new release is shown in the Indexing of MVar and MConstr objects section of the Detailed Release Notes for Gurobi 9.5.
However, I still don't know how to translate the above constraint to fit the new version of the gurobipy API.
Thank you in advance.
-
I found myself adding the constraint in a very basic way
m.addConstrs((Err[t] == sum(Z[s, t] * Z[s, t] * g for s in range(nS)) for t in range(0, nT)),
name="cErr")If there is a smarter way to add such a constraint, please let me know.
0
Please sign in to leave a comment.
Comments
1 comment