Пример #1
0
 def create(crowding_factor, crowding_size, elitism_size, starting_symbol, universal_symbol,
            max_non_terminal_symbols, random_starting_population_size, max_non_terminal_rules):
     configuration = RuleConfiguration()
     configuration.adding = AddingRulesConfiguration.create(
         crowding_factor, crowding_size, elitism_size, max_non_terminal_rules)
     configuration.starting_symbol = Symbol(starting_symbol)
     configuration.universal_symbol = Symbol(universal_symbol) if universal_symbol else None
     configuration.max_non_terminal_symbols = max_non_terminal_symbols
     configuration.random_starting_population_size = random_starting_population_size
     return configuration
Пример #2
0
    def create_rule_adding(self):
        configuration = AddingRulesConfiguration.create(
            crowding_factor=2,
            crowding_size=3,
            elitism_size=2,
            max_non_terminal_rules=19
        )

        adding_strategies = [SimpleAddingRuleStrategy(),
                             AddingRuleWithCrowdingStrategy(),
                             AddingRuleWithElitismStrategy()]

        self.rule_adding = AddingRuleSupervisor(self.randomizer, configuration, adding_strategies)