Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7fda9da

Browse files
Merge pull request #239 from ahmedfgad/master
Solve multi-objective optimization bugs
2 parents 03f509f + 6429acc commit 7fda9da

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎pygad/pygad.py‎

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

17101712
# Indices of the solutions to calculate their fitness.
17111713
solutions_indices = [idx for idx, fit in enumerate(pop_fitness) if type(fit) is str and fit == "undefined"]
1714+
17121715
# Number of batches.
17131716
num_batches = int(numpy.ceil(len(solutions_indices) / self.fitness_batch_size))
17141717
# For each batch, get its indices and call the fitness function.
@@ -1786,7 +1789,7 @@ def cal_pop_fitness(self):
17861789
solutions_to_submit = []
17871790
for sol_idx, sol in enumerate(self.population):
17881791
# The "undefined" value means that the fitness of this solution must be calculated.
1789-
if pop_fitness[sol_idx] =="undefined":
1792+
if pop_fitness[sol_idx] isundefined_pop_fitness:
17901793
solutions_to_submit.append(sol.copy())
17911794
solutions_to_submit_indices.append(sol_idx)
17921795

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /