Multiply scalar array with two-dimensional Mvar? (GurobiError: Variable is not a 1D MVar object)
AnsweredHi. I am trying to improve my runtime by using Mvar instead of scalar variabes. I have a descision variable with a second dimension (time), but constraint coefficients which are time-independent, so my constraint looks like:
model = gp.Model()
A = np.random.rand(len(N)) #(N coefficients)
b = np.random.rand(len(T)) #(T timesteps)
X = model.addMVar((len(N),len(T)))
model.addConstr(A@X == b)
However, I do get an error: GurobiError: Variable is not a 1D MVar object.
The product A@X works when X is a parameter but not a variable,
so it seems like gurobi does not support this multiplication for variables? Is there another way perhaps?
0
-
Hi Olaf,
I think the Knowledge Base article How do I multiply an array and a 2-D MVar object using the matrix-friendly Python API? should answer your question.
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
1 comment