91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

程序采用智能優化方法的禁忌搜索算法解決中國31省會城市的TSP問題,內含MATLAB源程序

資源截圖

代碼片段和文件信息

%%一個旅行商人要拜訪全國33個省會城市,且每個城市只能拜訪一次,求所有路徑之中的最小值
%%%禁忌搜索算法求解TSP問題%%%%%%%%%%%%%%%%%%%%%
function?[BestShortcuttheMinDistance]=TabuSearch
clear?all;
close?all;
clc;
Clist=[10481.4 4438.90;10548 4351.06;...
10933.2 3471.50;9588.6 3290.259;...
8199.9 3332.5139;7891.2 4867.0049;...
9564.3 4277.671;10048.5 4538.9796;...
9749.7 2539.6936;11396.7 5087.1710;...
11281.5 4879.2363;11104.2 4647.9507;...
10303.2 4228.7456;10127.7 4210.9544;...
9156.6 4065.289;10530 4075.2965;...
10228.5 3865.138;10690.2 3562.6876;...
10554.3 3542.6725;10817.1 3364.7605;...
10737 2899.96545;10430.1 3189.0724;...
10170 3136.8107;10287.9 3393.6712;...
10190.7 2575.2760;9931.5 2226.1237;...
9335.7 4006.3556;...
9805.5 3810.6524;9365.4 3410.3504;...
9603.9 2954.4510;9245.7 2784.3226;...
10269 2468.5288;10199.7 2460.745];%全國33個省會城市坐標

CityNum=size(Clist1);%TSP問題的規模即城市數目
dislist=zeros(CityNum);?
for?i=1:CityNum
????for?j=1:CityNum
????????dislist(ij)=((Clist(i1)-Clist(j1))^2+(Clist(i2)-Clist(j2))^2)^0.5;???????
????end
end
TabuList=zeros(CityNum);??????????????????????%?(tabu?list)
TabuLength=round((CityNum*(CityNum-1)/2)^0.5);%禁忌表長度(tabu?length)
Candidates=200;???????????????????????????????%候選集的個數?(全部領域解個數)
CandidateNum=zeros(CandidatesCityNum);???????%候選解集合
S0=randperm(CityNum);?????????????????????????%隨機產生初始解
BSF=S0;???????????????????????????????????????%best?so?far;
BestL=Inf;????????????????????????????????????%當前最佳解距離
p=1;?????????????????????????????????????????%記錄迭代次數
StopL=2001;??????????????????????????????????%最大迭代次數

figure(1);
stop?=?uicontrol(‘style‘‘toggle‘‘string‘...
‘stop‘‘background‘‘white‘);
tic;?????????????????????????????????????????%用來保存當前時間
%%%%%%%%%%%%%%%%%%%%%%禁忌搜索循環%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
while?p????if?Candidates>CityNum*(CityNum-1)/2
????????disp(‘候選解個數不大于n*(n-1)/2!‘);
????????break;
????end
????ALong(p)=Fun(dislistS0);??????%當前解適配值
????
????i=1;
????A=zeros(Candidates2);??????????%?解中交換的城市矩陣

????%以下while的?是生成隨機的200?X?2??的矩陣矩陣A。每一個元素都是在1-31之間的
????while?i<=Candidates????????
????????M=CityNum*rand(12);
????????M=ceil(M);
????????if?M(1)~=M(2)
????????????A(i1)=max(M(1)M(2));
????????????A(i2)=min(M(1)M(2));
????????????????if?i==1
????????????????isa=0;
????????????else
????????????????for?j=1:i-1
????????????????????if?A(i1)==A(j1)?&&?A(i2)==A(j2)
????????????????????????isa=1;
????????????????????????break;
????????????????????else
????????????????????????isa=0;
????????????????????end
????????????????end
????????????end?
????????????if?~isa
???????????????i=i+1;
????????????else?
????????????end????????????
????????else?
????????end
????end
????%%%%%%%%產生領域解%%%%%%%%%%%%%%%%%%%%%%%
????BestCandidateNum=100;%保留前BestCandidateNum個最好候選解
????BestCandidate=Inf*ones(BestCandidateNum4);
????F=zeros(1Candidates);
????
????%這相當于是產生一個S0的鄰域...
????for?i=1:Candidates
????????CandidateNum(i:)=S0;??%候選解集合。
????????CandidateN

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????90344??2017-09-19?22:40??智能優化TSP作業數據\1.jpg

?????文件??????76126??2017-09-19?22:40??智能優化TSP作業數據\10.jpg

?????文件??????67395??2017-09-19?22:40??智能優化TSP作業數據\150.jpg

?????文件??????65662??2017-09-19?22:43??智能優化TSP作業數據\1500.jpg

?????文件??????70789??2017-09-19?22:40??智能優化TSP作業數據\20.jpg

?????文件??????65157??2017-09-19?22:43??智能優化TSP作業數據\2000.jpg

?????文件??????65531??2017-09-19?22:41??智能優化TSP作業數據\400.jpg

?????文件??????81327??2017-09-19?22:40??智能優化TSP作業數據\5.jpg

?????文件??????69588??2017-09-19?22:40??智能優化TSP作業數據\60.jpg

?????文件??????65624??2017-09-19?22:41??智能優化TSP作業數據\800.jpg

?????文件???????6577??2017-09-19?22:25??智能優化TSP作業數據\TabuSearch.m

?????文件???????6919??2017-09-25?16:38??智能優化TSP作業數據\程序代碼及城市序號.txt

?????文件??????74499??2017-09-19?22:47??智能優化TSP作業數據\運行結果.png

?????文件??????32746??2017-09-19?22:44??智能優化TSP作業數據\進化曲線.jpg

?????目錄??????????0??2017-09-25?16:39??智能優化TSP作業數據

-----------?---------??----------?-----??----

???????????????838284????????????????????15


評論

共有 條評論