"BoundError: attempt to access JuMP containers" when creating a constraint

Hi, I’m trying to create a constraint like specified below, but have this error: “ERROR: BoundsError: attempt to access JuMP.Containers.SparseAxisArray{VariableRef, 3, Tuple{Int64, Int64, Bool}} with 44 entries at index”.
I can’t find the formulation error. Could anybody help me to fix it?
Thanks in advance

Vstation = collect(12:15)
Vcustomer = collect(2:11)
V0_customer = collect(1:11)
Vtotal = collect(1:15)
Q = 10000
@variable(model1, 0 <= q_in_st[i in V0_customer, h in Vstation] <=Q)
@variable(model1, 0 <= q[i in Vtotal, j in Vtotal] <=Q)

@constraint(model1, con5[f in Vcustomer, j in Vstation], q_in_st[f,j] <= sum(q[i,j] for i in V0_customer if i != j))

Your code runs on my machine (provided I add using JuMP and model1 = Model(), don’t forget to make your examples as reproducible as possible for people who want to help :wink:). Did you try in a fresh Julia session?


Thanks! After a restart my machine it worked. I think it was a bug.

1 Like