From 58a2ecbcb31a9a4dddaa2a2687c790967e1b0293 Mon Sep 17 00:00:00 2001 From: Ahmed Gad Date: Tue, 7 Jan 2025 13:11:11 -0500 Subject: [PATCH] Remove the delay_after_gen parameter --- pygad/pygad.py | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/pygad/pygad.py b/pygad/pygad.py index beb0a4d..bedca73 100644 --- a/pygad/pygad.py +++ b/pygad/pygad.py @@ -1,7 +1,6 @@ import numpy import random import cloudpickle -import time import warnings import concurrent.futures import inspect @@ -58,7 +57,6 @@ def __init__(self, on_mutation=None, on_generation=None, on_stop=None, - delay_after_gen=0.0, save_best_solutions=False, save_solutions=False, suppress_warnings=False, @@ -114,8 +112,6 @@ def __init__(self, on_generation: Accepts a function/method to be called after each generation. If function, then it must accept a single parameter representing the instance of the genetic algorithm. If the function returned "stop", then the run() method stops without completing the other generations. If method, then it must accept 2 parameters where the second one refers to the method's object. Added in PyGAD 2.6.0. on_stop: Accepts a function/method to be called only once exactly before the genetic algorithm stops or when it completes all the generations. If function, then it must accept 2 parameters: the first one represents the instance of the genetic algorithm and the second one is a list of fitness values of the last population's solutions. If method, then it must accept 3 parameters where the third one refers to the method's object. Added in PyGAD 2.6.0. - delay_after_gen: Added in PyGAD 2.4.0 and deprecated in PyGAD 3.3.0. It accepts a non-negative number specifying the number of seconds to wait after a generation completes and before going to the next generation. It defaults to 0.0 which means no delay after the generation. - save_best_solutions: Added in PyGAD 2.9.0 and its type is bool. If True, then the best solution in each generation is saved into the 'best_solutions' attribute. Use this parameter with caution as it may cause memory overflow when either the number of generations or the number of genes is large. save_solutions: Added in PyGAD 2.15.0 and its type is bool. If True, then all solutions in each generation are saved into the 'solutions' attribute. Use this parameter with caution as it may cause memory overflow when either the number of generations, number of genes, or number of solutions in population is large. @@ -1133,19 +1129,6 @@ def __init__(self, else: self.on_stop = None - # Validate delay_after_gen - if type(delay_after_gen) in GA.supported_int_float_types: - if not self.suppress_warnings: - warnings.warn("The 'delay_after_gen' parameter is deprecated starting from PyGAD 3.3.0. To delay or pause the evolution after each generation, assign a callback function/method to the 'on_generation' parameter to adds some time delay.") - if delay_after_gen >= 0.0: - self.delay_after_gen = delay_after_gen - else: - self.valid_parameters = False - raise ValueError(f"The value passed to the 'delay_after_gen' parameter must be a non-negative number. The value passed is ({delay_after_gen}) of type {type(delay_after_gen)}.") - else: - self.valid_parameters = False - raise TypeError(f"The value passed to the 'delay_after_gen' parameter must be of type int or float but {type(delay_after_gen)} found.") - # Validate save_best_solutions if type(save_best_solutions) is bool: if save_best_solutions == True: @@ -2064,8 +2047,6 @@ def run(self): if stop_run: break - time.sleep(self.delay_after_gen) - # Save the fitness of the last generation. if self.save_solutions: # self.solutions.extend(self.population.copy()) @@ -2535,11 +2516,6 @@ def print_params_summary(): if not print_step_parameters: print_mutation_params() - if self.delay_after_gen != 0: - m = f"Post-Generation Delay: {self.delay_after_gen}" - self.logger.info(m) - summary_output = summary_output + m + "\n" - if not print_step_parameters: print_on_generation_params()