Metadata-Version: 2.4
Name: allocator
Version: 1.2.0
Summary: Modern Python package for geographic task allocation, clustering, and routing optimization
Keywords: geographic,allocation,clustering,routing,optimization,tsp,kmeans,geospatial,logistics,shortest-path
Author: Suriyan Laohaprapanon, Gaurav Sood
Author-email: Suriyan Laohaprapanon <suriyant@gmail.com>, Gaurav Sood <gsood07@gmail.com>
License-Expression: MIT
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Dist: pandas>=2.0.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: scikit-learn>=1.3.0
Requires-Dist: scipy>=1.10.0
Requires-Dist: utm>=0.7.0
Requires-Dist: haversine>=2.8.0
Requires-Dist: networkx>=3.0
Requires-Dist: click>=8.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: requests>=2.28.0
Requires-Dist: googlemaps>=4.6.0
Requires-Dist: ortools>=9.5.0
Requires-Dist: matplotlib>=3.6.0
Requires-Dist: seaborn>=0.13.2
Requires-Dist: christofides>=1.0.0 ; extra == 'algorithms'
Requires-Dist: allocator[algorithms,geo] ; extra == 'all'
Requires-Dist: allocator[all,dev,test,docs] ; extra == 'complete'
Requires-Dist: ruff>=0.1.0 ; extra == 'dev'
Requires-Dist: mypy>=1.5.0 ; extra == 'dev'
Requires-Dist: black>=23.0.0 ; extra == 'dev'
Requires-Dist: isort>=5.12.0 ; extra == 'dev'
Requires-Dist: pre-commit>=3.0.0 ; extra == 'dev'
Requires-Dist: sphinx>=7.0.0 ; extra == 'docs'
Requires-Dist: furo>=2023.9.10 ; extra == 'docs'
Requires-Dist: myst-parser>=2.0.0 ; extra == 'docs'
Requires-Dist: linkify-it-py>=2.0.0 ; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints>=1.24.0 ; extra == 'docs'
Requires-Dist: sphinx-design>=0.5.0 ; extra == 'docs'
Requires-Dist: folium>=0.14.0 ; extra == 'geo'
Requires-Dist: polyline>=2.0.0 ; extra == 'geo'
Requires-Dist: pytest>=7.4.0 ; extra == 'test'
Requires-Dist: pytest-cov>=4.1.0 ; extra == 'test'
Requires-Dist: pytest-xdist>=3.3.0 ; extra == 'test'
Requires-Dist: coverage>=7.2.0 ; extra == 'test'
Requires-Dist: hypothesis>=6.82.0 ; extra == 'test'
Maintainer: Gaurav Sood
Maintainer-email: Gaurav Sood <gsood07@gmail.com>
Requires-Python: >=3.11
Project-URL: Homepage, https://github.com/geosensing/allocator
Project-URL: Documentation, https://geosensing.github.io/allocator/
Project-URL: Repository, https://github.com/geosensing/allocator.git
Project-URL: Bug Reports, https://github.com/geosensing/allocator/issues
Project-URL: Source Code, https://github.com/geosensing/allocator
Project-URL: Changelog, https://github.com/geosensing/allocator/blob/main/CHANGELOG.md
Provides-Extra: algorithms
Provides-Extra: all
Provides-Extra: complete
Provides-Extra: dev
Provides-Extra: docs
Provides-Extra: geo
Provides-Extra: test
Description-Content-Type: text/markdown

# allocator

[![PyPI version](https://img.shields.io/pypi/v/allocator.svg)](https://pypi.python.org/pypi/allocator)
[![Downloads](https://pepy.tech/badge/allocator)](https://pepy.tech/project/allocator)
[![CI](https://github.com/geosensing/allocator/actions/workflows/ci.yml/badge.svg)](https://github.com/geosensing/allocator/actions/workflows/ci.yml)
[![Documentation](https://img.shields.io/badge/docs-github.io-blue)](https://geosensing.github.io/allocator/)

Field teams, delivery services, and survey organizations waste time and money on inefficient routes. When you have 100+ locations to visit, manual planning fails. Allocator solves this.

## What It Does

- **Cluster**: Divide locations into balanced work zones
- **Route**: Find the shortest path through locations (TSP)
- **Assign**: Match locations to nearest workers or depots
- **Random Walk**: Generate survey itineraries on road networks

## Install

```bash
pip install allocator
```

## Python API

### Cluster locations into zones

```python
import allocator
import pandas as pd

locations = pd.DataFrame({
    'longitude': [100.501, 100.506, 100.510, 100.515, 100.520],
    'latitude': [13.756, 13.759, 13.763, 13.768, 13.772]
})

result = allocator.cluster(locations, n_clusters=2)
print(result.labels)  # [0 0 0 1 1]
```

### Find shortest route

```python
route = allocator.shortest_path(locations, method='ortools')
print(route.route)  # [0, 1, 2, 4, 3, 0]
```

### Assign to nearest depot

```python
depots = pd.DataFrame({
    'longitude': [100.50, 100.52],
    'latitude': [13.75, 13.77]
})

assignments = allocator.assign_to_closest(locations, depots)
print(assignments.data['assigned_worker'].tolist())  # [0, 0, 1, 1, 1]
```

### Generate random walk itineraries

```python
import networkx as nx

# Load road network graph (from OSMnx or similar)
G = nx.read_graphml("road_network.graphml")

result = allocator.random_walk(G, n_walks=10, walk_length_m=5000)
print(result.data)  # DataFrame with waypoints
```

## CLI

```bash
allocator cluster kmeans locations.csv -n 5 -o zones.csv
allocator route tsp locations.csv --method ortools -o route.csv
allocator sort locations.csv --workers depots.csv -o assignments.csv
allocator random-walk road_network.graphml -n 10 -l 5000 -o waypoints.csv
```

## Documentation

- [Full Documentation](https://geosensing.github.io/allocator/)
- [API Reference](https://geosensing.github.io/allocator/api/clustering.html)

## License

MIT
