Hi,
I wanted to implement the attached constraint with below code but getting error
const Gurobix = optimizer_with_attributes(Gurobi.Optimizer,"MIPGap"=>0.0005) #"TimeLimit"=>1000
mod2 = Model(Gurobix)
Lf_p= [18 17 30 32 3];
J =6
P=5
T=6
R=6
@variable(mod2,EXI_jprt[j in 1:J, p in 1:P, r in 1:R, t in 1:T],Int)
@variable(mod2,Qs_pwjirt[p in 1:P, w in 1:Lf_p[p],j in 1:J,i in 1:I, r in 1:R, t in 1:T],Int)
@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)
for j in 1:J
for p in 1:P
for t in 1:T
for r in 1:t
@constraint(mod2,
EXI_jprt[j,p,r,t]==
sum( Q_pwjtk[p,t-r+1,j,r,k] for k in 1:K)- sum(Qs_pwjirt[p,t-r+1,j,i,r,c] for i in 1:I, c in r:t) )
end
end
end
end
getting the following error
LoadError: KeyError: key (5, 4, 1, 1, 1) not found
Stacktrace:
[1] getindex(::Dict{NTuple{5,Int64},VariableRef}, ::NTuple{5,Int64}) at .\dict.jl:477
[2] getindex(::JuMP.Containers.SparseAxisArray{VariableRef,5,NTuple{5,Int64}}, ::Int64, ::Int64, ::Int64, ::Int64, ::Vararg{Int64,N} where N) at C:\Users\manojkumar.ram\.julia\packages\JuMP\YXK4e\src\Containers\SparseAxisArray.jl:97
[3] macro expansion at C:\Users\manojkumar.ram\.julia\packages\MutableArithmetics\8xkW3\src\rewrite.jl:279 [inlined]
[4] macro expansion at C:\Users\manojkumar.ram\.julia\packages\JuMP\YXK4e\src\macros.jl:416 [inlined]
[5] top-level scope at C:\Users\manojkumar.ram\Desktop\shweta\code\test.jl:17
in expression starting at C:\Users\manojkumar.ram\Desktop\shweta\code\test.jl:13![error|443x171](upload://z5TdjetJk8IUxCxlL5SMZ4sDSJJ.jpeg)
Thanks in advance for the help