i have this piece of code for optimization:
using JuMP
using GLPK
function scan_maker(A)
m= Model(GLPK.Optimizer)
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)
function setc(a)
set_normalized_rhs.(con, float.(a))
end
function scan(c::Channel)
i = 1
init = 1
while i > 0
if i >= init
@objective(m, Max, x[i])
res = JuMP.optimize!(m)
if termination_status(m) == MOI.OPTIMAL || termination_status(m) == MOI.DUAL_INFEASIBLE
ub[i] = round(Int, getvalue(x[i]))
set_objective_sense(m, MOI.MIN_SENSE)
res = JuMP.optimize!(m)
@assert termination_status(m) == MOI.OPTIMAL || termination_status(m) == MOI.DUAL_INFEASIBLE
lb[i] = round(Int, getvalue(x[i]))
v[i] = lb[i]
init += 1
else
@assert termination_status(m) == MOI.INFEASIBLE
i -= 1
continue
end
elseif v[i] < ub[i]
v[i] += 1
else
set_upper_bound(x[i], Inf)
set_lower_bound(x[i], -Inf)
init -= 1
i -= 1
continue
end
if i >= level
put!(c, v)
continue
else
set_upper_bound(x[i], v[i])
set_lower_bound(x[i], v[i])
i += 1
end
end
close(c)
end
return setc, scan
end
the code works quite well except for the first nested function setc
when i call it it shows nothing
in the output and i don’t know with what i should change set_normalized_rhs
because when i do this :
A=[2 2;1 1;4 3]
a=[2,3,7]
b, d= scan_maker(A)
b(a)
i get this
3-element Array{Nothing,1}:
nothing
nothing
nothing