TypeError: float() argument must be a string or a real number, not 'gurobipy.LinExpr'
ユーザーの入力を待っています。Hello, 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
-
正式なコメント
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Have you tried making \(\texttt{z_hat}\) also an MVar?
Cheers,
David0
投稿コメントは受け付けていません。
コメント
2件のコメント