def _populate_solver(self, reaction_list, metabolite_list=None):
constraint_terms = AutoVivification()<EOL>to_add = []<EOL>if metabolite_list is not None:<EOL><INDENT>for met in metabolite_list:<EOL><INDENT>to_add += [self.problem.Constraint(<EOL>Zero, name=met.id, lb=<NUM_LIT:0>, ub=<NUM_LIT:0>)]<EOL><DEDENT><DEDENT>self.add_cons_vars(to_add)<EOL>for reaction in reaction_list:<EOL><INDENT>if reaction.id not in self.variables:<EOL><INDENT>forward_variable = self.problem.Variable(reaction.id)<EOL>reverse_variable = self.problem.Variable(reaction.reverse_id)<EOL>self.add_cons_vars([forward_variable, reverse_variable])<EOL><DEDENT>else:<EOL><INDENT>reaction = self.reactions.get_by_id(reaction.id)<EOL>forward_variable = reaction.forward_variable<EOL>reverse_variable = reaction.reverse_variable<EOL><DEDENT>for metabolite, coeff in six.iteritems(reaction.metabolites):<EOL><INDENT>if metabolite.id in self.constraints:<EOL><INDENT>constraint = self.constraints[metabolite.id]<EOL><DEDENT>else:<EOL><INDENT>constraint = self.problem.Constraint(<EOL>Zero,<EOL>name=metabolite.id,<EOL>lb=<NUM_LIT:0>, ub=<NUM_LIT:0>)<EOL>self.add_cons_vars(constraint, sloppy=True)<EOL><DEDENT>constraint_terms[constraint][forward_variable] = coeff<EOL>constraint_terms[constraint][reverse_variable] = -coeff<EOL><DEDENT><DEDENT>self.solver.update()<EOL>for reaction in reaction_list:<EOL><INDENT>reaction = self.reactions.get_by_id(reaction.id)<EOL>reaction.update_variable_bounds()<EOL><DEDENT>for constraint, terms in six.iteritems(constraint_terms):<EOL><INDENT>constraint.set_linear_coefficients(terms)<EOL><DEDENT>
Populate attached solver with constraints and variables that
        model the provided reactions.