def is_consistent(database, solver, exchange=set(), zeromass=set()):
prob = solver.create_problem()<EOL>compound_set = _non_localized_compounds(database)<EOL>mass_compounds = compound_set.difference(zeromass)<EOL>m = prob.namespace(mass_compounds, lower=<NUM_LIT:1>)<EOL>prob.set_objective(m.sum(mass_compounds))<EOL>massbalance_lhs = {reaction: <NUM_LIT:0> for reaction in database.reactions}<EOL>for (compound, reaction), value in iteritems(database.matrix):<EOL><INDENT>if compound not in zeromass:<EOL><INDENT>mass = m(compound.in_compartment(None))<EOL>massbalance_lhs[reaction] += mass * value<EOL><DEDENT><DEDENT>for reaction, lhs in iteritems(massbalance_lhs):<EOL><INDENT>if reaction not in exchange:<EOL><INDENT>prob.add_linear_constraints(lhs == <NUM_LIT:0>)<EOL><DEDENT><DEDENT>result = prob.solve_unchecked(lp.ObjectiveSense.Minimize)<EOL>return result.success<EOL>
Try to assign a positive mass to each compound

    Return True if successful. The masses are simply constrained by m_i > 1 and
    finding a solution under these conditions proves that the database is mass
    consistent.