Changed implementation framework

Instead of a nested approach, selection/crossover/mutation are all called separately and directly by the GA. selection_impl was also separated into parent_selection_impl and survivor_selection_impl, as both are needed separately.
This commit is contained in:
RyleyGG
2020-10-04 17:59:59 -04:00
parent c18a531034
commit e05aa7f62b
5 changed files with 102 additions and 120 deletions

View File

@ -30,8 +30,10 @@ class Population:
def set_all_chromosomes(self, chromosomes):
self.chromosomes = chromosomes
def set_chromosome(self, chromosomes, index):
self.chromosome[index] = chromosome
def set_chromosome(self, chromosome, index = -1):
if index == -1:
index = len(self.chromosomes)-1
self.chromosomes[index] = chromosome
def set_fitness(self, fitness):
self.fitness = fitness