Skip to main content

addConstrs behaviour

Answered

Comments

1 comment

  • Maliheh Aramon
    Gurobi Staff 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

Please sign in to leave a comment.