NeoRoute
ActiveH3 multi-resolution spatial index over Nairobi, Q-learning traffic-aware routing with curriculum learning, Hungarian dispatch assignment and hierarchical TSP for multi-stop routes.
- Python
- PostgreSQL
- PostGIS
- H3
- OSMnx
- NetworkX
- SQLAlchemy
- NumPy
- SciPy
- Scikit-Learn
- Matplotlib
What was broken.
Last-mile delivery in Nairobi suffers from informal addressing, extreme traffic congestion (Thika/Mombasa Rds), and dynamic rider capacity. Existing GPS routing ignores time-of-day patterns and cannot handle multi-stop optimization or optimal rider-order matching.
How it is wired.
Multi-resolution H3 grid (res 6 zones, res 8 navigation) spans Nairobi. An implicit road graph stores OSM priors blended with empirical traces via Bayesian updating. A Q-learning agent (current/destination hex + time bucket + day type) learns traffic-aware policies. The Hungarian algorithm optimises dispatch; a hierarchical TSP solver handles multi-stop routes via zone clustering.
What I shipped.
- Multi-resolution H3 spatial indexing with OSMnx road-network integration
- Q-learning routing agent with curriculum learning (5→15 hex hops) and reward shaping
- GPS trace ingestion pipeline with validation and Bayesian weight blending (kappa=10)
- Hungarian dispatch optimizer with urgency-weighted cost matrices
- Hierarchical multi-stop router: zone clustering (res 6) plus greedy TSP per cluster
- Synthetic trace generator with temporal noise modelling for traffic patterns
- End-to-end benchmark harness: Q-policy vs H3-direct vs random walk
Why these choices.
Chose H3 over a quadtree for uniform hexagons and better nearest-neighbour queries. Q-learning over A* to learn traffic-aware shortcuts from empirical traces. Two-hour buckets instead of continuous time for tractability. PostgreSQL over MongoDB for ACID guarantees on dispatch assignments.