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

KeyError ( 0 0 0)

回答済み

コメント

2件のコメント

  • Eli Towle
    • Gurobi Staff

    On line 25, you assign the Var object returned by Model.addVar() to \(\texttt{Z[i, K, t]}\):

    Z[i, K, t] = model.addVar(...)

    You should use \(\texttt{k}\) instead of \(\texttt{K}\) here.

    To simplify the code, consider using Model.addVars() to construct \(\texttt{Z}\):

    Z = model.addVars(I, K, T, vtype=gp.GRB.BINARY, name="Z")

    With this approach, \(\texttt{Z}\) is a tupledict object. The tupledict class includes helper methods to make model-building easier. For example, you could then use the tupledict.sum() method to simplify the creation of \(\texttt{result_3}\):

    result_3 = 38 * Z.sum()
    0
  • Rayan SAAD
    • Gurobi-versary
    • Investigator
    • Conversationalist

    ohh I see,

    Thanks a lot !

    0

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