TypeError: 'gurobipy.LinExpr' object is not iterable
回答済みmdl.addConstrs(((x[0,2]+x[0,3]) <= (max(x[0,2]+x[0,3]))), name='22')
Why is the error occuring?
1
-
正式なコメント
This post is more than three 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. -
I am not sure what you are trying to model with your constraint. Currently, your constraint reads
\[\begin{align*}
x_{0,2} + x_{0,3} \leq \max(x_{0,2} + x_{0,3})
\end{align*}\]which is redundant. If you are trying to implement
\[\begin{align*}
x_{0,2} + x_{0,3} \leq \max(x_{0,2},x_{0,3}, \dots)
\end{align*}\]then you have to us the addGenConstrMax method.
Note that this method only accepts single variables. It does not accept linear or quadratic expressions. Thus, if you want to take the \(\max\) of a more complex term, you have to introduce auxiliary variables and equality constraints.
Best regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
2件のコメント