#NEWLINE# def main( prng = None , display = False ) : #NEWLINE# #INDENT# if ( prng is None ) : #NEWLINE# #INDENT# prng = Random ( ) #NEWLINE# prng . seed ( time ( ) ) #NEWLINE# #UNINDENT# problem = inspyred . benchmarks . Kursawe ( 3 ) #NEWLINE# ea = inspyred . ec . emo . PAES ( prng ) #NEWLINE# ea . terminator = inspyred . ec . terminators . evaluation_termination #NEWLINE# final_pop = ea . evolve ( generator = problem . generator , evaluator = problem . evaluator , bounder = problem . bounder , maximize = problem . maximize , max_evaluations = 10000 , max_archive_size = 100 , num_grid_divisions = 4 ) #NEWLINE# if display : #NEWLINE# #INDENT# final_arc = ea . archive #NEWLINE# print ( 'Best Solutions: \n' ) #NEWLINE# for f in final_arc : #NEWLINE# #INDENT# print ( f ) #NEWLINE# #UNINDENT# import matplotlib.pyplot as plt #NEWLINE# x = [ ] #NEWLINE# y = [ ] #NEWLINE# for f in ea : #NEWLINE# #INDENT# x . append ( f . fitness [ 0 ] ) #NEWLINE# y . append ( f . fitness [ 1 ] ) #NEWLINE# #UNINDENT# plt . scatter ( x , y , color = 'b' ) #NEWLINE# plt . savefig ( '{0} Example ({1}).pdf' . format ( ea . __class__ . __name__ , problem . __class__ . __name__ ) , format = 'pdf' ) #NEWLINE# plt . show ( ) #NEWLINE# #UNINDENT# return ea