rbatools.rba_problem_matrix module
Classes
class ProblemMatrix-
Class holding RBA-Linear Problem. Required Object type for linear problems (matrices), to be used in this RBA-API. Should include all fields, required for a linear problem in the COBRA format, as attributes.
Attributes
A:scipy.sparse.coo_matrix- Lefthandside of constraint Matrix (aka Constraint Matrix)
b:numpy.array- Righthandside of Constraint Matrix
row_signs:list- Type of constraints ('E' for equality 'L' for lower-or-equal inequality) –> Ax=b or Ax<=b
f:numyp.array- Objective function linear get_coefficients
LB:numpy.array- Lower bounds of decision-variables
UB:numpy.array- Upper bounds of decision-variables
row_names:list- Names of constraints
col_names:list- Names of decision-variables
rowIndicesMap:dict- Dictionary mapping constraint names to their numeric index (generated automatically)
colIndicesMap:dict- Dictionary mapping variable names to their numeric index (generated automatically)
Methods
def __init__(self)-
Initiates with empty Problem. Attributes can be changed manually.
def a_to_coo(self)-
Transforms constraint matrix (LHS) to scipy.sparse.coo_matrix format.
def a_to_lil(self)-
Transforms constraint matrix (LHS) to scipy.sparse.lil_matrix format.
def load_matrix(self, matrix)-
Imports information from compatible object.
Imports information for attributes from input-objects (named matrix) with the respectively named fields, required. Required fields are: 'A','b','row_signs','f','LB','UB','row_names' and 'col_names'.
Parameters
matrix:anyLP-objectholdingtherequiredfields- The matrix with elements to be added
def map_indices(self)-
Generates rowIndicesMap and colIndicesMap from attributes.
rowIndicesMap = Dictionary: {'constraint_name':index,…} colIndicesMap = Dictionary: {'variable_name':index,…}
def scale_lhs(self, factor)def to_float64(self)-
Transforms all numerical attributes to number type numpy.float64.