@@ -1646,7 +1646,9 @@ def cal_pop_fitness(self):
16461646 last_generation_elitism_as_list = [
16471647 list (gen_elitism ) for gen_elitism in self .last_generation_elitism ]
16481648
1649- pop_fitness = ["undefined" ] * len (self .population )
1649+ undefined_pop_fitness = object ()
1650+
1651+ pop_fitness = [undefined_pop_fitness ] * len (self .population )
16501652 if self .parallel_processing is None :
16511653 # Calculating the fitness value of each solution in the current population.
16521654 for sol_idx , sol in enumerate (self .population ):
@@ -1709,6 +1711,7 @@ def cal_pop_fitness(self):
17091711
17101712 # Indices of the solutions to calculate their fitness.
17111713 solutions_indices = [idx for idx , fit in enumerate (pop_fitness ) if type (fit ) is str and fit == "undefined" ]
1714+
17121715 # Number of batches.
17131716 num_batches = int (numpy .ceil (len (solutions_indices ) / self .fitness_batch_size ))
17141717 # For each batch, get its indices and call the fitness function.
@@ -1786,7 +1789,7 @@ def cal_pop_fitness(self):
17861789 solutions_to_submit = []
17871790 for sol_idx , sol in enumerate (self .population ):
17881791 # The "undefined" value means that the fitness of this solution must be calculated.
1789- if pop_fitness [sol_idx ] == "undefined" :
1792+ if pop_fitness [sol_idx ] is undefined_pop_fitness :
17901793 solutions_to_submit .append (sol .copy ())
17911794 solutions_to_submit_indices .append (sol_idx )
17921795
0 commit comments