Skip to main content

BalancedRoutePlanner

BalancedRoutePlanner is a Python package designed for smart city management and other extended applications. It provides functionalities for balanced clustering and route planning to optimize intra-cluster paths efficiently.


Features

  1. Supports multiple data formats: CSV, XLSX, and SHP point data.
  2. Balanced clustering: Uses balanced clustering methods to balance task allocation and route planning.
  3. Structured data output: Provides structured data for secondary analysis and generates visualizations of clustering results and routes for intuitive inspection.

Installation

BalancedRoutePlanner requires Python 3.6 or higher. You can install BalancedRoutePlanner from PyPI using the following command:

pip install BalancedRoutePlanner

Alternatively, you can install BalancedRoutePlanner using the following method:

# Install using Git
git clone  https://github.com/SmartCitiesTransportationHub/BalancedRoutePlanner.git
cd BalancedRoutePlanner
pip install -e .

Usage

You can run test.py to test the BalancedRoutePlanner using generated data.

Example Code

Below is a simple usage example:

import numpy as np
from BalancedRoutePlanner import balanced_cluster, nearest_neighbor_2opt, visualize_clusters, visualize_paths

# Generate test data
def generate_data(n_samples, x_range, y_range):
    x = np.random.uniform(x_range[0], x_range[1], n_samples)
    y = np.random.uniform(y_range[0], y_range[1], n_samples)
    return np.column_stack((x, y))

# Test data and parameters
coords = generate_data(50, [0, 10], [0, 10])
num_clusters = 3
center_point = np.array([5, 5])

# Balanced clustering
clusters, balanced_model, labels, cluster_sizes = balanced_cluster(coords, num_clusters)

# Path planning
paths = []
for cluster_id, cluster_coords in clusters.items():
    path = nearest_neighbor_2opt(coords[cluster_coords], center_point)
    paths.append(path)

# Visualization
visualize_clusters(coords, labels, balanced_model.cluster_centers_)
visualize_paths(paths, center_point)

Parameter Descriptions

  • balanced_cluster:

    • data: Array of data point coordinates.
    • num_clusters: Number of clusters.
    • tolerance (optional): Tolerance for initial assignment.
    • max_iterations (optional): Maximum number of iterations.
    • optimize_geo (optional): Whether to perform geographical optimization.
  • nearest_neighbor_2opt:

    • coords: Array of data point coordinates.
    • start_point: Starting and ending point of the path.
  • visualize_clusters:

    • coords: Array of data point coordinates.
    • labels: Cluster labels for each data point.
    • centers: Coordinates of cluster centers.
  • visualize_paths:

    • paths: List of optimized paths for each cluster.
    • center_point: Starting and ending point of the paths.

Support

If you have any issues or if you want to contribute to BalancedRoutePlanner, please open an issue or submit a pull request on GitHub!


License

BalancedRoutePlanner is open source and licensed under the MIT license.

Metadata

Release files for BalancedRoutePlanner 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for BalancedRoutePlanner 1.0.0
File Size Uploaded
BalancedRoutePlanner-1.0.0.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for BalancedRoutePlanner 1.0.0
File Interpreter ABI Platform
BalancedRoutePlanner-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.8 kB

Release files / BalancedRoutePlanner-1.0.0.tar.gz

Download URL BalancedRoutePlanner-1.0.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
842dbd202b762f32d22102ccd5017ba767e57b62a4ec19a89b76fab98795a860
BLAKE2b-256 checksum
How to use checksums
28d54839f29e7bfccd6158579a42a290f0cc6a446759e59987a1a79297a053bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.8.5

Release files / BalancedRoutePlanner-1.0.0-py3-none-any.whl

Download URL BalancedRoutePlanner-1.0.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6dbc270d0e64665342bdc5230812c3d3237ac993793f556d56f7d43ebe3a4db7
BLAKE2b-256 checksum
How to use checksums
8afe7fca5c81dc2f4b188e8ef404cae0ad27b33a62242853e5e00dcd5b8f8bb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page