#NEWLINE# def my_terminator( population , num_generations , num_evaluations , args ) : #NEWLINE# #INDENT# min_ham_dist = args . get ( 'minimum_hamming_distance' , 30 ) #NEWLINE# ham_dist = [ ] #NEWLINE# for ( x , y ) in itertools . combinations ( population , 2 ) : #NEWLINE# #INDENT# ham_dist . append ( sum ( ( ( a != b ) for ( a , b ) in zip ( x . candidate , y . candidate ) ) ) ) #NEWLINE# #UNINDENT# avg_ham_dist = ( sum ( avg_ham_dist ) / float ( len ( ham_dist ) ) ) #NEWLINE# return ( avg_ham_dist <= min_ham_dist )