Skip to main content

KeyError ( 0 0 0)

Answered

Comments

3 comments

  • Official comment
    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.
  • 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

Post is closed for comments.