From 4252901e1e90c802955c52f3d1bb080e073c4e62 Mon Sep 17 00:00:00 2001 From: itsGarrin Date: Thu, 9 Nov 2023 15:52:21 -0500 Subject: Changed types for router.py --- dashboard_website/router.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dashboard_website/router.py b/dashboard_website/router.py index 709c8d1..74ca98e 100644 --- a/dashboard_website/router.py +++ b/dashboard_website/router.py @@ -61,7 +61,7 @@ def cluster_and_optimize(clues: [db.Clue], bikes: [db.Bike], end: db.Point, time :param time_diff: the maximum time difference between the longest trip and the average trip :param max_time: the maximum time of the trip :param n: the number of routes to create - :return: a dataframe with a cluster column + :return: the routes """ regular_points = [] for clue in clues: @@ -75,7 +75,7 @@ def cluster_and_optimize(clues: [db.Clue], bikes: [db.Bike], end: db.Point, time kmeans = KMeans(n_clusters=len(norm_centroids), init=norm_centroids) kmeans.fit(normalized_points) - # Create a dataframe with the gps coordinates, the cluster, and the list of coordinates + # Create a dataframe with the gps coordinates and the cluster df = pd.DataFrame({'gps': regular_points, 'cluster': kmeans.labels_}) # Create the coordinate list from the bikes (the centroids) and the routes (the clues) @@ -90,6 +90,8 @@ def cluster_and_optimize(clues: [db.Clue], bikes: [db.Bike], end: db.Point, time routes[i] = __remove_longest_waypoints(routes[i], bikes[i], end, max_time) df.loc[df['gps'].astype(str).isin(map(str, routes[i])), 'cluster'] = i + return routes + def __points_to_string(point: [db.Point]): """ -- cgit v1.2.3