Plan the shortest round-trip across many field locations. Give it a list of stops (name, latitude, longitude) and it returns the optimal visiting order that starts at a depot, visits every stop once, and returns home — the classic Travelling Salesman Problem (TSP).
Built originally to plan daily field-visit routes across 50+ retail outlets, cutting travel distance and time.
- Distances: great-circle (Haversine) distance between every pair of coordinates.
- Solver: Google OR-Tools routing
engine (
PATH_CHEAPEST_ARCfirst solution, refined with Guided Local Search). - Output: the optimized stop order, total route distance in km, and a ready-to-open Google Maps directions link for the whole tour.
pip install -r requirements.txt
python route_optimizer.pyUse your own stops:
python route_optimizer.py --data my_stops.csv --depot 0name,latitude,longitude
Outlet 01,23.204579,75.80112036
Outlet 02,22.923623,75.397381
...The included
sample_locations.csvuses anonymized outlet names with real coordinates around the Ujjain / Madhya Pradesh region for demonstration.
Optimized route across 50 stops — total 412.7 km
1. Outlet 01 (depot)
2. Outlet 17
3. Outlet 09
...
51. Outlet 01 (depot)
Google Maps directions:
https://www.google.com/maps/dir/23.204579,75.80112036/...
Python · Google OR-Tools · pandas · Haversine geodesics
- Multiple vehicles / capacity constraints (full VRP)
- Real road distances via a routing API instead of straight-line
- Time windows per stop
- A small web UI to upload a CSV and view the route on a map
MIT — see LICENSE.