diff --git a/pygad/pygad.py b/pygad/pygad.py index e833732..d8664b2 100644 --- a/pygad/pygad.py +++ b/pygad/pygad.py @@ -1646,9 +1646,7 @@ def cal_pop_fitness(self): last_generation_elitism_as_list = [ list(gen_elitism) for gen_elitism in self.last_generation_elitism] - undefined_pop_fitness = object() - - pop_fitness = [undefined_pop_fitness] * len(self.population) + pop_fitness = ["undefined"] * len(self.population) if self.parallel_processing is None: # Calculating the fitness value of each solution in the current population. for sol_idx, sol in enumerate(self.population): @@ -1711,7 +1709,6 @@ def cal_pop_fitness(self): # Indices of the solutions to calculate their fitness. solutions_indices = [idx for idx, fit in enumerate(pop_fitness) if type(fit) is str and fit == "undefined"] - # Number of batches. num_batches = int(numpy.ceil(len(solutions_indices) / self.fitness_batch_size)) # For each batch, get its indices and call the fitness function. @@ -1789,7 +1786,7 @@ def cal_pop_fitness(self): solutions_to_submit = [] for sol_idx, sol in enumerate(self.population): # The "undefined" value means that the fitness of this solution must be calculated. - if pop_fitness[sol_idx] is undefined_pop_fitness: + if pop_fitness[sol_idx] == "undefined": solutions_to_submit.append(sol.copy()) solutions_to_submit_indices.append(sol_idx)