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). ...@@ -8,9 +8,7 @@ Arguments are passed to [`flux_balance_analysis`](@ref).
""" """
function flux_balance_analysis_vec(args...; kwargs...)::Union{Vector{Float64},Nothing} function flux_balance_analysis_vec(args...; kwargs...)::Union{Vector{Float64},Nothing}
optmodel = flux_balance_analysis(args...; kwargs...) optmodel = flux_balance_analysis(args...; kwargs...)
is_solved(optmodel) || return nothing
COBREXA.JuMP.termination_status(optmodel) in [MOI.OPTIMAL, MOI.LOCALLY_SOLVED] ||
return nothing
value.(optmodel[:x]) value.(optmodel[:x])
end end
......
...@@ -141,13 +141,13 @@ Internal helper for creating the optimized model on a remote worker, for ...@@ -141,13 +141,13 @@ Internal helper for creating the optimized model on a remote worker, for
avoiding namespace problems. avoiding namespace problems.
""" """
function _FVA_optimize_reaction(model, rid, ret) 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)] var = all_variables(model)[abs(rid)]
@objective(model, sense, var) @objective(model, sense, var)
optimize!(model) optimize!(model)
if termination_status(model) in [MOI.OPTIMAL, MOI.LOCALLY_SOLVED] if is_solved(model)
return ret(model) return ret(model)
else else
return nothing return nothing
......
...@@ -41,8 +41,7 @@ function parsimonious_flux_balance_analysis( ...@@ -41,8 +41,7 @@ function parsimonious_flux_balance_analysis(
) )
# Run FBA # Run FBA
opt_model = flux_balance_analysis(model, optimizer; modifications = modifications) opt_model = flux_balance_analysis(model, optimizer; modifications = modifications)
COBREXA.JuMP.termination_status(opt_model) in [MOI.OPTIMAL, MOI.LOCALLY_SOLVED] || is_solved(opt_model) || return nothing # FBA failed
return nothing # FBA failed
# get the objective # get the objective
Z = objective_value(opt_model) Z = objective_value(opt_model)
...@@ -63,15 +62,13 @@ function parsimonious_flux_balance_analysis( ...@@ -63,15 +62,13 @@ function parsimonious_flux_balance_analysis(
@constraint(opt_model, pfba_constraint, lb <= original_objective <= ub) @constraint(opt_model, pfba_constraint, lb <= original_objective <= ub)
optimize!(opt_model) optimize!(opt_model)
COBREXA.JuMP.termination_status(opt_model) in [MOI.OPTIMAL, MOI.LOCALLY_SOLVED] && is_solved(opt_model) && break
break
COBREXA.JuMP.delete(opt_model, pfba_constraint) COBREXA.JuMP.delete(opt_model, pfba_constraint)
COBREXA.JuMP.unregister(opt_model, :pfba_constraint) COBREXA.JuMP.unregister(opt_model, :pfba_constraint)
end end
COBREXA.JuMP.termination_status(opt_model) in [MOI.OPTIMAL, MOI.LOCALLY_SOLVED] || is_solved(opt_model) || return nothing # pFBA failed
return nothing # pFBA failed
return opt_model return opt_model
end 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