Refactor genotype obtention into a function
This commit is contained in:
parent
921e094858
commit
2e12296f2c
|
@ -10,12 +10,16 @@ def get_first_random_solution(n, m):
|
|||
return solution
|
||||
|
||||
|
||||
def get_genotype(element):
|
||||
genotype = where(element == True)
|
||||
return genotype[0]
|
||||
|
||||
|
||||
def evaluate_element(element, data):
|
||||
fitness = []
|
||||
genotype = where(element == True)
|
||||
indexes = genotype[0]
|
||||
distances = data.query(f"source in @indexes and destination in @indexes")
|
||||
for item in indexes[:-1]:
|
||||
genotype = get_genotype(element)
|
||||
distances = data.query(f"source in @genotype and destination in @genotype")
|
||||
for item in genotype[:-1]:
|
||||
element_df = distances.query(f"source == {item} or destination == {item}")
|
||||
max_distance = element_df["distance"].astype(float).max()
|
||||
fitness = append(arr=fitness, values=max_distance)
|
||||
|
|
Loading…
Reference in New Issue