diff --git a/Solid/EvolutionaryAlgorithm.py b/Solid/EvolutionaryAlgorithm.py index bdedd72..d077de8 100644 --- a/Solid/EvolutionaryAlgorithm.py +++ b/Solid/EvolutionaryAlgorithm.py @@ -132,7 +132,7 @@ def _select_n(self, n): shuffle(self.population) total_fitness = sum(self.fitnesses) if total_fitness != 0: - probs = list([self._fitness(x) / total_fitness for x in self.population]) + probs = list([self.fitnesses[i] / total_fitness for i in range(len(self.population))]) else: return self.population[0:n] res = [] diff --git a/Solid/GeneticAlgorithm.py b/Solid/GeneticAlgorithm.py index 01affd2..16c5f30 100644 --- a/Solid/GeneticAlgorithm.py +++ b/Solid/GeneticAlgorithm.py @@ -133,7 +133,7 @@ def _select_n(self, n): shuffle(self.population) total_fitness = sum(self.fitnesses) if total_fitness != 0: - probs = list([self._fitness(x) / total_fitness for x in self.population]) + probs = list([self.fitnesses[i] / total_fitness for i in range(len(self.population))]) else: return self.population[0:n] res = []