This repository contains implementations for analyzing the Traveling Salesman Problem (TSP) and understanding computational limits.
- Clone this repository
- Navigate to the repository directory
- Generate the test datasets:
python location_generator.py
This creates a data/ directory with emergency site datasets of various sizes (5, 8, 10, 12, 15, 20 locations).
The assignment asks you to run four different commands to analyze the algorithms:
python tsp_solver.py --test-smallTests both brute force and nearest neighbor on small datasets to verify they produce correct results.
python tsp_solver.py --time-brute-forceTimes the brute force algorithm on datasets of size 5, 8, 10, 12, and 15. Warning: Larger sizes may take several minutes or timeout after 60 seconds.
python tsp_solver.py --time-approximationTimes the nearest neighbor approximation on datasets of size 5, 8, 10, 12, 15, and 20.
python tsp_solver.py --compare-allCompares brute force and approximation side-by-side on small datasets where both can complete.
.
├── README.md # This file
├── location_generator.py # Generates test datasets
├── tsp_solver.py # TSP algorithm implementations and timing utilities
└── data/ # Generated test datasets
├── sites_5.json
├── sites_8.json
├── sites_10.json
├── sites_12.json
├── sites_15.json
└── sites_20.json
If you get an error about missing data files, make sure you've run:
python location_generator.pyIf you need to see all available options:
python tsp_solver.py --help