Skip to main content

KeyError: 'Missing constraint index'

Answered

Comments

2 comments

  • 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

Please sign in to leave a comment.