def debug_generation(self): self.hall_of_fame.update(self.population) record = self.stats.compile(self.population) if self.stats else {} self.logbook.record(gen=self.generation, nevals=self.new_individuals_in_generation, **record) self.logger.info(self.logbook.stream) best_hypothesis_str = hypothesis_to_string(self.hall_of_fame[0]) record.update({ 'generation': self.generation, 'best_hypothesis': best_hypothesis_str }) self.logger.log_stats_record(record, self.island_number) if self.generation > 0 and self.generation % ga_config.CLEAR_RULE_SET_CACHE_INTERVAL == 0: RuleSet.clear_caching() if ga_config.DUMP_ALL_POPULATION_EVERY_N_GENERATIONS > 0 and self.generation % ga_config.DUMP_ALL_POPULATION_EVERY_N_GENERATIONS == 0 and self.generation > 0: self.dump_population() if self.generation % ga_config.HALL_OF_FAME_DEBUG_INTERVAL == 0: self.logger.debug('\n\n**** {} top {} hypothesis:****\n'.format( self.island_name, ga_config.HALL_OF_FAME_HYPOTHESES)) for i in range(ga_config.HALL_OF_FAME_HYPOTHESES): try: hypo = self.hall_of_fame[i] self.logger.debug('** #{} **'.format(i + 1)) log_hypothesis(hypo, self.logger.debug) self.logger.debug('\n') except IndexError: break
def debug_generation(self): self.hall_of_fame.update(self.population) record = self.stats.compile(self.population) if self.stats else {} self.logbook.record(gen=self.generation, nevals=self.new_individuals_in_generation, **record) self.logger.info(self.logbook.stream) best_hypothesis_str = hypothesis_to_string(self.hall_of_fame[0]) record.update({ 'generation': self.generation, 'best_hypothesis': best_hypothesis_str }) self.logger.log_stats_record(record, self.island_number) if self.generation != self.initial_generation and self.generation % ga_config.DUMP_POPULATION_INTERVAL == 0: self.dump_population() if self.generation > 0 and self.generation % ga_config.CLEAR_KEY_VALUE_CACHE_INTERVAL == 0: self.cache.flush() if self.generation > 0 and self.generation % ga_config.CLEAR_TRANSDUCERS_CACHE_INTERVAL == 0: from bracket_rule_transducer import BracketRuleTransducer self.logger.info("Clearing rule set cache...") RuleSet.clear_caching() self.logger.info("Clearing bracket rule transducers cache...") BracketRuleTransducer.clear_caching() if ga_config.LOG_POPULATION_INTERVAL > 0 and self.generation % ga_config.LOG_POPULATION_INTERVAL == 0 and self.generation > 0: self.log_all_population() if self.generation % ga_config.HALL_OF_FAME_DEBUG_INTERVAL == 0: self.logger.debug('\n\n**** {} top {} hypothesis:****\n'.format( self.island_name, ga_config.HALL_OF_FAME_HYPOTHESES)) for i in range(ga_config.HALL_OF_FAME_HYPOTHESES): try: hypo = self.hall_of_fame[i] self.logger.debug('** #{} **'.format(i + 1)) log_hypothesis(hypo, self.logger.debug) self.logger.debug('\n') except IndexError: break
def _clear_modules_caching(self): from bracket_rule_transducer import BracketRuleTransducer BracketRuleTransducer.clear_caching() RuleSet.clear_caching()