<s> from random import Random <EOL> from time import time <EOL> import inspyred <EOL> def main ( prng = None , display = False ) : <EOL> if prng is None : <EOL> prng = Random ( ) <EOL> prng . seed ( time ( ) ) <EOL> problem = inspyred . benchmarks . Kursawe ( <NUM_LIT:3> ) <EOL> ea = inspyred . ec . emo . NSGA2 ( prng ) <EOL> ea . variator = [ inspyred . ec . variators . blend_crossover , <EOL> inspyred . ec . variators . gaussian_mutation ] <EOL> ea . terminator = inspyred . ec . terminators . generation_termination <EOL> final_pop = ea . evolve ( generator = problem . generator , <EOL> evaluator = problem . evaluator , <EOL> pop_size = <NUM_LIT:100> , <EOL> maximize = problem . maximize , <EOL> bounder = problem . bounder , <EOL> max_generations = <NUM_LIT> ) <EOL> if display : <EOL> final_arc = ea . archive <EOL> print ( '<STR_LIT>' ) <EOL> for f in final_arc : <EOL> print ( f ) <EOL> import matplotlib . pyplot as plt <EOL> x = [ ] <EOL> y = [ ] <EOL> for f in final_arc : <EOL> x . append ( f . fitness [ <NUM_LIT:0> ] ) <EOL> y . append ( f . fitness [ <NUM_LIT:1> ] ) <EOL> plt . scatter ( x , y , color = '<STR_LIT:b>' ) <EOL> plt . savefig ( '<STR_LIT>' . format ( ea . __class__ . __name__ , <EOL> problem . __class__ . __name__ ) , <EOL> format = '<STR_LIT>' ) <EOL> plt . show ( ) <EOL> return ea <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( display = True ) </s>
