allocator package
Subpackages
Submodules
allocator.cluster module
allocator.cluster_haversine module
allocator.cluster_kahip module
Allocator by Karlsruhe High Quality Partitioning (KaHIP)
- allocator.cluster_kahip.execute(cmd)
Execute external command
- allocator.cluster_kahip.main(argv=['-M', 'html', 'source', 'build'])
allocator.cluster_kmeans module
Allocator by K-means
- allocator.cluster_kmeans.closest_centroid_euclidean(points, centroids)
returns an array containing the index to the nearest centroid for each point
- allocator.cluster_kmeans.closest_centroid_haversine(points, centroids)
returns an array containing the index to the nearest centroid for each point
- allocator.cluster_kmeans.closest_centroid_osrm(points, centroids, args)
returns an array containing the index to the nearest centroid for each point
- allocator.cluster_kmeans.initialize_centroids(points, k, random_state=None)
returns k centroids from the initial points
- allocator.cluster_kmeans.main(argv=['-M', 'html', 'source', 'build'])
- allocator.cluster_kmeans.move_centroids(points, closest, centroids)
returns the new centroids assigned from the points closest to them
allocator.compare_buffoon_kmeans module
allocator.distance_matrix module
Distance Matrix
- allocator.distance_matrix.euclidean_distance_matrix(X, Y=None)
Euclidean distance matrix calculation
- allocator.distance_matrix.google_distance_matrix(X, Y=None, api_key=None, duration=True)
Limitations:
Users of the standard API: * 2,500 free elements per day, calculated as the sum of client-side and
server-side queries.
Maximum of 25 origins or 25 destinations per request.
100 elements per request.
100 elements per second, calculated as the sum of client-side and server-side queries.
For more informaton:- https://developers.google.com/maps/documentation/distance-matrix/usage-limits
- allocator.distance_matrix.haversine_distance_matrix(X, Y=None)
Harversine distance matrix calculation
- allocator.distance_matrix.latlon2xy(lat, lon)
Transform lat/lon to UTM coordinate
- Args:
lat (float): WGS latitude lon (float): WGS longitude
- Returns:
[x, y]: UTM x, y coordinate
- allocator.distance_matrix.osrm_distance_matrix(X, Y=None, chunksize=100, osrm_base_url=None)
Calculate distance matrix of arbitrary size using OSRM
Credits: https://github.com/stepankuzmin/distance-matrix
Please note that OSRM distance matrix is in duration in seconds.
- allocator.distance_matrix.pairwise_distances(X, Y=None)
Pairwise euclidean distance calculation
- allocator.distance_matrix.xy2latlog(x, y, zone_number, zone_letter=None)
Transform x, y coordinate to lat/lon coordinate
- Args:
x (float): UTM x coordinate y (float): UTM y coorinate zone_number (int): x/y zone number zone_letter (char): x/y zone letter (optional)
- Returns:
[lat, lon]: lat/lon coordinate
allocator.mst module
allocator.shortest_path_gm module
Shortest path using Google Direction API
- allocator.shortest_path_gm.main(argv=['-M', 'html', 'source', 'build'])
allocator.shortest_path_mst_tsp module
allocator.shortest_path_ortools module
allocator.shortest_path_osrm module
Shortest path using OSRM trip API
- allocator.shortest_path_osrm.main(argv=['-M', 'html', 'source', 'build'])
- allocator.shortest_path_osrm.osrm_trip(coords, osrm_base_url=None)
List of (lon, lat)
For more information: https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#trip-service
allocator.sort_by_distance module
Allocator by sorting distance from known worker location
- allocator.sort_by_distance.main(argv=['-M', 'html', 'source', 'build'])
allocator.utils module
- allocator.utils.column_exists(df, col)
Check the column name exists in the DataFrame.
- Args:
df (
DataFrame
): Pandas DataFrame. col (str): Column name.- Returns:
bool: True if exists, False if not exists.
- allocator.utils.fixup_columns(cols)
Replace index location column to name with col prefix
- Args:
cols (list): List of original columns
- Returns:
list: List of column names
- allocator.utils.isstring(s)