メインコンテンツへスキップ

addConstrs behaviour

回答済み

コメント

2件のコメント

  • 正式なコメント
    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

投稿コメントは受け付けていません。