def make_new_evolution(name, confusion, mask): print('Making new evolution') evolution = Evolution(confusion, mask) evolution.run_tests() ranked_preys = evolution.rank_preys() ranked_predators = evolution.rank_predators() evolution.update_pools(ranked_predators, ranked_preys) evolution.save(name) return evolution
if showViz: FitnessGraph = Viz.createGraph() Viz.labelGraph(FitnessGraph, "FitnessGraph") Viz.legendGraph(FitnessGraph, "Max Fitness", c="red") Viz.setStruts(num_bars) #smaller stru ts, less play but faster convergence..... GA = Evolution(num_struts = num_bars, strut_length = 10, max_gen=1000,init_size =population, pop_size=population, mutation_rate=m_rate, \ selection_rate = s_rate, selection_pressure = s_pressure,elite_rate=e_rate) #Essentailly just have an autmated hill climber rn, b/c mutation rate is so highself. GA.load(load) GA.eps = 1 while GA.alive(): if GA.current_gen % 25 == 0: GA.save(population) print("----------------------") print("Curr Gen: ", GA.current_gen) print("Pop Sicze", len(GA.pop)) for i in np.arange(len(GA.pop)): drone_structure = GA.pop[i][2] # loop through current population Solver.solve(drone_structure, i) # drones have already been solved so they go very fast fit = GA.fitness(drone_structure) # evaluate drone drone_structure.fitness = fit # update fitness GA.addToQueue(drone_structure, fit) # add drone the the queue GA.niche(niche_radius) GA.rankQueue() if showViz: