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

format and remove Gurobi

parent 0128a96b
......@@ -12,7 +12,6 @@ DistributedData = "f6a0035f-c5ac-4ad0-b410-ad102ced35df"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
......
......@@ -141,7 +141,7 @@ fva_max, fva_min = fva(model, biomass, optimizer; solver_attributes=atts)
function flux_variability_analysis(
model::StandardModel,
optimizer;
optimum_bound = 1.0-DEFAULT_FVA_TOL,
optimum_bound = 1.0 - DEFAULT_FVA_TOL,
modifications = [(model, opt_model) -> nothing],
)
# Run FBA
......@@ -157,14 +157,12 @@ function flux_variability_analysis(
v = opt_model[:x]
λ = COBREXA.JuMP.objective_value(opt_model) # objective value
λmin = min(optimum_bound*λ, λ * 1.0 / optimum_bound)
λmax = max(optimum_bound*λ, λ * 1.0 / optimum_bound)
λmin = min(optimum_bound * λ, λ * 1.0 / optimum_bound)
λmax = max(optimum_bound * λ, λ * 1.0 / optimum_bound)
COBREXA.JuMP.@constraint(
opt_model,
λmin <=
COBREXA.JuMP.objective_function(opt_model) <=
λmax # in case there is a negative bound
λmin <= COBREXA.JuMP.objective_function(opt_model) <= λmax # in case there is a negative bound
)
for i = 1:length(v)
......@@ -176,7 +174,7 @@ function flux_variability_analysis(
)
if status
fva_max[model.reactions[i].id] =
Dict(zip(reactions(model), value.(opt_model[:x]) ))
Dict(zip(reactions(model), value.(opt_model[:x])))
else
@warn "Error maximizing index: $i with error $(termination_status(opt_model))"
fva_max[model.reactions[i].id] = nothing
......@@ -190,7 +188,7 @@ function flux_variability_analysis(
)
if status
fva_min[model.reactions[i].id] =
Dict(zip(reactions(model), value.(opt_model[:x]) ))
Dict(zip(reactions(model), value.(opt_model[:x])))
else
@warn "Error minimizing index: $i with error $(termination_status(opt_model))"
fva_min[model.reactions[i].id] = nothing
......
......@@ -49,8 +49,8 @@ function parsimonious_flux_balance_analysis(
@objective(opt_model, Min, sum(dot(v, v)))
for lbconval in [1.0, 0.999999, 0.99999, 0.9999, 0.999, 0.99] # sequentially relax bound for stability
λmin = min(lbconval*λ, λ * 1.0 / lbconval)
λmax = max(lbconval*λ, λ * 1.0 / lbconval)
λmin = min(lbconval * λ, λ * 1.0 / lbconval)
λmax = max(lbconval * λ, λ * 1.0 / lbconval)
@constraint(
opt_model,
pfbacon,
......
......@@ -75,14 +75,14 @@ end
fva_max, fva_min = flux_variability_analysis(
model,
Tulip.Optimizer;
optimum_bound=0.99,
optimum_bound = 0.99,
modifications = [
change_solver_attribute("IPM_IterationsLimit", 500),
change_constraint(glucose, -10, -10),
change_constraint(oxygen, 0.0, 0.0),
],
)
@test isapprox(fva_max["EX_ac_e"]["EX_ac_e"], 8.518549434876208, atol = 1e-6)
@test isapprox(fva_min["EX_ac_e"]["EX_ac_e"], 7.448388738973361, atol = 1e-6)
end
Markdown is supported
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