You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PyGAD 2.16.2
1. A new instance attribute called `previous_generation_fitness` added in the `pygad.GA` class. It holds the fitness values of one generation before the fitness values saved in the `last_generation_fitness`.
2. Issue in the `cal_pop_fitness()` method in getting the correct indices of the previous parents. This is solved by using the previous generation's fitness saved in the new attribute `previous_generation_fitness` to return the parents' fitness values. Thanks to Tobias Tischhauser (M.Sc. - [Mitarbeiter Institut EMS, Departement Technik, OST – Ostschweizer Fachhochschule, Switzerland](https://www.ost.ch/de/forschung-und-dienstleistungen/technik/systemtechnik/ems/team)) for detecting this bug.
PyGAD 2.16.3
1. Validate the fitness value returned from the fitness function. An exception is raised if something is wrong. #67
Copy file name to clipboardExpand all lines: pygad.py
+10-3
Original file line number
Diff line number
Diff line change
@@ -899,6 +899,7 @@ def __init__(self,
899
899
self.last_generation_parents=None# A list holding the parents of the last generation.
900
900
self.last_generation_offspring_crossover=None# A list holding the offspring after applying crossover in the last generation.
901
901
self.last_generation_offspring_mutation=None# A list holding the offspring after applying mutation in the last generation.
902
+
self.previous_generation_fitness=None# Holds the fitness values of one generation before the fitness values saved in the last_generation_fitness attribute. Added in PyGAD 2.26.2
# Check if this solution is a parent from the previous generation and its fitness value is already calculated. If so, use the fitness value instead of calling the fitness function.
1151
+
if (self.last_generation_parentsisnotNone) andlen(numpy.where(numpy.all(self.last_generation_parents==sol, axis=1))[0] >0):
1151
1152
# Index of the parent in the parents array (self.last_generation_parents). This is not its index within the population.
raiseValueError("The fitness function should return a number but the value {fit_val} of type {fit_type} found.".format(fit_val=fitness, fit_type=type(fitness)))
0 commit comments