Skip to content

Commit

Permalink
rename modifications to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
exaexa committed Jan 3, 2024
1 parent 4db50b5 commit fd1c5e8
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 37 deletions.
6 changes: 3 additions & 3 deletions docs/src/examples/02a-optimizer-parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# # Changing optimizer parameters
#
# Many optimizers require fine-tuning to produce best results. You can pass in
# additional optimizer settings via the `modifications` parameter of
# additional optimizer settings via the `settings` parameter of
# [`flux_balance_analysis`](@ref). These include e.g.
#
# - [`set_optimizer_attribute`](@ref) (typically allowing you to tune e.g.
Expand Down Expand Up @@ -47,7 +47,7 @@ model = load_model("e_coli_core.json")
solution = flux_balance_analysis(
model,
Tulip.Optimizer;
modifications = [silence, set_optimizer_attribute("IPM_IterationsLimit", 1000)],
settings = [silence, set_optimizer_attribute("IPM_IterationsLimit", 1000)],
)

@test !isnothing(solution) #src
Expand All @@ -60,7 +60,7 @@ solution = flux_balance_analysis(
solution = flux_balance_analysis(
model,
Tulip.Optimizer;
modifications = [set_optimizer_attribute("IPM_IterationsLimit", 2)],
settings = [set_optimizer_attribute("IPM_IterationsLimit", 2)],
)

println(solution)
Expand Down
6 changes: 3 additions & 3 deletions docs/src/examples/02c-constraint-modifications.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ vt = optimized_constraints(
forced_mixed_fermentation,
objective = forced_mixed_fermentation.objective.value,
optimizer = Tulip.Optimizer,
modifications = [silence],
settings = [silence],
)

@test isapprox(vt.objective, 0.6337, atol = TEST_TOLERANCE) #src
Expand All @@ -78,7 +78,7 @@ vt = optimized_constraints(
ctmodel,
objective = ctmodel.objective.value,
optimizer = Tulip.Optimizer,
modifications = [silence],
settings = [silence],
)

@test isnothing(vt) #src
Expand All @@ -90,7 +90,7 @@ vt = optimized_constraints(
ctmodel,
objective = ctmodel.objective.value,
optimizer = Tulip.Optimizer,
modifications = [silence],
settings = [silence],
)

@test isapprox(vt.objective, 0.8739, atol = TEST_TOLERANCE) #src
6 changes: 3 additions & 3 deletions docs/src/examples/03-parsimonious-flux-balance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ model = load_model("e_coli_core.json") # load the model
# Use the convenience function to run standard pFBA on

vt =
parsimonious_flux_balance_analysis(model, Clarabel.Optimizer; modifications = [silence])
parsimonious_flux_balance_analysis(model, Clarabel.Optimizer; settings = [silence])

# Or use the piping functionality

model |> parsimonious_flux_balance_analysis(Clarabel.Optimizer; modifications = [silence])
model |> parsimonious_flux_balance_analysis(Clarabel.Optimizer; settings = [silence])

@test isapprox(vt.objective, 0.87392; atol = TEST_TOLERANCE) #src
@test sum(x^2 for x in values(vt.fluxes)) < 15000 #src
Expand Down Expand Up @@ -82,7 +82,7 @@ vt = minimize_metabolic_adjustment(model, ref_sol, Gurobi.Optimizer)
# Or use the piping functionality
model |>
minimize_metabolic_adjustment(ref_sol, Clarabel.Optimizer; modifications = [silence])
minimize_metabolic_adjustment(ref_sol, Clarabel.Optimizer; settings = [silence])
@test isapprox(vt.:momaobjective, 0.81580806; atol = TEST_TOLERANCE) #src
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/05-enzyme-constrained-models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ ec_solution = enzyme_constrained_flux_balance_analysis(
reaction_isozymes,
gene_molar_masses,
[("total_proteome_bound", A.genes(model), total_enzyme_capacity)];
modifications = [set_optimizer_attribute("IPM_IterationsLimit", 10_000)],
settings = [set_optimizer_attribute("IPM_IterationsLimit", 10_000)],
unconstrain_reactions = ["EX_glc__D_e"],
optimizer = Tulip.Optimizer,
)
Expand Down Expand Up @@ -173,5 +173,5 @@ ec_solution = optimized_constraints(
m;
objective = m.objective.value,
optimizer = Tulip.Optimizer,
modifications = [set_optimizer_attribute("IPM_IterationsLimit", 10_000)],
settings = [set_optimizer_attribute("IPM_IterationsLimit", 10_000)],
)
4 changes: 2 additions & 2 deletions docs/src/examples/06-thermodynamic-models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ mmdf_solution = max_min_driving_force_analysis(
concentration_ub = 1e-1, # M
T = 298.15, # Kelvin
R = 8.31446261815324e-3, # kJ/K/mol
modifications = [set_optimizer_attribute("IPM_IterationsLimit", 1_000)],
settings = [set_optimizer_attribute("IPM_IterationsLimit", 1_000)],
optimizer = Tulip.Optimizer,
)

Expand Down Expand Up @@ -150,5 +150,5 @@ mmdf_solution = optimized_constraints(
m;
objective = m.max_min_driving_force.value,
optimizer = Tulip.Optimizer,
modifications = [set_optimizer_attribute("IPM_IterationsLimit", 1_000)],
settings = [set_optimizer_attribute("IPM_IterationsLimit", 1_000)],
)
4 changes: 2 additions & 2 deletions docs/src/examples/08-community-models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ sol = optimized_constraints(
m;
objective = m.objective.value,
optimizer = Tulip.Optimizer,
modifications = [set_optimizer_attribute("IPM_IterationsLimit", 1000)],
settings = [set_optimizer_attribute("IPM_IterationsLimit", 1000)],
)

@test isapprox(sol.:objective, 0.66686196344, atol = TEST_TOLERANCE) #src
Expand All @@ -127,7 +127,7 @@ sol = optimized_constraints(
m;
objective = m.objective.value,
optimizer = Tulip.Optimizer,
modifications = [set_optimizer_attribute("IPM_IterationsLimit", 1000)],
settings = [set_optimizer_attribute("IPM_IterationsLimit", 1000)],
)


Expand Down
2 changes: 1 addition & 1 deletion src/COBREXA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ include("frontend/enzyme_constrained.jl")

# utilities
include("misc/bounds.jl")
include("misc/modifications.jl")
include("misc/settings.jl")
include("misc/utils.jl")

end # module COBREXA
4 changes: 2 additions & 2 deletions src/frontend/balance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $(TYPEDSIGNATURES)
Pipe-able overload of [`flux_balance_analysis`](@ref).
"""
flux_balance_analysis(optimizer; modifications = []) =
m -> flux_balance_analysis(m, optimizer; modifications)
flux_balance_analysis(optimizer; settings = []) =
m -> flux_balance_analysis(m, optimizer; settings)

export flux_balance_analysis
6 changes: 3 additions & 3 deletions src/frontend/enzyme_constrained.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The latter is a vector of tuples, where each tuple represents a distinct bound
as `(bound_id, genes_in_bound, protein_mass_bound)`. Typically, `model` has
bounded exchange reactions, which are unnecessary in enzyme constrained models.
Unbound these reactions by listing their IDs in `unconstrain_reactions`, which
makes them reversible. Optimization `modifications` are directly forwarded.
makes them reversible. Optimization `settings` are directly forwarded.
In the event that your model requires more complex build steps, consider
constructing it manually by using [`add_enzyme_constraints!`](@ref).
Expand All @@ -37,7 +37,7 @@ function enzyme_constrained_flux_balance_analysis(
capacity_limitations::Vector{Tuple{String,Vector{String},Float64}};
optimizer,
unconstrain_reactions = String[],
modifications = [],
settings = [],
)
m = fbc_model_constraints(model)

Expand All @@ -56,7 +56,7 @@ function enzyme_constrained_flux_balance_analysis(
m.fluxes[rid].bound = C.Between(-1000.0, 1000.0)
end

optimized_constraints(m; objective = m.objective.value, optimizer, modifications)
optimized_constraints(m; objective = m.objective.value, optimizer, settings)
end

export enzyme_constrained_flux_balance_analysis
4 changes: 2 additions & 2 deletions src/frontend/loopless.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function loopless_flux_balance_analysis(
model;
max_flux_bound = 1000.0, # needs to be an order of magnitude bigger, big M method heuristic
strict_inequality_tolerance = 1.0, # heuristic from paper
modifications = [],
settings = [],
optimizer,
)

Expand All @@ -68,7 +68,7 @@ function loopless_flux_balance_analysis(
)

# solve
optimized_constraints(m; objective = m.objective.value, optimizer, modifications)
optimized_constraints(m; objective = m.objective.value, optimizer, settings)
end

export loopless_flux_balance_analysis
6 changes: 3 additions & 3 deletions src/frontend/mmdf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ supplied).
`T` and `R` can be specified in the corresponding units; defaults are K and
kJ/K/mol. The unit of metabolite concentrations is typically molar, and the ΔG⁰s
have units of kJ/mol. Other units can be used, as long as they are consistent.
As usual, optimizer settings can be changed with `modifications`.
As usual, optimizer settings can be changed with `settings`.
"""
function max_min_driving_force_analysis(
model::A.AbstractFBCModel,
Expand All @@ -82,7 +82,7 @@ function max_min_driving_force_analysis(
T = 298.15, # Kelvin
R = 8.31446261815324e-3, # kJ/K/mol
ignore_reaction_ids = String[],
modifications = [],
settings = [],
optimizer,
)
m = build_max_min_driving_force_model(
Expand Down Expand Up @@ -113,7 +113,7 @@ function max_min_driving_force_analysis(
m;
objective = m.max_min_driving_force.value,
optimizer,
modifications,
settings,
)
end

Expand Down
10 changes: 5 additions & 5 deletions src/frontend/moma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ A slightly easier-to-use version of [`minimization_of_metabolic_adjustment_analy
computes the reference flux as the optimal solution of the
[`reference_model`](@ref). The reference flux is calculated using
`reference_optimizer` and `reference_modifications`, which default to the
`optimizer` and `modifications`.
`optimizer` and `settings`.
Leftover arguments are passed to the overload of
[`minimization_of_metabolic_adjustment_analysis`](@ref) that accepts the reference flux
Expand All @@ -68,23 +68,23 @@ function minimization_of_metabolic_adjustment_analysis(
reference_model::A.AbstractFBCModel,
optimizer;
reference_optimizer = optimizer,
modifications = [],
reference_modifications = modifications,
settings = [],
reference_settings = settings,
kwargs...,
)
reference_constraints = fbc_model_constraints(reference_model)
reference_fluxes = optimized_constraints(
reference_constraints;
optimizer = reference_optimizer,
modifications = reference_modifications,
settings = reference_settings,
output = reference_constraints.fluxes,
)
isnothing(reference_fluxes) && return nothing
minimization_of_metabolic_adjustment_analysis(
model,
reference_fluxes,
optimizer;
modifications,
settings,
kwargs...,
)
end
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/parsimonious.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $(TYPEDSIGNATURES)
Optimize the system of `constraints` to get the optimal `objective` value. Then
try to find a "parsimonious" solution with the same `objective` value, which
optimizes the `parsimonious_objective` (possibly also switching optimization
sense, optimizer, and adding more modifications).
sense, optimizer, and adding more settings).
For efficiency, everything is performed on a single instance of JuMP model.
Expand All @@ -30,7 +30,7 @@ in [`parsimonious_flux_balance`](@ref).
function parsimonious_optimized_constraints(
constraints::C.ConstraintTreeElem;
objective::C.Value,
modifications = [],
settings = [],
parsimonious_objective::C.Value,
parsimonious_optimizer = nothing,
parsimonious_sense = J.MIN_SENSE,
Expand All @@ -42,7 +42,7 @@ function parsimonious_optimized_constraints(

# first solve the optimization problem with the original objective
om = optimization_model(constraints; objective, kwargs...)
for m in modifications
for m in settings
m(om)
end
J.optimize!(om)
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export Feasible
$(TYPEDSIGNATURES)
Make an JuMP model out of `constraints` using [`optimization_model`](@ref)
(most arguments are forwarded there), then apply the `modifications`, optimize
(most arguments are forwarded there), then apply the `settings`, optimize
the model, and return either `nothing` if the optimization failed, or `output`
substituted with the solved values (`output` defaults to `constraints`.
Expand All @@ -113,12 +113,12 @@ For a "nice" version for simpler finding of metabolic model optima, use
"""
function optimized_constraints(
constraints::C.ConstraintTreeElem;
modifications = [],
settings = [],
output = constraints,
kwargs...,
)
om = optimization_model(constraints; kwargs...)
for m in modifications
for m in settings
m(om)
end
J.optimize!(om)
Expand Down

0 comments on commit fd1c5e8

Please sign in to comment.