def constraint_matrices(model, array_type='<STR_LIT>', include_vars=False,<EOL>zero_tol=<NUM_LIT>):
if array_type not in ('<STR_LIT>', '<STR_LIT>') and not dok_matrix:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>array_builder = {<EOL>'<STR_LIT>': np.array, '<STR_LIT>': dok_matrix, '<STR_LIT>': lil_matrix,<EOL>'<STR_LIT>': pd.DataFrame,<EOL>}[array_type]<EOL>Problem = namedtuple("<STR_LIT>",<EOL>["<STR_LIT>", "<STR_LIT:b>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>"])<EOL>equality_rows = []<EOL>inequality_rows = []<EOL>inequality_bounds = []<EOL>b = []<EOL>for const in model.constraints:<EOL><INDENT>lb = -np.inf if const.lb is None else const.lb<EOL>ub = np.inf if const.ub is None else const.ub<EOL>equality = (ub - lb) < zero_tol<EOL>coefs = const.get_linear_coefficients(model.variables)<EOL>coefs = [coefs[v] for v in model.variables]<EOL>if equality:<EOL><INDENT>b.append(lb if abs(lb) > zero_tol else <NUM_LIT:0.0>)<EOL>equality_rows.append(coefs)<EOL><DEDENT>else:<EOL><INDENT>inequality_rows.append(coefs)<EOL>inequality_bounds.append([lb, ub])<EOL><DEDENT><DEDENT>var_bounds = np.array([[v.lb, v.ub] for v in model.variables])<EOL>fixed = var_bounds[:, <NUM_LIT:1>] - var_bounds[:, <NUM_LIT:0>] < zero_tol<EOL>results = Problem(<EOL>equalities=array_builder(equality_rows),<EOL>b=np.array(b),<EOL>inequalities=array_builder(inequality_rows),<EOL>bounds=array_builder(inequality_bounds),<EOL>variable_fixed=np.array(fixed),<EOL>variable_bounds=array_builder(var_bounds))<EOL>return results<EOL>
Create a matrix representation of the problem.

    This is used for alternative solution approaches that do not use optlang.
    The function will construct the equality matrix, inequality matrix and
    bounds for the complete problem.

    Notes
    -----
    To accomodate non-zero equalities the problem will add the variable
    "const_one" which is a variable that equals one.

    Arguments
    ---------
    model : cobra.Model
        The model from which to obtain the LP problem.
    array_type : string
        The type of array to construct. if 'dense', return a standard
        numpy.array, 'dok', or 'lil' will construct a sparse array using
        scipy of the corresponding type and 'DataFrame' will give a
        pandas `DataFrame` with metabolite indices and reaction columns.
    zero_tol : float
        The zero tolerance used to judge whether two bounds are the same.

    Returns
    -------
    collections.namedtuple
        A named tuple consisting of 6 matrices and 2 vectors:
        - "equalities" is a matrix S such that S*vars = b. It includes a row
          for each constraint and one column for each variable.
        - "b" the right side of the equality equation such that S*vars = b.
        - "inequalities" is a matrix M such that lb <= M*vars <= ub.
          It contains a row for each inequality and as many columns as
          variables.
        - "bounds" is a compound matrix [lb ub] containing the lower and
          upper bounds for the inequality constraints in M.
        - "variable_fixed" is a boolean vector indicating whether the variable
          at that index is fixed (lower bound == upper_bound) and
          is thus bounded by an equality constraint.
        - "variable_bounds" is a compound matrix [lb ub] containing the
          lower and upper bounds for all variables.