def test_should_find_subsumer_among_nonsubsumers(self, acs2_cfg): # given subsumer = acs2.Classifier(condition='###0####', action=3, effect='##1#####', quality=0.93, reward=1.35, experience=23, cfg=acs2_cfg) nonsubsumer = acs2.Classifier(action=3, cfg=acs2_cfg) cl = acs2.Classifier(condition='1##0####', action=3, effect='##1#####', quality=0.5, reward=0.35, experience=1, cfg=acs2_cfg) population = acs2.ClassifiersList( *[nonsubsumer, subsumer, nonsubsumer]) # when subsumers = find_subsumers(cl, population, acs2_cfg.theta_exp) # then assert len(subsumers) == 1 assert subsumers[0] == subsumer
def test_should_find_most_general_subsumer(self, acs2_cfg): # given subsumer1 = acs2.Classifier(condition='1##0####', action=3, effect='##1#####', quality=0.93, reward=1.35, experience=23, cfg=acs2_cfg) subsumer2 = acs2.Classifier(condition='#1#0####', action=3, effect='##1#####', quality=0.93, reward=1.35, experience=23, cfg=acs2_cfg) most_general = acs2.Classifier(condition='###0####', action=3, effect='##1#####', quality=0.93, reward=1.35, experience=23, cfg=acs2_cfg) nonsubsumer = acs2.Classifier(cfg=acs2_cfg) cl = acs2.Classifier(condition='11#0####', action=3, effect='##1#####', quality=0.5, reward=0.35, experience=1, cfg=acs2_cfg) population = acs2.ClassifiersList(*[ nonsubsumer, subsumer1, nonsubsumer, most_general, subsumer2, nonsubsumer ]) # when subsumers = find_subsumers(cl, population, acs2_cfg.theta_exp) # then assert subsumers[0] == most_general
def _find_old_classifier(population, cl, use_subsumption: bool, theta_exp: int): old_cl = None if use_subsumption: subsumers = find_subsumers(cl, population, theta_exp) # Try to find most general subsumer try: old_cl = subsumers[0] except IndexError: pass # If there is no subsumer - look for similar classifiers if old_cl is None: old_cl = _find_similar(cl, population) return old_cl