def flux_randomization(model, threshold, tfba, solver):
optimize = {}<EOL>for reaction_id in model.reactions:<EOL><INDENT>if model.is_reversible(reaction_id):<EOL><INDENT>optimize[reaction_id] = <NUM_LIT:2>*random.random() - <NUM_LIT:1.0><EOL><DEDENT>else:<EOL><INDENT>optimize[reaction_id] = random.random()<EOL><DEDENT><DEDENT>fba = _get_fba_problem(model, tfba, solver)<EOL>for reaction_id, value in iteritems(threshold):<EOL><INDENT>fba.prob.add_linear_constraints(fba.get_flux_var(reaction_id) >= value)<EOL><DEDENT>fba.maximize(optimize)<EOL>for reaction_id in model.reactions:<EOL><INDENT>yield reaction_id, fba.get_flux(reaction_id)<EOL><DEDENT>
Find a random flux solution on the boundary of the solution space.

    The reactions in the threshold dictionary are constrained with the
    associated lower bound.

    Args:
        model: MetabolicModel to solve.
        threshold: dict of additional lower bounds on reaction fluxes.
        tfba: If True enable thermodynamic constraints.
        solver: LP solver instance to use.

    Returns:
        An iterator of reaction ID and reaction flux pairs.