straindesign.strainDesignMILP
Classes and function for the solution of strain design MILPs
Module Contents
- class straindesign.strainDesignMILP.SDMILP(model: straindesign.Model, sd_modules: List[straindesign.SDModule], **kwargs)[source]
Bases:
straindesign.SDProblem
,straindesign.MILP_LP
Class that contains functions for the solution of the strain design MILP
This class is a wrapper and inherited from the casses SDProblem, MILP_LP. The constructor of SDProblem (see strainDesignProblem.py) translates a given problem into a MILP. The constructor of MILP_LP (see solver_interface.py) then sets up the solver interface for the selected solver. In addition to the functions from SDProblem and MILP_LP, SDMILP provides functions for the solution of the strain design MILP, such as verification of strain design solutions or introduction of exclusion constraints for computing multiple solutions.
- Parameters:
model (cobra.Model) – A metabolic model that is an instance of the cobra.Model class.
sd_modules ((list of) straindesign.SDModule) – Modules that specify the strain design problem, e.g., protected or suppressed flux states for MCS strain design or inner and outer objective functions for OptKnock. See description of SDModule for more information on how to set up modules.
ko_cost (optional (dict)) – (Default: None) A dictionary of reaction identifiers and their associated knockout costs. If not specified, all reactions are treated as knockout candidates, equivalent to ko_cost = {‘r1’:1, ‘r2’:1, …}. If a subset of reactions is listed in the dict, all other are not considered as knockout candidates.
ki_cost (optional (dict)) – (Default: None) A dictionary of reaction identifiers and their associated costs for addition. If not specified, all reactions are treated as knockout candidates. Reaction addition candidates must be present in the original model with the intended flux boundaries after insertion. Additions are treated adversely to knockouts, meaning that their exclusion from the network is not associated with any cost while their presence entails intervention costs.
max_cost (optional (int)) – (Default: inf): The maximum cost threshold for interventions. Every possible intervention is associated with a cost value (1, by default). Strain designs cannot exceed the max_cost threshold. Individual intervention cost factors may be defined through ki_cost and ko_cost.
solver (optional (str)) – (Default: same as defined in model / COBRApy) The solver that should be used for preparing and carrying out the strain design computation. Allowed values are ‘cplex’, ‘gurobi’, ‘scip’ and ‘glpk’.
M (optional (int)) – (Default: None) If this value is specified (and non-zero, not None), the computation uses the big-M method instead of indicator constraints. Since GLPK does not support indicator constraints it uses the big-M method by default (with COBRA standard M=1000). M should be chosen ‘sufficiently large’ to avoid computational artifacts and ‘sufficiently small’ to avoid numerical issues.
essential_kis (optional (set)) – A set of reactions that are marked as addable and that are essential for at least one of the strain design modules. Providing such “essential knock-ins” may speed up the strain design computation.
- Returns:
An instance of SDProblem containing the strain design MILP and providing several functions for its solution
- Return type:
(SDMILP)
- add_exclusion_constraints_ineq(z)[source]
Exclude binary solution in z (but not its supersets) from MILP
- build_sd_solution(sd_dict, status, solution_approach)[source]
Build the strain design solution object
- compute(**kwargs)[source]
Compute arbitrary solutions of the strain design MILP and iteratively find further solutions
- Parameters:
max_solutions (optional (int)) – (Default: inf) The maximum number of MILP solutions that are generated for a strain design problem.
time_limit (optional (int)) – (Default: inf) The time limit in seconds for the MILP-solver.
show_no_ki (optional (bool)) – (Default: True) Indicate non-added addition candidates in a solution specifically with a value of 0
- Returns:
Strain design solutions provided as an SDSolutions object
- Return type:
- compute_optimal(**kwargs)[source]
Compute the global optimum of the strain design MILP and iteratively find the next best solution
- Parameters:
max_solutions (optional (int)) – (Default: inf) The maximum number of MILP solutions that are generated for a strain design problem.
time_limit (optional (int)) – (Default: inf) The time limit in seconds for the MILP-solver.
show_no_ki (optional (bool)) – (Default: True) Indicate non-added addition candidates in a solution specifically with a value of 0
- Returns:
Strain design solutions provided as an SDSolutions object
- Return type:
- enumerate(**kwargs)[source]
Find all globally optimal solutions to the strain design MILP and iteratively construct pools for the suboptimal values
- Parameters:
max_solutions (optional (int)) – (Default: inf) The maximum number of MILP solutions that are generated for a strain design problem.
time_limit (optional (int)) – (Default: inf) The time limit in seconds for the MILP-solver.
show_no_ki (optional (bool)) – (Default: True) Indicate non-added addition candidates in a solution specifically with a value of 0
- Returns:
Strain design solutions provided as an SDSolutions object
- Return type:
- fixObjective(c, cx)[source]
Enforce a certain objective function and value (or any other constraint of the form c*x <= cx)
- populateZ(n) Tuple[List, int] [source]
Populate MILP, and return only binary variables rounded to 5 decimals (should return ints)
- resetTargetableZ()[source]
Reset targetable/switchable intervention indicators / allow all intervention candidates
- sd2dict(sol, *args) Dict [source]
Translate binary solution vector to dictionary for human-readable output