Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Route Optimizer

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.

How it works

  • Distances: great-circle (Haversine) distance between every pair of coordinates.
  • Solver: Google OR-Tools routing engine (PATH_CHEAPEST_ARC first 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.

Quick start

pip install -r requirements.txt
python route_optimizer.py

Use your own stops:

python route_optimizer.py --data my_stops.csv --depot 0

Input format (sample_locations.csv)

name,latitude,longitude
Outlet 01,23.204579,75.80112036
Outlet 02,22.923623,75.397381
...

The included sample_locations.csv uses anonymized outlet names with real coordinates around the Ujjain / Madhya Pradesh region for demonstration.

Example output

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/...

Tech

Python · Google OR-Tools · pandas · Haversine geodesics

Possible extensions

  • 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

License

MIT — see LICENSE.

About

Shortest round-trip route optimizer for field visits — Travelling Salesman Problem via Google OR-Tools + Haversine distances. Outputs the optimal stop order, total distance, and a Google Maps link.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages