@@ -1646,9 +1646,7 @@ def cal_pop_fitness(self):
1646
1646
last_generation_elitism_as_list = [
1647
1647
list (gen_elitism ) for gen_elitism in self .last_generation_elitism ]
1648
1648
1649
- undefined_pop_fitness = object ()
1650
-
1651
- pop_fitness = [undefined_pop_fitness ] * len (self .population )
1649
+ pop_fitness = ["undefined" ] * len (self .population )
1652
1650
if self .parallel_processing is None :
1653
1651
# Calculating the fitness value of each solution in the current population.
1654
1652
for sol_idx , sol in enumerate (self .population ):
@@ -1711,7 +1709,6 @@ def cal_pop_fitness(self):
1711
1709
1712
1710
# Indices of the solutions to calculate their fitness.
1713
1711
solutions_indices = [idx for idx , fit in enumerate (pop_fitness ) if type (fit ) is str and fit == "undefined" ]
1714
-
1715
1712
# Number of batches.
1716
1713
num_batches = int (numpy .ceil (len (solutions_indices ) / self .fitness_batch_size ))
1717
1714
# For each batch, get its indices and call the fitness function.
@@ -1789,7 +1786,7 @@ def cal_pop_fitness(self):
1789
1786
solutions_to_submit = []
1790
1787
for sol_idx , sol in enumerate (self .population ):
1791
1788
# The "undefined" value means that the fitness of this solution must be calculated.
1792
- if pop_fitness [sol_idx ] is undefined_pop_fitness :
1789
+ if pop_fitness [sol_idx ] == "undefined" :
1793
1790
solutions_to_submit .append (sol .copy ())
1794
1791
solutions_to_submit_indices .append (sol_idx )
1795
1792
0 commit comments