资源简介
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;
相关资源
- matlab实现画最小外接矩形
- 基于非支配排序遗传算法处理多目标
- 读取dat文件的matlab代码
- 简单的matlab图像处理GUI程序
- Gabor变换,MATLAB,边缘检测
- MATLAB中计算psnr值的实现
- 频偏估计S&C方法及实现matlab
- 四维超混沌及其图形
- POD_matlab
- 欧盟winner项目关于MIMO信道模型的MAT
- 改进的蜂群算法图像分割MATLAB代码
- 数字调制解调,同步,滤波技术的M
- 基于PCA的图像压缩Matlab代码
- matlab视频教程 李大勇 自学一本通 安
- 光纤通信系统的Matlab仿真
- MATLAB房间温度控制系统及其仿真
- MATLAB系统仿真之银行排队问题
- 正则化方法matlab程序
- matlab下的道路标志检测
- 机器人避障的matlab仿真
- 云发生器模型的matlab实现
- 无线传感网节点定位目标定位matlab仿
- 粒子群算法解决VRP代码matlab
- 将图像文件转换成数据文件的Matlab源
- 用matlab实现基于灰度的阈值分割算法
- chameleon算法(matlab)
- 字符识别matlab实现
- matlab实现kd_tree
- 信号功率谱估值及Matlab代码,仿真结
- 二维sinc函数的图像
评论
共有 条评论