Skip to main content

KeyError: 'Missing constraint index'

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    Gurobi Staff Gurobi Staff
    This post is more than three 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 why not try our AI Gurobot?.
  • Eli Towle
    Gurobi Staff Gurobi Staff

    I see two issues:

    • Model.addConstrs() is used for adding multiple constraints to a model with a single method call. It looks like you only want to add a single constraint with your third line of code. If this is the case, use Model.addConstr() instead.
    • \( \texttt{gp.quicksum(x[0, j] for j in AllNodes if j != 0)} \) is not a complete constraint. I would guess you want to set this expression equal to the number of vehicles.

    I hope this helps!

    0
  • Kaiyu Wei
    Gurobi-versary
    First Question
    First Comment

    Eli Towle Dear Eli, Thank you, it works!

    0

Post is closed for comments.