#NEWLINE# def setup_cache( self ) : #NEWLINE# #INDENT# if ( not self . enabled ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# numtrials = 100 #NEWLINE# results = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# solvers = [ 'DE' , 'basinh.' ] #NEWLINE# for ( name , klass ) in sorted ( self . _functions . items ( ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# f = klass ( ) #NEWLINE# b = _BenchOptimizers . from_funcobj ( name , numtrials ) #NEWLINE# with np . errstate ( all = 'ignore' ) : #NEWLINE# #INDENT# b . bench_run_global ( methods = solvers , numtrials = numtrials ) #NEWLINE# #UNINDENT# results [ name ] = b . average_results ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# results [ name ] = '\n' . join ( traceback . format_exc ( ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# dump_fn = os . path . join ( os . path . dirname ( __file__ ) , '..' , 'global-bench-results.json' ) #NEWLINE# with open ( dump_fn , 'w' ) as f : #NEWLINE# #INDENT# json . dump ( results , f , indent = 2 , sort_keys = True ) #NEWLINE# #UNINDENT# #UNINDENT# return results