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
|
return solution
|
||||||
|
|
||||||
|
|
||||||
|
def get_genotype(element):
|
||||||
|
genotype = where(element == True)
|
||||||
|
return genotype[0]
|
||||||
|
|
||||||
|
|
||||||
def evaluate_element(element, data):
|
def evaluate_element(element, data):
|
||||||
fitness = []
|
fitness = []
|
||||||
genotype = where(element == True)
|
genotype = get_genotype(element)
|
||||||
indexes = genotype[0]
|
distances = data.query(f"source in @genotype and destination in @genotype")
|
||||||
distances = data.query(f"source in @indexes and destination in @indexes")
|
for item in genotype[:-1]:
|
||||||
for item in indexes[:-1]:
|
|
||||||
element_df = distances.query(f"source == {item} or destination == {item}")
|
element_df = distances.query(f"source == {item} or destination == {item}")
|
||||||
max_distance = element_df["distance"].astype(float).max()
|
max_distance = element_df["distance"].astype(float).max()
|
||||||
fitness = append(arr=fitness, values=max_distance)
|
fitness = append(arr=fitness, values=max_distance)
|
||||||
|
|
Loading…
Reference in New Issue