Unverified Commit dba54c58 authored by St. Elmo's avatar St. Elmo
Browse files

fixed all functions

parent 98186aad
......@@ -8,9 +8,7 @@ Arguments are passed to [`flux_balance_analysis`](@ref).
"""
function flux_balance_analysis_vec(args...; kwargs...)::Union{Vector{Float64},Nothing}
optmodel = flux_balance_analysis(args...; kwargs...)
COBREXA.JuMP.termination_status(optmodel) in [MOI.OPTIMAL, MOI.LOCALLY_SOLVED] ||
return nothing
is_solved(optmodel) || return nothing
value.(optmodel[:x])
end
......
......@@ -141,13 +141,13 @@ Internal helper for creating the optimized model on a remote worker, for
avoiding namespace problems.
"""
function _FVA_optimize_reaction(model, rid, ret)
sense = rid > 0 ? MOI.MAX_SENSE : MOI.MIN_SENSE
sense = rid > 0 ? MAX : MIN
var = all_variables(model)[abs(rid)]
@objective(model, sense, var)
optimize!(model)
if termination_status(model) in [MOI.OPTIMAL, MOI.LOCALLY_SOLVED]
if is_solved(model)
return ret(model)
else
return nothing
......
......@@ -41,8 +41,7 @@ function parsimonious_flux_balance_analysis(
)
# Run FBA
opt_model = flux_balance_analysis(model, optimizer; modifications = modifications)
COBREXA.JuMP.termination_status(opt_model) in [MOI.OPTIMAL, MOI.LOCALLY_SOLVED] ||
return nothing # FBA failed
is_solved(opt_model) || return nothing # FBA failed
# get the objective
Z = objective_value(opt_model)
......@@ -63,15 +62,13 @@ function parsimonious_flux_balance_analysis(
@constraint(opt_model, pfba_constraint, lb <= original_objective <= ub)
optimize!(opt_model)
COBREXA.JuMP.termination_status(opt_model) in [MOI.OPTIMAL, MOI.LOCALLY_SOLVED] &&
break
is_solved(opt_model) && break
COBREXA.JuMP.delete(opt_model, pfba_constraint)
COBREXA.JuMP.unregister(opt_model, :pfba_constraint)
end
COBREXA.JuMP.termination_status(opt_model) in [MOI.OPTIMAL, MOI.LOCALLY_SOLVED] ||
return nothing # pFBA failed
is_solved(opt_model) || return nothing # pFBA failed
return opt_model
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment