def test_write_and_read_geneme(self): filename = self.path + '/genome_test.json' genome = Genome(key=0) genome.create_random_genome() genome.save_genome(filename) genome_read = Genome.create_from_file(filename) self.assertEqual(len(genome.__dict__), len(genome_read.__dict__))
def initialize_population(self): population = {} for i in range(self.pop_size): key = next(self.genome_indexer) if self.config.initial_genome_filename is None: genome = Genome(key=key) genome.create_random_genome() else: filename = self.config.initial_genome_filename genome = Genome.create_from_file(filename=filename, key=key) population[key] = genome self.ancestors[key] = tuple() return population