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