# BoundsError: attempt to access 0-element Array{JuMP.Variable,1} at index \[1\]

**URL:** <https://discourse.julialang.org/t/boundserror-attempt-to-access-0-element-array-jump-variable-1-at-index-1/32683>\
**Category:** General Usage\
**Created:** [December 25, 2019, 7:30am UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-0-element-array-jump-variable-1-at-index-1/32683 "2019-12-25T07:30:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marouane1994](https://avatars.discourse-cdn.com/v4/letter/m/74df32/32.png) [@marouane1994](https://discourse.julialang.org/u/marouane1994)\
**Post date:** [December 25, 2019, 7:30am UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-0-element-array-jump-variable-1-at-index-1/32683/1 "2019-12-25T07:30:24Z")

</div>

i have this function:

```julia
function prob(na)
		    
		    b = T0*na
		    setc(-b)
		    total = 0.0
		    for x in Channel(scan)
		        nab = vi2*x + b #the photon numbers for each item in the sum in the note (10)
		        total += prod([c.^complex(n)/factorial(n) for (c, n) in zip(coef, nab)])
		    end
		    return abs2.(total*omega)
		end

```

where `na` is an integer ,`scan` is a function with a `Channel` as an argument → `scan(c::Channel)` and `setc(b)`is a function and it is written as follows:

```julia
function setc(c)
        for i = 1:size(A, 1)
            m.linconstr[i].lb = float(c[i]) #lb is the lower bound of a variable `x`
        end
    end

```

A is a non square matrix and `lb` is a lower bound of a variable `x` that has this following constraint:

```julia
function scan_maker(A)
    m = JuMP.Model(solver=ClpSolver(PrimalTolerance=1e-3, DualTolerance=1e-3, InfeasibleReturn=1, PresolveType=1))
    # m = Model(solver=GurobiSolver())
    level = size(A, 2)
    v = zeros(Int, level)
    ub = zeros(Int, level)
    lb = zeros(Int, level)

    @variable(m, x[1:level])
    @constraint(m, con, A*x.>=0)

```

now everytime i run the `prob` function i get this error:  
`BoundsError: attempt to access 0-element Array{JuMP.Variable,1} at index [1]`, apparently and according to the stacktrace the error raises in the level of the `for` loop: `for x in Channel(scan)` but i don’t know why is there something wrong with the channel i would like to post the `scan` function too but it is kinda long, could it be the JuMP version that i’m using ? any ideas how to fix the problem?
