Compare commits
1 Commits
046b1a043a
...
1e5f02e5ce
Author | SHA1 | Date |
---|---|---|
coolneng | 1e5f02e5ce |
|
@ -201,12 +201,11 @@ def generational_replacement(prev_population, current_population):
|
||||||
|
|
||||||
|
|
||||||
def get_best_elements(population):
|
def get_best_elements(population):
|
||||||
select_population = deepcopy(population)
|
first_element = max(population, key=lambda x: x.fitness.values[0])
|
||||||
first_element = max(select_population, key=lambda x: x.fitness.values[0])
|
first_index = get_individual_index(first_element, population)
|
||||||
first_index = get_individual_index(first_element, select_population)
|
population.pop(first_index)
|
||||||
select_population.pop(first_index)
|
second_element = max(population, key=lambda x: x.fitness.values[0])
|
||||||
second_element = max(select_population, key=lambda x: x.fitness.values[0])
|
second_index = get_individual_index(second_element, population)
|
||||||
second_index = get_individual_index(second_element, select_population)
|
|
||||||
return first_index, second_index
|
return first_index, second_index
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue