def _action_set_subsumption(self, action_set):
<EOL>selected_rule = None<EOL>selected_bit_count = None<EOL>for rule in action_set:<EOL><INDENT>if not (rule.experience > self.subsumption_threshold and<EOL>rule.error < self.error_threshold):<EOL><INDENT>continue<EOL><DEDENT>bit_count = rule.condition.count()<EOL>if (selected_rule is None or<EOL>bit_count > selected_bit_count or<EOL>(bit_count == selected_bit_count and<EOL>random.randrange(<NUM_LIT:2>))):<EOL><INDENT>selected_rule = rule<EOL>selected_bit_count = bit_count<EOL><DEDENT><DEDENT>if selected_rule is None:<EOL><INDENT>return<EOL><DEDENT>to_remove = []<EOL>for rule in action_set:<EOL><INDENT>if (selected_rule is not rule and<EOL>selected_rule.condition(rule.condition)):<EOL><INDENT>selected_rule.numerosity += rule.numerosity<EOL>action_set.model.discard(rule, rule.numerosity)<EOL>to_remove.append(rule)<EOL><DEDENT><DEDENT>for rule in to_remove:<EOL><INDENT>action_set.remove(rule)<EOL><DEDENT>
Perform action set subsumption.