def run(self, scenario, learn=True):
assert isinstance(scenario, scenarios.Scenario)<EOL>previous_match_set = None<EOL>while scenario.more():<EOL><INDENT>situation = scenario.sense()<EOL>match_set = self.match(situation)<EOL>match_set.select_action()<EOL>reward = scenario.execute(match_set.selected_action)<EOL>if learn:<EOL><INDENT>assert reward is not None<EOL>if scenario.is_dynamic:<EOL><INDENT>if previous_match_set is not None:<EOL><INDENT>match_set.pay(previous_match_set)<EOL>previous_match_set.apply_payoff()<EOL><DEDENT>match_set.payoff = reward<EOL>previous_match_set = match_set<EOL><DEDENT>else:<EOL><INDENT>match_set.payoff = reward<EOL>match_set.apply_payoff()<EOL><DEDENT><DEDENT><DEDENT>if learn and previous_match_set is not None:<EOL><INDENT>previous_match_set.apply_payoff()<EOL><DEDENT>
Run the algorithm, utilizing the classifier set to choose the
        most appropriate action for each situation produced by the
        scenario. If learn is True, improve the situation/action mapping to
        maximize reward. Otherwise, ignore any reward received.

        Usage:
            model.run(scenario, learn=True)

        Arguments:
            scenario: A Scenario instance which this classifier set is to
                interact with.
            learn: A bool indicating whether the classifier set should
                attempt to optimize its performance based on reward
                received for each action, as opposed to simply using what
                it has already learned from previous runs and ignoring
                reward received; default is True.
        Return: None