Skip to main content

A package for balanced clustering and route planning

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BalancedRoutePlanner-1.0.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

BalancedRoutePlanner-1.0.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file BalancedRoutePlanner-1.0.0.tar.gz.

File metadata

  • Download URL: BalancedRoutePlanner-1.0.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.5

File hashes

Hashes for BalancedRoutePlanner-1.0.0.tar.gz
Algorithm Hash digest
SHA256 842dbd202b762f32d22102ccd5017ba767e57b62a4ec19a89b76fab98795a860
MD5 06251752f6b101e04637de466e76b97b
BLAKE2b-256 28d54839f29e7bfccd6158579a42a290f0cc6a446759e59987a1a79297a053bc

See more details on using hashes here.

File details

Details for the file BalancedRoutePlanner-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for BalancedRoutePlanner-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6dbc270d0e64665342bdc5230812c3d3237ac993793f556d56f7d43ebe3a4db7
MD5 826946de40d498c92cf80b5b67007f59
BLAKE2b-256 8afe7fca5c81dc2f4b188e8ef404cae0ad27b33a62242853e5e00dcd5b8f8bb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page