Skip to content

Commit 58a2ecb

Browse files
committed
Remove the delay_after_gen parameter
1 parent 84559ce commit 58a2ecb

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

pygad/pygad.py

-24
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import numpy
22
import random
33
import cloudpickle
4-
import time
54
import warnings
65
import concurrent.futures
76
import inspect
@@ -58,7 +57,6 @@ def __init__(self,
5857
on_mutation=None,
5958
on_generation=None,
6059
on_stop=None,
61-
delay_after_gen=0.0,
6260
save_best_solutions=False,
6361
save_solutions=False,
6462
suppress_warnings=False,
@@ -114,8 +112,6 @@ def __init__(self,
114112
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.
115113
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.
116114
117-
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.
118-
119115
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.
120116
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.
121117
@@ -1133,19 +1129,6 @@ def __init__(self,
11331129
else:
11341130
self.on_stop = None
11351131

1136-
# Validate delay_after_gen
1137-
if type(delay_after_gen) in GA.supported_int_float_types:
1138-
if not self.suppress_warnings:
1139-
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.")
1140-
if delay_after_gen >= 0.0:
1141-
self.delay_after_gen = delay_after_gen
1142-
else:
1143-
self.valid_parameters = False
1144-
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)}.")
1145-
else:
1146-
self.valid_parameters = False
1147-
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.")
1148-
11491132
# Validate save_best_solutions
11501133
if type(save_best_solutions) is bool:
11511134
if save_best_solutions == True:
@@ -2064,8 +2047,6 @@ def run(self):
20642047
if stop_run:
20652048
break
20662049

2067-
time.sleep(self.delay_after_gen)
2068-
20692050
# Save the fitness of the last generation.
20702051
if self.save_solutions:
20712052
# self.solutions.extend(self.population.copy())
@@ -2535,11 +2516,6 @@ def print_params_summary():
25352516
if not print_step_parameters:
25362517
print_mutation_params()
25372518

2538-
if self.delay_after_gen != 0:
2539-
m = f"Post-Generation Delay: {self.delay_after_gen}"
2540-
self.logger.info(m)
2541-
summary_output = summary_output + m + "\n"
2542-
25432519
if not print_step_parameters:
25442520
print_on_generation_params()
25452521

0 commit comments

Comments
 (0)