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

use pkg relativity

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