Created
January 31, 2021 16:36
-
-
Save rocreguant/e4a0b7e63c4f3219805a4fd8b751e1e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mate_progenitors(prog_a, prog_b, max_weight, objects_dict): | |
offspring = [] | |
for i in zip(prog_a, prog_b): | |
offspring.extend(i) | |
offspring = list(dict.fromkeys(offspring)) #Removing duplicates | |
offspring = fit_in_knapsack(offspring, max_weight, objects_dict) | |
return offspring | |
def mate_population(progenitor_list, max_weight, objects_dict): | |
new_population_set = [] | |
for i in range(progenitor_list.shape[1]): | |
prog_a, prog_b = progenitor_list[0][i], progenitor_list[1][i] | |
offspring = mate_progenitors(prog_a, prog_b, max_weight, objects_dict) | |
new_population_set.append(offspring) | |
return new_population_set |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment