I think I’ve found a small bug in JuMP (or NamedArrays) when setting bounds using a NamedArray
S = [:a,:b]
X = NamedArray([1, 2],S)
m = Model()
DimensionMismatch: arrays could not be broadcast to a common size; got a dimension with lengths 2 and 2
Both of the following commands work as expected
I’m not sure if the issue is with JuMP or NamedArrays.
I’ve realized this can be expressed more simply as
L = NamedArray([1,2,3],[:a,:b,:c])
X = JuMP.Containers.DenseAxisArray([1,2,3],[:a,:b,:c])
X .≈ L
This produces the same error for the same reasons.
This is a problem with the way that Julia packages compose. In this case, there are no methods to coordinate JuMP’s
One approach might be a package extension, like we recently merged for
DimensionalData: Add DimensionalData extension by odow · Pull Request #3413 · jump-dev/JuMP.jl · GitHub. See the much larger backstory at [Containers] support ArrayInterface.jl traits · Issue #3214 · jump-dev/JuMP.jl · GitHub.
NamedArray in the first place? Why not just something like
X = Containers.DenseAxisArray([1, 2], S).
That makes sense. And I’ve wanted to experiment with package extensions.
One reason for named arrays vs dense axis arrays is, at least to my knowledge, you can’t mask a dense axis arrays. In your example I don’t believe
I’m on a phone so apologies if things format poorly or that example does actually work.