I used to frequently iterate over the keys of a variable to get the nonzero values. Now I get an error with that code. I am using 0.18.4
julia> x = m[:x]
0 <= x[j,p,t] <= .. for all j in {FMP 01,FMP 03,..,TAM 05R,FMP 01R}, p in {1DAR,1NAR,..,TRI,TRIA}, t in {1,2,..,59,60}
julia> for k in keys(x)
println(k)
end
x[FMP 01,1DAR,1]
ERROR: UndefVarError: next not defined
Stacktrace:
[1] __next(::JuMP.JuMPArray{Variable,3,Tuple{Array{String,1},Array{String,1},Array{Int64,1}}}, ::Int64) at C:\Users\bbr
unaud\.julia\packages\JuMP\PbnIJ\src\JuMPContainer.jl:346
[2] iterate(::JuMP.KeyIterator{JuMP.JuMPArray{Variable,3,Tuple{Array{String,1},Array{String,1},Array{Int64,1}}}}, ::Int
64) at C:\Users\bbrunaud\.julia\packages\JuMP\PbnIJ\src\JuMPContainer.jl:355
[3] top-level scope at .\REPL[2]:2 [inlined]
[4] top-level scope at .\none:0
julia> collect(keys(x))
ERROR: UndefVarError: next not defined
Stacktrace:
[1] __next(::JuMP.JuMPArray{Variable,3,Tuple{Array{String,1},Array{String,1},Array{Int64,1}}}, ::Int64) at C:\Users\bbr
unaud\.julia\packages\JuMP\PbnIJ\src\JuMPContainer.jl:346
[2] iterate(::JuMP.KeyIterator{JuMP.JuMPArray{Variable,3,Tuple{Array{String,1},Array{String,1},Array{Int64,1}}}}, ::Int
64) at C:\Users\bbrunaud\.julia\packages\JuMP\PbnIJ\src\JuMPContainer.jl:355
[3] copyto!(::Array{Any,1}, ::JuMP.KeyIterator{JuMP.JuMPArray{Variable,3,Tuple{Array{String,1},Array{String,1},Array{In
t64,1}}}}) at .\abstractarray.jl:672
[4] _collect at .\array.jl:550 [inlined]
[5] collect(::JuMP.KeyIterator{JuMP.JuMPArray{Variable,3,Tuple{Array{String,1},Array{String,1},Array{Int64,1}}}}) at .\
array.jl:544
[6] top-level scope at none:0
Can you test on 0.18.6 to see if it still broken?
Some update about this issue ? I got the same problem when I have tried to use:
for key in (sort!(collect(keys(var))))
That’s really bad for me because my whole set of variables is multi-index (like, [“id”,“region”,“city”] and it’s very important to me be able to sweep the index in many parts of my code.
I have to use Clp Solver, so the JuMP version I have been using is 0.9.0.
This is fixed in JuMP 0.19 onwards. Can you update?
Thanks for your return, but I cannot update because Clp is not compatible with new versions of JuMP.
I have found another way to iterate over the index, for someone is interested : https://discourse.julialang.org/t/jump-filtering-the-output-of-jump-value-x/25391/2
Clp is not compatible yet to JuMP v0.20 but it is compatible with JuMP v0.19
Closing as out-dated. We won't be fixing this in 0.18, and it is fixed in JuMP 0.21.