Travelling Salesman Problem

Can be used to solve both symmetric and asymmetric tsp; The script reads the distance matrix from an input file.
1.4K Downloads
Updated 21 Oct 2019

View License

The script is a modification of the TSP Example, Matlab Optimization Toolbox (https://mathworks.com/help/optim/ug/travelling-salesman-problem.html) to solve asymmetrical TSPs.
*detectSubtours.m has been kept intact without any change.
1. The script solves TSPs (both symmetric and asymmetric) based on binary integer programming
2. Required inputs: Distance matrix file. Place the input file in the same folder as the script. Distance matrix should be a square matrix.
3. Enter the file name in the prompt along with extension like .csv/.xls
4. Distance between (i,i) should be 0. Also if there is no route between two nodes, the corresponding matrix value should be zero.

Cite As

Santhanakrishnan Narayanan (2024). Travelling Salesman Problem (https://www.mathworks.com/matlabcentral/fileexchange/64654-travelling-salesman-problem), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016b
Compatible with R2016a to R2019b
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.3.0

Minor modifications in the code

1.2.2.0

csvread function has been replaced with readmatrix function

1.2.1.0

There was a numerical issue when using the script in Matlab 2018 or later. The issue has been rectified and the script has been tested in Matlab 2019.

1.2.0.0

There was a bug related to constraint for (i->i) and non-existing routes in previous version and has been rectified in this version.

1.1.0.0

There was a request for sample csv file. I have added a csv file containing distances corresponding to 79 German cities. The distances were taken from google maps. In the command prompt for distance matrix file, enter germanCities.csv

1.0.0.0