Tabu Search Algorithm for TSP

TS algorithm for TSP matlab code

Tabu search algorithm of this paper is the most classical tabu search algorithm can be modified and extended on the basis of

The main function

%Author:Chauncy_xu
%Date:2020年4月1日
clc;
clear all;
close all;
[len_side,city]=City;
num_city=size(city,1);%城市数目
gen=1;                                         %记录迭代次数
Num_gen=1000;                                   %最大迭代次数
pop0=randperm(num_city);                       %随机产生初始解
%% 禁忌表设置
TabuList=zeros(num_city);                      %禁忌表
len_Tabu=100;%禁忌表长度
%% 迭代准备
num_candi=400;                                 %全部领域解个数,不能超过30*29/2
candi=zeros(num_candi,num_city);               %邻域集合
best_pop=pop0;                                 %当前最优解
best_dis=Inf;                                  %当前最佳解距离
now_fit=zeros(1,Num_gen);
mem_best=zeros(1,Num_gen); %用于记录每一代的最优值
%% 迭代
while gen<=Num_gen
    now_fit(gen)=Fitness(len_side,pop0);      %当前解适配值
    move=zeros(num_candi,2);          % 准备所有可能的移动城市,200行2列
    %% 产生指定个数的候选解
    %选择邻域

Guess you like

Origin blog.csdn.net/qq_44384577/article/details/105257076