Skip to content

Instantly share code, notes, and snippets.

@rocreguant
Created January 31, 2021 16:37
Show Gist options
  • Save rocreguant/925082e87f13640d196b31f4364e9a93 to your computer and use it in GitHub Desktop.
Save rocreguant/925082e87f13640d196b31f4364e9a93 to your computer and use it in GitHub Desktop.
best_solution = [-1,-np.inf,np.array([])]
for i in range(10000):
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.max() > best_solution[1]:
best_solution[0] = i
best_solution[1] = fitnes_list.max()
best_solution[2] = np.array(mutated_pop)[fitnes_list.max() == fitnes_list]
progenitor_list = progenitor_selection(population_set,fitnes_list)
new_population_set = mate_population(progenitor_list, max_weight, objects_dict)
mutated_pop = mutate_population(new_population_set, max_weight,object_list, objects_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment