A dynamic Python-based simulation tool designed to solve the Traveling Salesperson Problem (TSP) for urban logistics. This project focuses on reducing operational costs by optimizing delivery sequences using algorithmic decision-making.
- Interactive Simulation Mode: Configure delivery points (up to 30), vehicle speed, and random seeds directly from the terminal.
- Dynamic Data Generation: Real-time generation of delivery points with random weights (1–50 kg) and priority levels (Normal vs. Urgent) within Istanbul's coordinates.
- Advanced Analytics Dashboard: Instant performance reporting including total distance, average weight per stop, and time savings.
- Dual-Layer Visualization:
- Matplotlib: Side-by-side comparison graphs and distance bar charts.
- Folium: High-fidelity interactive HTML map with zoomable markers and route overlays.
The engine uses the Haversine Formula to calculate great-circle distances between points on Earth, followed by a Greedy Nearest Neighbor approach. It starts at the central depot and always chooses the closest unvisited point until the route is complete.
In a standard 12-point delivery scenario, the simulator consistently achieves:
- ~50% reduction in total travel distance.
- Significant decreases in fuel consumption and carbon footprint.
- Optimized time-to-delivery metrics.
- Python 3.x
- NumPy & Pandas: Data manipulation and numerical operations.
- Matplotlib: Static performance visualizations.
- Folium: Interactive map generation (Leaflet.js wrapper).
- Install dependencies:
pip install numpy pandas matplotlib folium
Run the main script and follow the interactive prompts:
Bash
python main.py
Project Structure
main.py: Interactive entry point and simulation controller.
data_generator.py: Dynamic dataset creation and statistics.
route_optimizer.py: Distance calculations and Greedy algorithm logic.
visualizer.py: Dashboard UI and map/graph rendering.
config.py: Global constants and map boundaries.