'Why does the index error appear in this problem?

I am running an integer programming model in Python using the gurobi solver. With the code, it gives me an index error like the following.

model.constraintarrivaltime1 = pe.ConstraintList() 
for k in model.K:
    for r in model.R:
        expression = model.v[k,r] == model.v[k,r-1]+ sum(model.x[i,j,k,r]*t[i,j] for i in model.N for j in model.N)
        model.constraintarrivaltime1.add(expression)

Error : KeyError: "Index '(1, 0)' is not valid for indexed component 'v'"



Solution 1:[1]

Don't know the model but it appears to expect 2 parameters k and r while (1,0) would just be one parameter even though the tuple consists of two value. So maybe store it in two variables or use *(0,1).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 haxor789