rbatools.fba_problem
module
Classes
class ProblemFBA
-
Class holding RBA-problem as mathematical manifestation of the RBA-model.
Attributes
LP
:LinearProblem
object
parsimonious
:bool
- Indicator whether FBA problem is parsimonious
Solved
:bool
- Booelean indicating wheter Problem has been successfully solved, according to the acceptable solution statuses provided to the solve_lp-method. Created by method 'solve_lp'
SolutionStatus
:int
- Numerical value indicating the solution-status of the problem. Consult CPLEX documentation for their meaning. Created by method 'solve_lp'
ObjectiveValue
:float
- Numeric value of the objective function after optimisation by CPLEX. Created by method 'solve_lp'
SolutionValues
:dict
- Solution vector after optimisation by CPLEX. (Dictionary with variable IDs as keys and numeric values as values) Created by method 'solve_lp'
DualValues
:dict
- Vector of dual-values after optimisation by CPLEX. (Dictionary with constraint IDs as keys and numeric values as values) Created by method 'solve_lp'
Methods
def __init__(self, FBA)
-
Initialize self. See help(type(self)) for accurate signature.
def calculate_left_hand_side(self, constraints=[])
-
Calculates value of problem's lefthand side (after multiplying with solution-vector).
Parameters
constraints
:str
orlist
ofstr
- Constraints to retreive the LHS-value for. Either constraint ID or list of constraint IDs to specify the LHS-value of which constraint to look up. This is an optional input; if not provided all constraint are looked up.
Returns
dict
- Dictionary with constraint-IDs as keys and LHS-value as values.
def clear_objective(self)
-
Sets all coefficients of the objective function to zero.
def export_escher_map(self, Filename)
def get_constraint_types(self, constraints=[])
-
Extracts type of constraints.
Parameters
constraints
:str
orlist
ofstr
- Constraints to retreive the type for. Either constraint ID or list of constraint IDs to specify the type of which constraint to look up. This is an optional input; if not provided all constraint are looked up.
Returns
dict
- Dictionary with constraint-IDs as keys and type identification-characters as values.
def get_lb(self, variables=[])
-
Returns lower bounds of problem variables.
Parameters
variables
:str
list
ofstr
- Variables to retreive the objective coefficients for. Either variable ID or list of variable IDs to specify the coefficients of which variables to look up. This is an optional input; if not provided all variables are looked up.
Returns
dict
- Dictionary with variable-IDs as keys and lower bounds as values.
def get_objective(self, variables=[])
-
Returns objective coefficient of variables in problem.
Parameters
variables
:str
orlist
ofstr
- Variables to retreive the objective coefficients for. Either variable ID or list of variable IDs to specify the coefficients of which variables to look up. This is an optional input; if not provided all variables are looked up.
Returns
dict
- Dictionary with variable-IDs as keys and objective coefficients as values.
def get_problem_coefficients(self, inputTuples=[])
-
Returns coefficients of LHS of problem.
Parameters
inputTuples : tuple or list of tuples. Tuples hold row and column indices. [('row1','col1'),('row2','col2'),…] or ('row1','col1').
Returns
dict
- Dictionary with index tuples as keys and matrix coefficients as values.
def get_right_hand_side(self, constraints=[])
-
Extracts coefficients of problem's righthand side (B-vector).
Parameters
constraints
:str
orlist
ofstr
- Constraints to retreive the objective coefficients for. Either constraint ID or list of constraint IDs to specify the RHS of which constraint to look up. This is an optional input; if not provided all constraint are looked up.
Returns
dict
- Dictionary with constraint-IDs as keys and RHS-values as values.
def get_ub(self, variables=[])
-
Returns upper bounds of problem variables.
Parameters
variables
:str
list
ofstr
- Variables to retreive the objective coefficients for. Either variable ID or list of variable IDs to specify the coefficients of which variables to look up. This is an optional input; if not provided all variables are looked up.
Returns
dict
- Dictionary with variable-IDs as keys and upper bounds as values.
def invert_objective(self)
-
Changes sign (optimisation-sense) of objective function.
def parsimonise(self, rxns_to_ignore_in_objective=[])
-
Transforms current FBA-problem into a parsimonious FBA problem. Reversible reactions are duplicated into a (irreversible) forward and backward-variants. Objective function is defined to minimize total sum of (internal reactions).
Parameters
rxns_to_ignore_in_objective
:list
ofstr
List of reactions to ignore in objective function (not subject to principle of parsimony)
def set_constraint_types(self, inputDict)
-
Sets type of constraints.
E
: = ;L
: <= ;G
: >=
Parameters
inputDict
:dict
- Dictionary with constraint-IDs as keys and type identification-character as values. ({'col1':'E','col2':'L', …}).
def set_lb(self, inputDict)
-
Set lower-bounds of the problem variables.
Parameters
inputDict
:dict
- Dictionary with variable-IDs as keys and new numeric values as values. ({'col1':42,'col2':9000, …}).
def set_objective(self, inputDict)
-
Sets objective function coefficients.
Parameters
inputDict
:dict
- Dictionary with variable-IDs as keys and new numeric values as values. ({'col1':42,'col2':9000, …}).
def set_problem_coefficients(self, inputDict)
-
Set coefficients of the problems' LHS (constraint matrix).
Parameters
inputDict
:dict
- Dict with index-tuples ('row1','col1') as keys and new numeric values as values. ({('row1','col1'):42,('row2','col2'):9000, …}).
def set_right_hand_side(self, inputDict)
-
Set coefficients of the problems' RHS (b-vector). Parameters
inputDict
:dict
- Dictionary with constraint-IDs as keys and new numeric values as values. ({'row1':42,'row2':9000, …}).
def set_ub(self, inputDict)
-
Set upper-bounds of the problem variables.
Parameters
inputDict
:dict
- Dictionary with variable-IDs as keys and new numeric values as values. ({'col1':42,'col2':9000, …}).
def solve_lp(self, feasible_stati=['optimal', 'feasible'], try_unscaling_if_sol_status_is_feasible_only_before_unscaling=True)
-
Solves Linear fBA problem.
When solution-status is amongst the user-defined feasible statuses; boolean 'Solved' is set to True and 'ObjectiveValue', 'SolutionValues' and 'DualValues' are stored as attributes.
Parameters
feasible_stati
:list
ofint
- List with identifiers of acceptable solution statuses. (consult ILOG-CPLEX documentation for information on them). Default: feasible_stati=["optimal","feasible"]
try_unscaling_if_sol_status_is_feasible_only_before_unscaling :bool Try re-solving problem with less aggressive scaling, when solution status is infeasible after unscaling Default: True