Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedfgad authored Nov 2, 2023
1 parent 7fda9da commit b0051f8
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pygad/pygad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit b0051f8

Please sign in to comment.