Skip to content

Commit be93f0f

Browse files
committed
new docs
1 parent a963981 commit be93f0f

30 files changed

+2306
-957
lines changed

.github/workflows/docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ jobs:
3636
run: |
3737
uv pip install -e .[docs]
3838
39+
- name: Generate installation docs from pyproject.toml
40+
run: |
41+
uv run python scripts/generate_installation_docs.py
42+
3943
- name: Build documentation
4044
run: |
4145
cd docs

README.md

Lines changed: 28 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,175 +1,59 @@
1-
# allocator: Optimally Allocate Geographically Distributed Tasks
1+
# allocator: Modern Geographic Task Allocation
22

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

8-
**Allocator v1.0** provides a modern, Pythonic API for geographic task allocation, clustering, and routing optimization.
8+
**Allocator v1.0** provides a modern, Pythonic API for geographic task allocation, clustering, and routing optimization.
99

10-
How can we efficiently collect data from geographically distributed locations? Whether you're coordinating crowdsourced data collection, optimizing delivery routes, or planning field research, allocator provides the tools you need.
10+
> **📖 [Complete Documentation](https://geosensing.github.io/allocator/)** | **🚀 [Quick Start](https://geosensing.github.io/allocator/quickstart.html)** | **💡 [Examples](https://geosensing.github.io/allocator/examples/overview.html)**
1111
12-
## ✨ What's New in v1.0
12+
## Key Features
1313

14-
- **🎯 Modern Python API** - Clean, intuitive interface with type hints
15-
- **📦 Unified CLI** - Single command with subcommands (`allocator cluster`, `allocator route`, `allocator assign`)
16-
- **🚀 Performance** - Optimized algorithms with NumPy and scikit-learn
17-
- **📊 Rich Results** - Structured results with metadata and easy export
18-
- **🔧 No Backward Compatibility** - Clean slate, standards-compliant design
19-
20-
## Core Functionality
21-
22-
**1. Clustering** 🎯
23-
Group geographic points into balanced clusters for task allocation.
24-
25-
**2. Routing** 🛣️
26-
Find optimal paths through sets of locations (TSP solving).
27-
28-
**3. Assignment** 📍
29-
Assign points to closest workers/centers with distance-based sorting.
14+
- **🎯 Clustering**: Group geographic points into balanced zones
15+
- **🛣️ Routing**: Find optimal paths through locations (TSP solving)
16+
- **📍 Assignment**: Connect points to closest workers/centers
17+
- **🚀 Performance**: Optimized algorithms with NumPy and scikit-learn
18+
- **📦 Modern API**: Clean Python interface + unified CLI
3019

3120
## Quick Start
3221

33-
### Installation
34-
3522
```bash
3623
pip install allocator
3724
```
3825

39-
### Python API Example
40-
4126
```python
4227
import allocator
4328
import pandas as pd
4429

45-
# Load your geographic data
46-
data = pd.DataFrame({
47-
'longitude': [101.0, 101.1, 101.2, 101.3],
48-
'latitude': [13.0, 13.1, 13.2, 13.3],
49-
'location_id': ['A', 'B', 'C', 'D']
30+
# Geographic locations
31+
locations = pd.DataFrame({
32+
'longitude': [100.5018, 100.5065, 100.5108],
33+
'latitude': [13.7563, 13.7590, 13.7633]
5034
})
5135

52-
# Cluster locations into groups
53-
result = allocator.cluster(data, n_clusters=2, method='kmeans')
54-
print(f"Cluster labels: {result.labels}")
55-
print(f"Centroids: {result.centroids}")
36+
# Group into zones
37+
clusters = allocator.cluster(locations, n_clusters=2)
5638

57-
# Find optimal route through locations
58-
route = allocator.shortest_path(data, method='ortools')
59-
print(f"Optimal route: {route.route}")
60-
print(f"Total distance: {route.total_distance}")
39+
# Find optimal route
40+
route = allocator.shortest_path(locations)
6141

62-
# Assign points to closest centers
42+
# Assign to service centers
6343
centers = pd.DataFrame({
64-
'longitude': [101.05, 101.25],
65-
'latitude': [13.05, 13.25]
44+
'longitude': [100.50, 100.52],
45+
'latitude': [13.75, 13.77]
6646
})
67-
assignments = allocator.assign_to_closest(data, centers)
68-
print(assignments.data)
69-
```
70-
71-
### CLI Example
72-
73-
```bash
74-
# Cluster geographic points
75-
allocator cluster data.csv --clusters 3 --method kmeans --output clusters.csv
76-
77-
# Find optimal route
78-
allocator route locations.csv --method ortools --output route.csv
79-
80-
# Assign points to centers
81-
allocator assign points.csv centers.csv --output assignments.csv
47+
assignments = allocator.assign(locations, centers)
8248
```
8349

84-
## Distance Metrics
85-
86-
All functions support multiple distance calculation methods:
87-
88-
- **euclidean** - Fast Euclidean distance (good for local areas)
89-
- **haversine** - Great circle distance accounting for Earth's curvature
90-
- **osrm** - Real road network distances via OSRM API
91-
- **google** - Google Maps distance matrix (requires API key)
92-
93-
## Algorithms
94-
95-
**Clustering:**
96-
- **K-means**: Fast, well-balanced clusters
97-
- **KaHIP**: Graph partitioning for highly balanced clusters (requires external install)
98-
99-
**Routing (TSP):**
100-
- **OR-Tools**: Exact solutions for small problems, heuristics for larger ones
101-
- **Christofides**: 1.5-approximation algorithm (requires external install)
102-
- **OSRM**: Real-world routing via road networks
103-
- **Google**: Google Maps Directions API
104-
105-
## Data Format
106-
107-
Input data must be pandas DataFrames or CSV files with these columns:
108-
109-
- **longitude**: Geographic longitude (required)
110-
- **latitude**: Geographic latitude (required)
111-
- Additional columns are preserved in results
112-
113-
## Examples and Use Cases
114-
115-
- **Field Research**: Optimize survey routes for maximum efficiency
116-
- **Delivery/Logistics**: Plan optimal delivery routes and territories
117-
- **Crowdsourcing**: Assign tasks to workers based on geographic proximity
118-
- **Emergency Response**: Allocate resources to incident locations
119-
- **Urban Planning**: Analyze spatial patterns and optimize service locations
120-
121-
## API Reference
122-
123-
### Main Functions
124-
125-
```python
126-
# High-level functions
127-
allocator.cluster(data, n_clusters=3, method='kmeans', distance='euclidean')
128-
allocator.shortest_path(data, method='ortools', distance='euclidean')
129-
allocator.assign_to_closest(points, workers, distance='euclidean')
130-
131-
# Specific algorithms
132-
allocator.kmeans(data, n_clusters=3, distance='euclidean')
133-
allocator.kahip(data, n_clusters=3) # Requires KaHIP installation
134-
allocator.tsp_ortools(data, distance='euclidean')
135-
allocator.tsp_christofides(data) # Requires Christofides installation
136-
```
137-
138-
### Result Types
139-
140-
- `ClusterResult`: Labels, centroids, convergence info, metadata
141-
- `RouteResult`: Route order, total distance, metadata
142-
- `SortResult`: Sorted assignments with distances, metadata
143-
144-
## Requirements
145-
146-
- Python 3.11+
147-
- Core: pandas, numpy, matplotlib, networkx, scikit-learn
148-
- CLI: click, rich
149-
- Optional: ortools, googlemaps, requests (for OSRM)
150-
151-
## Documentation
152-
153-
Complete documentation: https://geosensing.github.io/allocator/
154-
155-
## Development
156-
157-
This project uses modern Python development practices:
158-
159-
- **uv** for dependency management
160-
- **pytest** for testing
161-
- **black** and **isort** for code formatting
162-
- **ruff** for linting
163-
- **GitHub Actions** for CI/CD
164-
165-
## Contributing
166-
167-
We welcome contributions! Please see our [Contributor Code of Conduct](http://contributor-covenant.org/version/1/0/0/).
168-
169-
## Authors
50+
## Documentation & Examples
17051

171-
Suriyan Laohaprapanon and Gaurav Sood
52+
- **📖 [Full Documentation](https://geosensing.github.io/allocator/)**
53+
- **🚀 [Installation & Tutorial](https://geosensing.github.io/allocator/quickstart.html)**
54+
- **🔧 [API Reference](https://geosensing.github.io/allocator/api/clustering.html)**
55+
- **💡 [Real-World Examples](https://geosensing.github.io/allocator/examples/overview.html)**
17256

173-
## License
57+
## License & Contributing
17458

175-
MIT License - see [LICENSE](https://opensource.org/licenses/MIT) for details.
59+
MIT License. Contributions welcome - see [Contributing Guide](https://geosensing.github.io/allocator/contributing.html).

docs/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ SPHINXPROJ = allocator
88
SOURCEDIR = source
99
BUILDDIR = build
1010

11+
# Generate docs from pyproject.toml before building
12+
generate-installation:
13+
@echo "Generating installation docs from pyproject.toml..."
14+
cd .. && uv run python scripts/generate_installation_docs.py
15+
1116
# Put it first so that "make" without argument is like "make help".
1217
help:
1318
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1419

15-
.PHONY: help Makefile
20+
# Override html target to generate docs first
21+
html: generate-installation
22+
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
23+
24+
.PHONY: help Makefile generate-installation
1625

1726
# Catch-all target: route all unknown targets to Sphinx using the new
1827
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).

docs/source/allocator.rst

Lines changed: 0 additions & 125 deletions
This file was deleted.

docs/source/allocator.tests.rst

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)