TypeError: 'gurobipy.LinExpr' object is not iterable
Answeredmdl.addConstrs(((x[0,2]+x[0,3]) <= (max(x[0,2]+x[0,3]))), name='22')
Why is the error occuring?
1
-
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
Please sign in to leave a comment.
Comments
1 comment