File Exchange

image thumbnail

version (121 KB) by Duc Chung Tran
Solution for Travelling Salesman Problem


Updated 15 May 2014

View License

Solution for The Travelling Salesman Problem:
- A salesman has to visit a number of cities in a single closed tour.
- He always starts and ends the tour in his home city.
- He has to visit each other city on the tour exactly once.
-> The solution attempts to minimize the overall travelling distance.

Cite As

Duc Chung Tran (2021). (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (31)

ali murtaza

Respected sir and other persons i am having a non linear optimization problem in matlab could any one please help me for this
so kindly provide some help

ali murtaza

Arezoo Samiei

I couldn't run it. Sir would plz help me to run it.

Anushika Fernando

Rui Zhou

lun zhao

Harikrishnan KC

Anyone pleas provide me code for lion optimization algorithm... my mail id..

subi sumuran

Duc Chung Tran

Thank you everyone for your constructive comments and support. However, at the moment I do not have time to provide detail support to each individual. Thus, I hope through the easy-to-understand function names, you can study/investigate the algorithm yourself. If it is too difficult to understand, please take a piece of paper, a pencil and draw a flowchart of the algorithm, surely you can understand it quickly.


oh, my gosh, I spent my 2 hours on understanding tour and tourlength. hope the author could give more detailed explanation to help others. wow..

thuc hanh



Mohammed Alshammari

can i get example of your work regarding TSP because I still could not solve my TSP problem

Raden Eka Gunawan



Dear Duc Chung Tran,

Thank you very much for this software. This is very nice program. Could you please suggest the literature you have followed to write this software?
Thank you !


gizem Albas

is this enumerated version of it?


Is this method guarantee the optimal solution?

arnab roy

Please can you post a numerical example.

zhao mengwei



Hi can you also send me an example of what "position" looks like? Thanks!

Twinkle katiyar

sir i need an error free travellig salesman code without using any algorithm but this generates a number of errors.if any one have it please help!!!

Twinkle katiyar

Duc Chung Tran

Yes, I sent an example to your email just now, please check. In this page, I show only my complete solutions rather than fragmented parts of them.


Would you be able to post an example?

Duc Chung Tran

Probably you wrongly used "tsp" function. You may change data matrix to 2x148 and try. Please check the source code in GUI file as well.


position is an 148*2 matrice in my example but error appears "Undefined function 'tsp' for input arguments of type 'double' "

what can be position please!

Duc Chung Tran

In order to plot both my solution and your alternative solution on a same figure, you need to:
1. Generate same set of data as input to the algorithm
2. Run my algorithm and obtain a solution of TSP, save this result to a variable
3. Run your alternative algorithm and obtain a solution of TSP, save this result to another variable
4. Plot the results on the same figure, using legend command to differentiate between the two.
Hope this information address your query.


If i also had to find an alternative solution including the original one in this kind of problem. I have got an original solution but when i have an alternative solution it doesn't include the circles as cities and the alternative tour crosses paths therefore making it worse tour then original one?

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!