#NEWLINE# def _internal_evaluator( self , candidates , args ) : #NEWLINE# #INDENT# the_generator = args . get ( 'the_generator' ) #NEWLINE# the_evaluator = args . get ( 'the_evaluator' ) #NEWLINE# do_maximize = args . get ( 'do_maximize' , True ) #NEWLINE# fitness = [ ] #NEWLINE# for candidate in candidates : #NEWLINE# #INDENT# ( popsize , selector , replacer , crossover , mutator , myargs ) = self . interpret_candidate ( candidate ) #NEWLINE# myargs [ 'max_evaluations' ] = args . get ( 'num_trial_evaluations' , ( popsize * 10 ) ) #NEWLINE# num_trials = args . get ( 'num_trials' , 1 ) #NEWLINE# evo = ec . EvolutionaryComputation ( self . _random ) #NEWLINE# evo . terminator = self . _internal_terminator #NEWLINE# evo . observer = self . _internal_observer #NEWLINE# evo . selector = selector #NEWLINE# evo . variator = [ crossover , mutator ] #NEWLINE# evo . replacer = replacer #NEWLINE# best_fit = [ ] #NEWLINE# for i in range ( num_trials ) : #NEWLINE# #INDENT# final_pop = evo . evolve ( generator = the_generator , evaluator = the_evaluator , pop_size = popsize , maximize = do_maximize , args = myargs ) #NEWLINE# best_fit . append ( final_pop [ 0 ] . fitness ) #NEWLINE# #UNINDENT# fitness . append ( ( sum ( best_fit ) / float ( len ( best_fit ) ) ) ) #NEWLINE# #UNINDENT# return fitness