# JuMP: Error while fixing variable defined as DenseAxisArray using map function

I came across this error when trying to fix a variable defined as `DenseAxisArray`. For example:

``````using JuMP
m=Model()
@variable(m, x[0:2,1:3] >=0)
map(y->fix(y,0.0; force=true), x[0, :])
``````

This gives an error:

`````` MethodError: similar(::JuMP.Containers.DenseAxisArray{VariableRef, 1, Tuple{Base.OneTo{Int64}}, Tuple{JuMP.Containers._AxisLookup{Base.OneTo{Int64}}}}, ::Type{Nothing}, ::Tuple{Base.OneTo{Int64}}) is ambiguous.
``````

I am pretty sure it is because I start the first dimension’s indexing from 0 (it works perfectly if the variable `x` is defined as `@variable(m, x[1:3,1:3]`). However, to increase readability, I would like to keep the definition as `@variable(m, x[0:2,1:3]`. So, is there an alternative way of fixing the variables `x[0, :]` (similar to using map function) apart from using a `for` loop to do so?

Thanks!

Note: @odow’s broadcasting solution works equally well. The existing bug will be fixed by @blegat’s PR.

Thanks for reporting this bug, it should be fixed by Fix map for DenseAxisArray with OneTo axes by blegat · Pull Request #2621 · jump-dev/JuMP.jl · GitHub

4 Likes

Great! Thanks.

``````fix.(x[0, :], 0.0; force = true)