Skip to main content

TypeError: 'gurobipy.LinExpr' object is not iterable

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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.
  • Jaromił Najman
    • Gurobi Staff

    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

Post is closed for comments.