def fastcore(model, core, epsilon, solver, scaling=<NUM_LIT>, weights={}):
consistent_subset = set()<EOL>reaction_set = set(model.reactions)<EOL>subset = core - model.reversible<EOL>logger.debug('<STR_LIT>'.format(len(subset), subset))<EOL>penalty_set = reaction_set - core<EOL>logger.debug('<STR_LIT>'.format(len(penalty_set), penalty_set))<EOL>p = FastcoreProblem(model, solver, epsilon=epsilon)<EOL>mode = set(p.find_sparse_mode(subset, penalty_set, scaling, weights))<EOL>if not subset.issubset(mode):<EOL><INDENT>raise FastcoreError('<STR_LIT>'<EOL>'<STR_LIT>'.format(subset - mode))<EOL><DEDENT>consistent_subset |= mode<EOL>logger.debug('<STR_LIT>'.format(<EOL>len(consistent_subset), consistent_subset))<EOL>subset = core - mode<EOL>logger.debug('<STR_LIT>'.format(len(subset), subset))<EOL>flipped = False<EOL>singleton = False<EOL>while len(subset) > <NUM_LIT:0>:<EOL><INDENT>penalty_set -= consistent_subset<EOL>if singleton:<EOL><INDENT>subset_i = set((next(iter(subset)),))<EOL><DEDENT>else:<EOL><INDENT>subset_i = subset<EOL><DEDENT>mode = set(p.find_sparse_mode(subset_i, penalty_set, scaling, weights))<EOL>consistent_subset.update(mode)<EOL>logger.debug('<STR_LIT>'.format(<EOL>len(consistent_subset), consistent_subset))<EOL>if not subset.isdisjoint(consistent_subset):<EOL><INDENT>logger.debug('<STR_LIT>'.format(<EOL>len(subset), len(subset - consistent_subset)))<EOL>subset -= consistent_subset<EOL>logger.debug('<STR_LIT>'.format(len(subset), subset))<EOL>flipped = False<EOL><DEDENT>else:<EOL><INDENT>logger.debug('<STR_LIT>')<EOL>subset_rev_i = subset_i & model.reversible<EOL>if flipped or len(subset_rev_i) == <NUM_LIT:0>:<EOL><INDENT>if singleton:<EOL><INDENT>raise FastcoreError('<STR_LIT>'<EOL>'<STR_LIT>'.format(subset_rev_i))<EOL><DEDENT>logger.debug('<STR_LIT>')<EOL>singleton = True<EOL>flipped = False<EOL><DEDENT>else:<EOL><INDENT>p.flip(subset_rev_i)<EOL>flipped = True<EOL>logger.debug('<STR_LIT>'.format(<EOL>len(subset_rev_i)))<EOL><DEDENT><DEDENT><DEDENT>return consistent_subset<EOL>
Find a flux consistent subnetwork containing the core subset.

    The result will contain the core subset and as few of the additional
    reactions as possible.

    Args:
        model: :class:`MetabolicModel` to solve.
        core: Set of core reaction IDs.
        epsilon: Flux threshold value.
        solver: LP solver instance to use.
        scaling: Scaling value to apply (see [Vlassis14]_ for more
            information on this parameter).
        weights: Dictionary with reaction IDs as keys and values as weights.
            Weights specify the cost of adding a reaction to the consistent
            subnetwork. Default value is 1.

    Returns:
        Set of reaction IDs in the consistent reaction subset.