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

variable in Gurobi

回答済み

コメント

1件のコメント

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

サインインしてコメントを残してください。