- This script is designed to solve the Traveling Salesman Problem using the Branch and Bound method.
- It reads TSP data from text files, processes each file to find the minimum cost path, and writes the results to a CSV file.
- Python 3.x
- NumPy library
Ensure that Python 3 is installed on your system. You can download it from https://www.python.org/downloads/
Install NumPy using pip:
pip install numpy
- Place your TSP data files in a directory.
- Open the script and modify the file path in the
__main__section to point to your directory containing the TSP data files. - Run the script using Python:
python your_script_name.py(Here it is TSPusingbnb.py)
The script will process each file and write the results to 'tsp_results_bnb.csv' in the current directory.
- The script uses a Branch and Bound algorithm, which may take significant time for large datasets.
- I have mentioned
#TODOin the script wherever changes are required. - A timeout mechanism is implemented to stop processing a file if it takes too long, you can change the duration of this duration in the
__main__. (I have taken 100 milliseconds) - Change the value in the for loop in the
__main__section according to the number of data files you have. - Modify the
file_pathvariable in the__main__section according to the location of your test data. - The script creates a 'tsp_results_bnb.csv' file to store the results. Ensure you have write permissions in the directory where the script is run.