diff --git a/src/processing.py b/src/processing.py index 7578f3c..27c763d 100644 --- a/src/processing.py +++ b/src/processing.py @@ -1,5 +1,5 @@ from preprocessing import parse_file -from pandas import DataFrame +from pandas import DataFrame, Series from sys import argv from random import seed, randint from time import time @@ -30,7 +30,7 @@ def get_furthest_element(element, data): furthest_index = element_df["distance"].astype(float).idxmax() furthest_row = data.iloc[furthest_index] furthest_point = get_different_element(original=element, row=furthest_row) - return {"point": furthest_point, "distance": furthest_row["distance"]} + return Series(data={"point": furthest_point, "distance": furthest_row["distance"]}) def remove_solution_dataset(data, solution): @@ -44,14 +44,15 @@ def greedy_algorithm(n, m, data): for _ in range(m): last_solution = int(solutions["point"].tail(n=1)) centroid = get_furthest_element(element=last_solution, data=data) - solutions = solutions.append(dict(centroid), ignore_index=True) + solutions = solutions.append(centroid, ignore_index=True) data = remove_solution_dataset(data=data, solution=last_solution) return solutions def get_pseudorandom_solution(n, data): seed(42) - return data.iloc[randint(a=0, b=n)] + solution = data.iloc[randint(a=0, b=n)] + return Series(data={"point": solution["destination"], "distance": 0}) def local_search(n, m, data):