math.cos(x1) + 10.) def f3() # TEST NUM. 1 -- f1(x) g = GA(10, 10, p_mut, p_xover, l_dna) b_gene = "" b_fitness = 999999 g.init_population() for _ in range(g.n_gen): decimals = [g.in_context(-2., 2., g.to_decimal(g.population[i]), l_dna) for i in range(g.n_pop)] scores = [f1(x) for x in decimals] for i, gene in enumerate(g.population): if scores[i] < b_fitness: b_fitness = scores[i] b_gene = gene children = [] for i in range(g.n_pop / 2): p1 = g.t_selection(scores) p2 = g.t_selection(scores)