Skip to main content

KeyError, Attribute Error.

Answered

Comments

1 comment

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

Please sign in to leave a comment.