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

variable in Gurobi

回答済み

コメント

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.
  • Mario Ruthmair
    • Gurobi Staff

    Hi Shahrzad,

    Each call to Model.addVar() creates a variable and a corresponding handle to access it. Since you need access to the variables to build the constraints, you must organize and store your handles somehow. You can do this however you like in Python, but one approach might be to use a dictionary with the day strings as keys.

    Alternatively, Gurobi provides a so-called tupledict that organizes your variable handles. For example,

    vars = Model.addVars(days_of_week)

    would generate a dictionary with the day strings as keys and the variable handles as values.

    Best regards,
    Mario

    0

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