Added decorator file and fixed old crossover usage in adapt method

This commit is contained in:
SimpleArt
2021-01-01 16:11:14 -05:00
parent b2b1775e16
commit 94793b1b05
2 changed files with 25 additions and 33 deletions

View File

@ -122,7 +122,16 @@ class Population:
population[index] = chromosome
to set the indexed chromosome.
"""
self.chromosome_list[index] = to_chromosome(chromosome)
# Just one chromosome
if isinstance(index, int):
chromosome = to_chromosome(chromosome)
# Multiple chromosomes
else:
chromosome = [to_chromosome(elem) for elem in chromosome]
self.chromosome_list[index] = chromosome
def __delitem__(self, index):