JuMP error constraint forming KeyError:

A bit messy explanation, but I hope it helps. Something is wrong with the indicators in the loops. For instance for t=6 and r=3, we get t-r+1=4. The matrix Q_pwjtk does not have anything in the position [5, 4, 1, 1, 1], i.e. Q_pwjtk[5, 4, 1, 1, 1] does not exist (the second indicator is missing). This is because when you create your variable @variable(mod2,Q_pwjtk[p in 1:P, w in 1:Lf_p[p], j in 1:J , t in 1:T, k in 1:K],Int) then for p=P, you have w in 1:Lf_p[p] and Lf_p[P]=3 so you cannot then have Q_pwjtk[5,4,1,1,1].

2 Likes