def benchmark_differential_evolution(): island = pg_island(algo=de(gen=10), prob=problem(rosenbrock(5)), size=10) N = 10 print('Differential Evolution (pop. size {})'.format( island.get_population().get_f().size)) for k in range(N): island.evolve() island.wait() d = sqrt( float(((island.get_population().champion_x - rosenbrock(5).best_known())**2).mean())) print('DE {:2}/{}: best fitness {:9.2f}, deviation {:9.2f}, fevals {}'. format(k, N, float(island.get_population().champion_f[0]), d, island.get_population().problem.get_fevals()))
def benchmark_simulated_annealing(): island = pg_island(algo=simulated_annealing(Ts=1., Tf=.01), prob=problem(rosenbrock(5)), size=10) N = 10 print('Simulated Annealing (pop. size {})'.format( island.get_population().get_f().size)) for k in range(N): island.evolve() island.wait() d = sqrt( float(((island.get_population().champion_x - rosenbrock(5).best_known())**2).mean())) print('SA {:2}/{}: best fitness {:9.2f}, deviation {:9.2f}, fevals {}'. format(k, N, float(island.get_population().champion_f[0]), d, island.get_population().problem.get_fevals()))
def benchmark_differential_evolution(generations): island = pg_island( algo=de(gen=generations), prob=B2_UDP(getLowerBound(),getUpperBound(),'../../../../../sbml/b2.xml'), size=10) N = 50 import arrow time_start = arrow.utcnow() print('Differential Evolution (pop. size {})'.format(island.get_population().get_f().size)) for k in range(N): island.evolve() island.wait() delta_t = arrow.utcnow() - time_start print('DE {:2}/{}: best fitness {:9.2f}, fevals {}, duration {}'.format( k,N,float(island.get_population().champion_f[0]), island.get_population().problem.get_fevals(), delta_t))
def benchmark_simulated_annealing(): island = pg_island( algo=simulated_annealing(Ts=1.,Tf=.01), prob=problem(B2_UDP(getLowerBound(),getUpperBound(),'../../../../../sbml/b2.xml')), size=10) N = 10 import arrow time_start = arrow.utcnow() print('Simulated Annealing (pop. size {})'.format(island.get_population().get_f().size)) for k in range(N): island.evolve() island.wait() delta_t = arrow.utcnow() - time_start print('SA {:2}/{}: best fitness {:9.2f}, fevals {}, duration {}'.format( k,N,float(island.get_population().champion_f[0]), island.get_population().problem.get_fevals(), delta_t))