Skip to content

Commit

Permalink
Updated docs design_algorithms for nicer Sphinx output (#279)
Browse files Browse the repository at this point in the history
Closes #258
  • Loading branch information
zakandrewking authored and phantomas1234 committed Sep 10, 2016
1 parent 650cf01 commit 128034e
Showing 1 changed file with 68 additions and 40 deletions.
108 changes: 68 additions & 40 deletions cobra/design/design_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,37 @@ def set_up_optknock(model, chemical_objective, knockable_reactions,
n_knockouts_required=True, dual_maximum=1000, copy=True):
"""Set up the OptKnock problem described by Burgard et al., 2003:
Burgard AP, Pharkya P, Maranas CD. Optknock: a bilevel programming
framework for identifying gene knockout strategies for microbial strain
optimization. Biotechnol Bioeng. 2003;84(6):647-57.
http://dx.doi.org/10.1002/bit.10803.
Burgard AP, Pharkya P, Maranas CD. Optknock: a bilevel programming framework
for identifying gene knockout strategies for microbial strain optimization.
Biotechnol Bioeng. 2003;84(6):647-57. https://doi.org/10.1002/bit.10803.
Arguments
---------
model : :class:`~cobra.core.Model` object.
model: :class:`~cobra.core.Model`
A COBRA model.
chemical_objective: str. The ID of the reaction to maximize in the outer
problem.
chemical_objective: str
The ID of the reaction to maximize in the outer problem.
knockable_reactions: [str]. A list of reaction IDs that can be knocked out.
knockable_reactions: [str]
A list of reaction IDs that can be knocked out.
biomass_objective: str. The ID of the reaction to maximize in the inner
problem. By default, this is the existing objective function in the passed
model.
biomass_objective: str
The ID of the reaction to maximize in the inner problem. By default,
this is the existing objective function in the passed model.
n_knockouts: int. The number of knockouts allowable.
n_knockouts: int
The number of knockouts allowable.
n_knockouts_required: bool. Require exactly the number of knockouts
specified by n_knockouts.
n_knockouts_required: bool
Require exactly the number of knockouts specified by n_knockouts.
dual_maximum: float or int. The upper bound for dual variables.
dual_maximum: float or int
The upper bound for dual variables.
copy: bool. Copy the model before making any modifications.
copy: bool
Copy the model before making any modifications.
Zachary King 2015
Expand Down Expand Up @@ -139,15 +145,20 @@ def run_optknock(optknock_problem, solver=None, tolerance_integer=1e-9,
**kwargs):
"""Run the OptKnock problem created with set_up_optknock.
Arguments
---------
optknock_problem: :class:`~cobra.core.Model` object. The problem generated
by set_up_optknock.
optknock_problem: :class:`~cobra.core.Model`
The problem generated by set_up_optknock.
solver: str. The name of the preferred solver.
solver: str
The name of the preferred solver.
tolerance_integer: float. The integer tolerance for the MILP.
tolerance_integer: float
The integer tolerance for the MILP.
**kwargs: Keyword arguments are passed to Model.optimize().
**kwargs
Keyword arguments are passed to Model.optimize().
Zachary King 2015
Expand Down Expand Up @@ -179,10 +190,14 @@ def dual_problem(model, objective_sense="maximize",
Make the problem irreversible, then take the dual. Convert the problem:
.. code-block:: none
Maximize (c^T)x subject to Ax <= b, x >= 0
which is something like this in COBRApy:
.. code-block:: none
Maximize sum(objective_coefficient_j * reaction_j for all j)
s.t.
sum(coefficient_i_j * reaction_j for all j) <= metabolite_bound_i
Expand All @@ -191,10 +206,14 @@ def dual_problem(model, objective_sense="maximize",
to the problem:
.. code-block:: none
Minimize (b^T)w subject to (A^T)w >= c, w >= 0
which is something like this in COBRApy (S matrix is m x n):
.. code-block:: none
Minimize sum( metabolite_bound_i * dual_i for all i ) +
sum( upper_bound_j * dual_m+j for all j ) +
s.t.
Expand All @@ -206,41 +225,46 @@ def dual_problem(model, objective_sense="maximize",
Arguments
---------
model : :class:`~cobra.core.Model` object.
model : :class:`~cobra.core.Model`
The COBRA model.
objective_sense: str. The objective sense of the starting problem, either
'maximize' or 'minimize'. A minimization problems will be converted to a
maximization before taking the dual. This function always returns a
minimization problem.
objective_sense: str
The objective sense of the starting problem, either 'maximize' or
'minimize'. A minimization problems will be converted to a maximization
before taking the dual. This function always returns a minimization
problem.
iteger_vars_to_maintain: [str]. A list of IDs for Boolean integer variables
to be maintained in the dual problem. See 'Maintaining integer variables'
below for more details
iteger_vars_to_maintain: [str]
A list of IDs for Boolean integer variables to be maintained in the dual
problem. See 'Maintaining integer variables' below for more details.
already_irreversible: Boolean. If True, then do not convert the model to
irreversible.
already_irreversible: bool
If True, then do not convert the model to irreversible.
copy: bool. If True, then make a copy of the model before modifying
it. This is not necessary if already_irreversible is True.
copy: bool
If True, then make a copy of the model before modifying it. This is not
necessary if already_irreversible is True.
dual_maximum: float or int. The upper bound for dual variables.
dual_maximum: float or int
The upper bound for dual variables.
Maintaining integer variables
-----------------------------
**Maintaining integer variables**
The argument integer_vars_to_maintain can be used to specify certin Boolean
The argument ``integer_vars_to_maintain`` can be used to specify certin Boolean
integer variables that will be maintained in the dual problem. This makes
it possible to join outer and inner problems in a bi-level MILP. The method
for maintaining integer variables is described by Tepper and Shlomi, 2010:
Tepper N, Shlomi T. Predicting metabolic engineering knockout
strategies for chemical production: accounting for competing pathways.
Bioinformatics. 2010;26(4):536-43. doi:10.1093/bioinformatics/btp704.
Tepper N, Shlomi T. Predicting metabolic engineering knockout strategies for
chemical production: accounting for competing pathways. Bioinformatics.
2010;26(4):536-43. https://doi.org/10.1093/bioinformatics/btp704.
In COBRApy, this roughly translates to transforming (decision variables p,
integer constraints o):
.. code-block:: none
Maximize (c^T)x subject to (A_x)x + (A_y)y <= b, x >= 0
(1) Maximize sum(objective_coefficient_j * reaction_j for all j)
Expand All @@ -253,10 +277,14 @@ def dual_problem(model, objective_sense="maximize",
to the problem:
.. code-block:: none
Minimize (b - (A_y)y)^T w subject to (A_x^T)w >= c, w >= 0
which linearizes to (with auxiliary variables z):
.. code-block:: none
Minimize (b^T)w - { ((A_y)y)^T w with yw --> z }
subject to (A_x^T)w >= c, linearization constraints, w >= 0
Linearization constraints: z <= w_max * y, z <= w,
Expand Down

0 comments on commit 128034e

Please sign in to comment.