i have this function:
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:
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:
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?