BatyLeo
September 1, 2022, 5:12pm
1
Hello, a bug appeared in my package when I updated JuMP to v1.2.1 from v1.1.1.
Here is a minimum (non) working example:
using GLPK
using JuMP
paths = [
[1, 2, 15, 3, 20],
[1, 9, 16, 20],
[1, 2, 20]
]
model = Model(GLPK.Optimizer)
@variable(model, y[p in paths], Bin)
@objective(
model,
Min,
sum(y[p] for p in paths)
)
The variable definition works, but the expression sum(y[p] for p in paths)
raises a KeyError: key 1 not found
, which was not the case before.
Did I miss something ?
1 Like
odow
September 1, 2022, 6:54pm
2
1 Like
odow
September 1, 2022, 8:24pm
3
I have a fix: [Containers] fix DenseAxisArray with Vector key by odow · Pull Request #3064 · jump-dev/JuMP.jl · GitHub
It might take a bit to get a new release, but you can fix your code by adding this function to your script, just after using JuMP
. Once we update JuMP, you can remove it.
function Base.getindex(
x::JuMP.Containers._AxisLookup{Dict{K,Int}},
key::K,
) where {K<:AbstractVector}
return x.data[key]
end
1 Like
BatyLeo
September 2, 2022, 6:37am
4
Thanks for the quick answer, your workaround works perfectly !
1 Like
odow
September 4, 2022, 11:47pm
5
Just to follow up: JuMP v1.3.0 has been released with a fix for this bug.
1 Like