Verified Commit 6e6b1097 authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

use pkg relativity

parent c39c4a69
...@@ -8,12 +8,12 @@ using JuMP ...@@ -8,12 +8,12 @@ using JuMP
using MAT using MAT
using Distributed using Distributed
using DistributedData using DistributedData
using Downloads
using Requires using Requires
using JSON using JSON
using Measurements using Measurements
using Statistics using Statistics
using Random using Random
using PyCall
using Tulip # for LPs using Tulip # for LPs
using OSQP # for QPs, but it kinda sucks using OSQP # for QPs, but it kinda sucks
......
...@@ -38,7 +38,7 @@ function flux_variability_analysis( ...@@ -38,7 +38,7 @@ function flux_variability_analysis(
end end
(optimization_model, x0) = flux_balance_analysis(model, optimizer) (optimization_model, x0) = flux_balance_analysis(model, optimizer)
Z0 = JuMP.objective_value(optimization_model) Z0 = COBREXA.JuMP.objective_value(optimization_model)
optimization_model = nothing # we won't need this one anymore, so free the memory optimization_model = nothing # we won't need this one anymore, so free the memory
# store a JuMP optimization model at all workers # store a JuMP optimization model at all workers
...@@ -91,7 +91,7 @@ Internal helper function for adding constraints to a model. Exists mainly ...@@ -91,7 +91,7 @@ Internal helper function for adding constraints to a model. Exists mainly
because for avoiding namespace problems on remote workers. because for avoiding namespace problems on remote workers.
""" """
function _FVA_add_constraint(model, c, x, Z0, gamma) function _FVA_add_constraint(model, c, x, Z0, gamma)
JuMP.@constraint(model, c' * x gamma * Z0) COBREXA.JuMP.@constraint(model, c' * x gamma * Z0)
end end
""" """
...@@ -102,11 +102,11 @@ namespace problems. ...@@ -102,11 +102,11 @@ namespace problems.
""" """
function _FVA_optimize_reaction(model, rid) function _FVA_optimize_reaction(model, rid)
sense = rid > 0 ? MOI.MAX_SENSE : MOI.MIN_SENSE sense = rid > 0 ? MOI.MAX_SENSE : MOI.MIN_SENSE
var = JuMP.all_variables(model)[abs(rid)] var = COBREXA.JuMP.all_variables(model)[abs(rid)]
JuMP.@objective(model, sense, var) COBREXA.JuMP.@objective(model, sense, var)
JuMP.optimize!(model) COBREXA.JuMP.optimize!(model)
return JuMP.objective_value(model) return COBREXA.JuMP.objective_value(model)
end end
""" """
......
...@@ -120,7 +120,7 @@ function pfba( ...@@ -120,7 +120,7 @@ function pfba(
termination_status(cbm) == MOI.LOCALLY_SOLVED # try to relax bound if failed optimization termination_status(cbm) == MOI.LOCALLY_SOLVED # try to relax bound if failed optimization
break break
else else
JuMP.delete(cbm, pfbacon) COBREXA.JuMP.delete(cbm, pfbacon)
@constraint(cbm, lbconval * λ <= sum(v[i] for i in objective_indices) <= λ) @constraint(cbm, lbconval * λ <= sum(v[i] for i in objective_indices) <= λ)
optimize!(cbm) optimize!(cbm)
end end
......
...@@ -10,7 +10,7 @@ function make_optimization_model( ...@@ -10,7 +10,7 @@ function make_optimization_model(
m, n = size(stoichiometry(model)) m, n = size(stoichiometry(model))
xl, xu = bounds(model) xl, xu = bounds(model)
optimization_model = JuMP.Model(optimizer) optimization_model = COBREXA.JuMP.Model(optimizer)
@variable(optimization_model, x[i = 1:n]) @variable(optimization_model, x[i = 1:n])
@objective(optimization_model, sense, objective(model)' * x) @objective(optimization_model, sense, objective(model)' * x)
mb = @constraint(optimization_model, mb, stoichiometry(model) * x .== balance(model)) # mass balance mb = @constraint(optimization_model, mb, stoichiometry(model) * x .== balance(model)) # mass balance
...@@ -30,6 +30,6 @@ function optimize_model( ...@@ -30,6 +30,6 @@ function optimize_model(
) where {LM<:MetabolicModel} ) where {LM<:MetabolicModel}
optimization_model, x, _, _, _ = optimization_model, x, _, _, _ =
make_optimization_model(model, optimizer; sense = sense) make_optimization_model(model, optimizer; sense = sense)
JuMP.optimize!(optimization_model) COBREXA.JuMP.optimize!(optimization_model)
return (optimization_model, x) return (optimization_model, x)
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