Skip to main content

addConstrs behaviour

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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.
  • Maliheh Aramon
    • Gurobi Staff

    Hi Zvonimir, 

    As mentioned in our documentation, the Model.addConstrs() method returns a tupledict where the constraints are indexed by the values of the generator expression. In your code, I guess the \(\texttt{lin_eqs.select("*", "*", "*")}\) is a list of Gurobi LinExpr() objects which cannot be used as keys of the tupledict. One idea to fix this is given below:

    lin_eqs_list = lin_eqs.select('*', '*', '*')
    m.addConstrs((lin_eqs_list[i] == 0 for i in range(len(lin_eqs_list))), name="qe")

    Best regards,

    Maliheh

     

    2

Post is closed for comments.