Skip to content
Snippets Groups Projects
Unverified Commit d5e0ff6a authored by St. Elmo's avatar St. Elmo
Browse files

added fva like warmup point function

parent d8f95671
No related branches found
No related tags found
No related merge requests found
......@@ -47,17 +47,25 @@ samples = hit_and_run(100_000, opt_model; keepevery=10, samplesize=5000)
```
"""
function hit_and_run(
N::Int,
opt_model;
model,
optimizer;
modifications = [],
N = 1000,
keepevery = _constants.sampling_keep_iters,
samplesize = _constants.sampling_size,
random_objective = false,
num_warmup_points = length(reactions(model))
)
lbs, ubs = get_bound_vectors(opt_model) # get actual ub and lb constraints, can't use model function because the user may have changed them in the function arguments
wpoints = _get_warmup_points(opt_model; random_objective = random_objective)
# generate warmup points
ws = flux_variability_analysis(
model,
collect(1:10),
Tulip.Optimizer;
bounds = objective_bounds(0.90),
ret = m -> COBREXA.JuMP.value.(m[:x])
)
nwpts = size(wpoints, 2) # number of warmup points generated
samples = zeros(size(wpoints, 1), samplesize) # sample storage
current_point = zeros(size(wpoints, 1))
......
"""
warmup(
model::MetabolicModel,
optimizer;
warmup_points::Vector{Int},
modifications = [],
workers = [myid()],
Generates warmup points for samplers by sequentially minimizing and maximizing
reactions at `warmup_points`. Very similar to [`flux_variability_analysis`](@ref).
"""
function warmup(
model::MetabolicModel,
optimizer;
warmup_points::Vector{Int},
modifications = [],
workers = [myid()],
)
# create optimization problem, apply constraints, load on all workers
optmodel = make_optimization_model(model, optimizer)
for mod in modifications
mod(model, optmodel)
end
map(fetch, save_at.(workers, :warmup_model, Ref(:($optmodel))))
ret = m -> value.(m[:x]) # get all the fluxes
fluxes = dpmap(
rid -> :($COBREXA._FVA_optimize_reaction(warmup_model, $rid, $ret)),
CachingPool(workers),
[-warmup_points warmup_points],
)
# free the data on workers
map(fetch, remove_from.(workers, :warmup_model))
return fluxes
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment