Skip to content

Commit 0e8a425

Browse files
authored
PyGAD 2.18.1
A big fix when `keep_elitism` is used. #132
1 parent 16c5ad9 commit 0e8a425

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from .pygad import * # Relative import.
22

3-
__version__ = "2.18.0"
3+
__version__ = "2.18.1"

pygad.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1398,12 +1398,7 @@ def run(self):
13981398
self.population[0:parents_to_keep.shape[0], :] = parents_to_keep
13991399
self.population[parents_to_keep.shape[0]:, :] = self.last_generation_offspring_mutation
14001400
else:
1401-
# If the keep_elitism parameter has a value other than 0, then it will decide the number of elitism to keep in the next generation.
1402-
if self.last_generation_elitism is None:
1403-
self.last_generation_elitism, _ = self.steady_state_selection(self.last_generation_fitness, num_parents=self.keep_elitism)
1404-
else:
1405-
# The elitism are already returned into the last_generation_elitism attribute if crossover_type=None. In this case, the steady_state_selection() method was already called.
1406-
pass
1401+
self.last_generation_elitism, _ = self.steady_state_selection(self.last_generation_fitness, num_parents=self.keep_elitism)
14071402
self.population[0:self.last_generation_elitism.shape[0], :] = self.last_generation_elitism
14081403
self.population[self.last_generation_elitism.shape[0]:, :] = self.last_generation_offspring_mutation
14091404

0 commit comments

Comments
 (0)