TypeError: float() argument must be a string or a real number, not 'gurobipy.LinExpr'
Awaiting user inputHello, I am trying to add constraints but encounter an error that I couldn't figure out how to get around.
m.addConstrs((T @ f_a + M_a * (1  z_hat[k]) >= eta.loc[k, :].values for k in K))
In my code, T is a numpy.ndarray (elements are 0 or 1 constants), f_a is a gurobi MVar object, M_a is a numpy.ndarry (elements are constants), and z_hat[k] is a gurobi variable. I can see the error comes from adding the T @ f_a and the M_a * (1  z_hat[k]) together. Running T @ f_a and M_a * (1  z_hat[k]) separately did not produce an error. It only appears when adding them together.
TypeError: float() argument must be a string or a real number, not 'gurobipy.LinExpr'
Thanks for the help.
0

Have you tried making \(\texttt{z_hat}\) also an MVar?
Cheers,
David0
Please sign in to leave a comment.
Comments
1 comment