Skip to content

Instantly share code, notes, and snippets.

@rocreguant
Created January 31, 2021 16:18
Show Gist options
  • Save rocreguant/4e0ec9c16847b44b9a05b3e04f656985 to your computer and use it in GitHub Desktop.
Save rocreguant/4e0ec9c16847b44b9a05b3e04f656985 to your computer and use it in GitHub Desktop.
# First step: Create the first population set
def genesis(city_list, n_population):
population_set = []
for i in range(n_population):
#Randomly generating a new solution
sol_i = city_list[np.random.choice(list(range(n_cities)), n_cities, replace=False)]
population_set.append(sol_i)
return np.array(population_set)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment