straindesign.strainDesignMILP ============================= .. py:module:: straindesign.strainDesignMILP .. autoapi-nested-parse:: Classes and function for the solution of strain design MILPs Module Contents --------------- .. py:class:: SDMILP(model: straindesign.Model, sd_modules: List[straindesign.SDModule], **kwargs) Bases: :py:obj:`straindesign.SDProblem`, :py:obj:`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. :param model: A metabolic model that is an instance of the cobra.Model class. :type model: cobra.Model :param sd_modules: 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. :type sd_modules: (list of) straindesign.SDModule :param ko_cost: (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. :type ko_cost: optional (dict) :param ki_cost: (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. :type ki_cost: optional (dict) :param max_cost: (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. :type max_cost: optional (int) :param solver: (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'. :type solver: optional (str) :param M: (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. :type M: optional (int) :param essential_kis: 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. :type essential_kis: optional (set) :returns: An instance of SDProblem containing the strain design MILP and providing several functions for its solution :rtype: (SDMILP) .. py:method:: add_exclusion_constraints(z) Exclude binary solution in z and all supersets from MILP .. py:method:: add_exclusion_constraints_ineq(z) Exclude binary solution in z (but not its supersets) from MILP .. py:method:: build_sd_solution(sd_dict, status, solution_approach) Build the strain design solution object .. py:method:: compute(**kwargs) Compute arbitrary solutions of the strain design MILP and iteratively find further solutions :param max_solutions: (Default: inf) The maximum number of MILP solutions that are generated for a strain design problem. :type max_solutions: optional (int) :param time_limit: (Default: inf) The time limit in seconds for the MILP-solver. :type time_limit: optional (int) :param show_no_ki: (Default: True) Indicate non-added addition candidates in a solution specifically with a value of 0 :type show_no_ki: optional (bool) :returns: Strain design solutions provided as an SDSolutions object :rtype: (SDSolutions) .. py:method:: compute_optimal(**kwargs) Compute the global optimum of the strain design MILP and iteratively find the next best solution :param max_solutions: (Default: inf) The maximum number of MILP solutions that are generated for a strain design problem. :type max_solutions: optional (int) :param time_limit: (Default: inf) The time limit in seconds for the MILP-solver. :type time_limit: optional (int) :param show_no_ki: (Default: True) Indicate non-added addition candidates in a solution specifically with a value of 0 :type show_no_ki: optional (bool) :returns: Strain design solutions provided as an SDSolutions object :rtype: (SDSolutions) .. py:method:: enumerate(**kwargs) Find all globally optimal solutions to the strain design MILP and iteratively construct pools for the suboptimal values :param max_solutions: (Default: inf) The maximum number of MILP solutions that are generated for a strain design problem. :type max_solutions: optional (int) :param time_limit: (Default: inf) The time limit in seconds for the MILP-solver. :type time_limit: optional (int) :param show_no_ki: (Default: True) Indicate non-added addition candidates in a solution specifically with a value of 0 :type show_no_ki: optional (bool) :returns: Strain design solutions provided as an SDSolutions object :rtype: (SDSolutions) .. py:method:: fixObjective(c, cx) Enforce a certain objective function and value (or any other constraint of the form c*x <= cx) .. py:method:: populateZ(n) -> Tuple[List, int] Populate MILP, and return only binary variables rounded to 5 decimals (should return ints) .. py:method:: resetObjective() Reset objective to the one set upon MILP construction .. py:method:: resetTargetableZ() Reset targetable/switchable intervention indicators / allow all intervention candidates .. py:method:: sd2dict(sol, *args) -> Dict Translate binary solution vector to dictionary for human-readable output .. py:method:: setMinIntvCostObjective() Reset minimization of intervention costs as global objective .. py:method:: setTargetableZ(sol) Only allow a subset of intervention candidates .. py:method:: solveZ() -> Tuple[List, int] Solve MILP, and return only binary variables rounded to 5 decimals (should return ints) .. py:method:: verify_sd(sols) -> List Verify computed strain design