TSP using Two-Opt Heuristics
Version 1.0.2 (2,38 KB) von
Moreno, M.
Fast and simple TSP algorithm using 2-opt heuristics seeking for the 'best' solution.
Description
[idx,val] = tsp(x,arg1,arg2,~): Returns the best solution idx and its cost val to the travelling sales person problem in x (matrix or file name) using two-opt heuristics within the parameters arg1 and arg2. These parameters are, by default, the number of run cycles and the number of iterations per cycle, and are set to 1 and 1e3 each by default. If only arg1 was passed, it would be taken as the number of iterations for only one cycle. An empty function call produces sample values with a figure output. Passing a fourth input parameter would instead look for the 'worst' possible solution.
Miguel Moreno, July 2024
Examples
[idx,val] = tsp; % Test run
[idx,val] = tsp(rand(2e2,2)); % Medium problem
[idx,val] = tsp(rand(50,2),10,1e3) % Re-converged
[idx,val] = tsp(rand(20,3),[],[],-1); % Worst solution
Zitieren als
Moreno, M. (2024). TSP using Two-Opt Heuristics (https://www.mathworks.com/matlabcentral/fileexchange/169161-tsp-using-two-opt-heuristics), MATLAB Central File Exchange. Abgerufen .
Kompatibilität der MATLAB-Version
Erstellt mit
R2024a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
1.0.2 | Logo change. |
||
1.0.1 | Includes 'worst' possible solution upon an additional input parameter call |
||
1.0.0 |