Skip to content

Instantly share code, notes, and snippets.

@rocreguant
Created January 31, 2021 16:24
Show Gist options
  • Save rocreguant/b4fa8ef573dbb63c2072a0d86804cf2d to your computer and use it in GitHub Desktop.
Save rocreguant/b4fa8ef573dbb63c2072a0d86804cf2d to your computer and use it in GitHub Desktop.
# Everything put together
best_solution = [-1,np.inf,np.array([])]
for i in range(100000):
if i%100==0: print(i, fitnes_list.min(), fitnes_list.mean(), datetime.now().strftime("%d/%m/%y %H:%M"))
fitnes_list = get_all_fitnes(mutated_pop,cities_dict)
#Saving the best solution
if fitnes_list.min() < best_solution[1]:
best_solution[0] = i
best_solution[1] = fitnes_list.min()
best_solution[2] = np.array(mutated_pop)[fitnes_list.min() == fitnes_list]
progenitor_list = progenitor_selection(population_set,fitnes_list)
new_population_set = mate_population(progenitor_list)
mutated_pop = mutate_population(new_population_set)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment