8000 Merge pull request #240 from ahmedfgad/github-actions · madprog/GeneticAlgorithmPython@9137dd4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9137dd4

Browse files
authored
Merge pull request ahmedfgad#240 from ahmedfgad/github-actions
Merge pull request ahmedfgad#239 from ahmedfgad/master
2 parents 6429acc + b0051f8 commit 9137dd4

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

pygad/pygad.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,9 +1646,7 @@ 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-
undefined_pop_fitness = object()
1650-
1651-
pop_fitness = [undefined_pop_fitness] * len(self.population)
1649+
pop_fitness = ["undefined"] * len(self.population)
16521650
if self.parallel_processing is None:
16531651
# Calculating the fitness value of each solution in the current population.
16541652
for sol_idx, sol in enumerate(self.population):
@@ -1711,7 +1709,6 @@ def cal_pop_fitness(self):
17111709

17121710
# Indices of the solutions to calculate their fitness.
17131711
solutions_indices = [idx for idx, fit in enumerate(pop_fitness) if type(fit) is str and fit == "undefined"]
1714-
17151712
# Number of batches.
17161713
num_batches = int(numpy.ceil(len(solutions_indices) / self.fitness_batch_size))
17171714
# For each batch, get its indices and call the fitness function.
@@ -1789,7 +1786,7 @@ def cal_pop_fitness(self):
17891786
solutions_to_submit = []
17901787
for sol_idx, sol in enumerate(self.population):
17911788
# 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":
17931790
solutions_to_submit.append(sol.copy())
17941791
solutions_to_submit_indices.append(sol_idx)
17951792

0 commit comments

Comments
 (0)
0