2626
2727logger = logging .getLogger ('__main__' )
2828
29+ def isclose (a , b , rel_tol = 1e-09 , abs_tol = 0.0 ):
30+ return abs (a - b ) <= max (rel_tol * max (abs (a ), abs (b )), abs_tol )
31+
2932
3033class MaxNGen (bluepyopt .stoppingCriteria .StoppingCriteria ):
3134 """Max ngen stopping criteria class"""
@@ -39,7 +42,6 @@ def __init__(self, max_ngen):
3942 def check (self , kwargs ):
4043 """Check if the maximum number of iteration is reached"""
4144 gen = kwargs .get ("gen" )
42-
4345 if gen > self .max_ngen :
4446 self .criteria_met = True
4547
@@ -61,7 +63,7 @@ def __init__(self, lambda_, problem_size):
6163
6264 def check (self , kwargs ):
6365 """Check if the population stopped improving"""
64- ngen = kwargs .get ("ngen " )
66+ ngen = kwargs .get ("gen " )
6567 population = kwargs .get ("population" )
6668 fitness = [ind .fitness .reduce for ind in population ]
6769 fitness .sort ()
@@ -117,7 +119,7 @@ def __init__(self, lambda_, problem_size):
117119 def check (self , kwargs ):
118120 """Check if in 1/3rd of the last problem_size iterations the best and
119121 k'th best solutions are equal"""
120- ngen = kwargs .get ("ngen " )
122+ ngen = kwargs .get ("gen " )
121123 population = kwargs .get ("population" )
122124
123125 fitness = [ind .fitness .reduce for ind in population ]
@@ -201,7 +203,7 @@ def __init__(self, problem_size):
201203
202204 def check (self , kwargs ):
203205 """Check if the coordinate axis std is too low"""
204- ngen = kwargs .get ("ngen " )
206+ ngen = kwargs .get ("gen " )
205207 centroid = kwargs .get ("centroid" )
206208 sigma = kwargs .get ("sigma" )
207209 diagD = kwargs .get ("diagD" )
0 commit comments