Skip to main content

KeyError, Attribute Error.

Answered

Comments

2 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.
  • Simranjit Kaur
    • Gurobi Staff

    Hi Myat,

    The error  "KeyError: 'Missing constraint index'" occurs when you try to add a single constraint using the method Model.addConstrs().

    Please use Model.addConstr() instead of using Model.addConstrs() to add the single indicator constraint in the following calls in your code

    m.addConstr((u[i,t] == 0) >> (p_ch[i,t] == 0))
    m.addConstr((u[i, t] == 1) >> (p_dch[i, t] == 0))

    Regards,

    Simran

    1

Post is closed for comments.