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

  • 大小: 21KB
    文件類型: .m
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-05-29
  • 語言: Matlab
  • 標(biāo)簽: Tabu??Search??matlab??tsp??

資源簡介

An example to apply tabu search to find optimal routes for TSP prblem

資源截圖

代碼片段和文件信息

%?function?[best_sofarbestV_sofar]=ftabu(VtableFeatableNtabu_tenurepenal_iter)
%This?is?a?tabu?search?function.
%The?default?objective?is?minimization
%The?move?is?exchange?here
%Another?function?fcost?is?needed?to?calculate?each?move?value
%[val]=fcost(Vtable)?
%Vtable?is?a?table?includes?all?available?movement?combinations.
%Featable?is?a?cell?table?having?the?same?dimensions?as?Vtable.?For?each?cell?
%it?consistes?of?a?table?which?including?0?or?1?to?indicate?the?availability?
%of?movements?between?nodes.?For?example?if?node1(ij)?and?node2(uv)?
%cannot?be?exchanged?then?Featable{ij)(uv)=0;
XY=[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];%node?coordinates
%?XY=[4272;1747;1325;3517;];

SZ=size(XY1);
%?Vtable=[182324911719201021141582526292827161722233051213461;];
Vtable=[231891171920102114158252629282716172223305121346241;];

crnt_tour=Vtable;
short_path=Vtable;
figure?(1);
plot([XY(short_path(SZ)1)XY(short_path(1)1)][XY(short_path(SZ)2)XY(short_path(1)2)]);
plot(XY(SZ1)XY(SZ2)‘bd‘‘MarkerFaceColor‘‘g‘‘MarkerSize‘10);
hold?on;

for?i=1:SZ-1
????plot(XY(i1)XY(i2)‘bd‘‘MarkerFaceColor‘‘g‘‘MarkerSize‘10);
????plot([XY(crnt_tour(i)1)XY(crnt_tour(i+1)1)][XY(crnt_tour(i)2)XY(crnt_tour(i+1)2)]);
????
end

hold?off;




Featable=cell(size(Vtable));
%?for?i=1:size(Vtable1)
%?????for?j=1:size(Vtable2)
%?????????for?u=1:size(Vtable1)
%?????????????for?v=1:size(Vtable2)
%?????????????????if?i==u?&&?j==v?||?j==1?||?v==1?||?Vtable(ij)==0?||?Vtable(uv)==0
%?????????????????????Featable{ij}(uv)=0;
%?????????????????else
%?????????????????????Featable{ij}(uv)=1;
%?????????????????end
%?????????????end
%?????????end
%?????end
%?end

for?i=1:size(Vtable2)
????for?ii=1:size(Vtable2)
????????if?i~=1?&&?i~=length(Vtable)?&&?ii~=1?&&?ii~=length(Vtable)?&&?i~=ii
????????????Featable{1i}(1ii)=1;
????????else
????????????Featable{1i}(1ii)=0;
????????end
????end
end

%Featable?generation
N=1000;
penal_iter=60;
tabu_tenure=50;


track=size(N3);



%************************Function?start?here*******************************
fprintf(‘\n\n\n**************ftabu?start?here*****************‘);
start_time?=?cputime;

dim1=size(Vtable1);
dim2=size(Vtable2);

tabu_list=cell(dim1dim2);
costtable=cell(dim1dim2);
frequency?=?cell(dim1dim2);

for?i=1:dim1
????for?j=1:dim2
????????tabu_list{ij}=zeros(dim1dim2);
????????costtable{ij}=zeros(dim1dim2);
????????frequency{ij}=zeros(dim1dim2);
????end
end

for?i=1:dim1
????????for?j=1:dim2
????????????for?u=1:dim1
????????????????for?v=1:dim2
????????????????????if?Featable{ij}(uv)==0
????????????????????????tabu_list{ij}(uv)=10000;
?????????????????

評(píng)論

共有 條評(píng)論