summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoritsGarrin <garrin.shieh@gmail.com>2023-11-09 15:52:21 -0500
committeritsGarrin <garrin.shieh@gmail.com>2023-11-09 15:52:21 -0500
commit4252901e1e90c802955c52f3d1bb080e073c4e62 (patch)
tree3d3ad0c25279a72a63824577b9b0c870cd84573f
parentcb075ec78f3d816f9688cfd7d3cb7f8d960832e7 (diff)
Changed types for router.py
-rw-r--r--dashboard_website/router.py6
1 files 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]):
"""