禁忌搜索解决 TSP 的 Matlab 程序
%keywords:TSP,TS
%by Zhaokai,zkcsu@126.com
%Information School of Central South University
%2006/06
%This program is for testing
function TspTS
%禁忌搜索是对局部领域搜索的一种扩展,是一种全局逐步寻优算法。搜索过程可以接受劣解,有较强的爬山能力。
%领域结构对收敛性有很大影响。这个程序的结构简单,为 SWAP 操作。
clear;
city10=[0.4 0.4439;0.2439 0.1463;0.1707 0.2293;0.2293 0.761;0.5171 0.9414;
0.8732 0.6536;0.6878 0.5219;0.8488 0.3609;0.6683 0.2536;0.6195 0.2634];%10 cities d'=2.691
for i=1:10
for j=1:10
DL10(i,j)=((city10(i,1)-city10(j,1))^2+(city10(i,2)-city10(j,2))^2)^0.5;
end
end
city30=[41 94;37 84;54 67;25 62;7 64;2 99;68 58;71 44;54 62;83 69;64 60;18 54;22 60;
83 46;91 38;25 38;24 42;58 69;71 71;74 78;87 76;18 40;13 40;82 7;62 32;58 35;45 21;41 26;44 35;4 50];%30 cities
d'=423.741 by D B Fogel
for i=1:30
for j=1:30
DL30(i,j)=((city30(i,1)-city30(j,1))^2+(city30(i,2)-city30(j,2))^2)^0.5;
end