Skip to content

Commit

Permalink
None solution index
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedfgad committed Aug 16, 2023
1 parent a3e1219 commit b84d062
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pygad/utils/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ def adaptive_mutation_population_fitness(self, offspring):
if self.fitness_batch_size in [1, None]:
# Calculate the fitness for each individual solution.
for idx in range(first_idx, last_idx):
# We cannot return the index of the solution within the population.
# Because the new solution (offspring) does not yet exist in the population.
# The user should handle this situation if the solution index is used anywhere.
fitness[idx] = self.fitness_func(self,
temp_population[idx],
None)
Expand All @@ -495,6 +498,9 @@ def adaptive_mutation_population_fitness(self, offspring):
batch_last_index = first_idx + (batch_idx + 1) * self.fitness_batch_size

# Calculate the fitness values for the batch.
# We cannot return the index/indices of the solution(s) within the population.
# Because the new solution(s) (offspring) do(es) not yet exist in the population.
# The user should handle this situation if the solution index is used anywhere.
fitness_temp = self.fitness_func(self,
temp_population[batch_first_index:batch_last_index],
None)
Expand Down

0 comments on commit b84d062

Please sign in to comment.