function [bestMin, bestID] = ILSSIWBA()
%A new bat algorithm based on iterative local search and stochastic inertia weight
%omegaxyz.com QQ: 644327005
clc;
%% 经典BA参数设置
t = 1;
maxT = 100; %最大迭代次数
dim = 30; %问题的维度
sizep = 50; %种群大小
xmin = -0.5;
xmax = 0.5; %位置向量的范围
A = 0.6.*ones(sizep,1); % 响度 (不变或者减小)
r = zeros(sizep,1); % 脉冲率 (不变或增加))
Qmin = 0; % 最小频率
Qmax = 1; % 最大频率
%% 初始化
Lb = xmin*ones(1,dim);
Ub = xmax*ones(1,dim);
pop = Lb+(Ub-Lb).*rand(sizep,dim); %种群初始化
popv = zeros(sizep,dim); % 速度
Q = zeros(sizep,1); % 频率
pfitness = zeros(dim,1);
for i = 1:sizep
pfitness(i) = evaluate2(pop(i,:)); %评价
end
[bestMin, bestID]=min(pfitness);
bestS = pop(bestID, :);
bestArchive = zeros(maxT,1);
%% 论文中的新策略参数
umin = 0.4; %The second modification (SIW method)
umax = 0.9;
sigma = 0.2;
R0 = 0.1; %The 3th modification
Rupper = 0.7;
A0 = 0.9;
Alower = 0.6;
%% 具体迭代过程
while t <= maxT
for i = 1:sizep
Q(i)=Qmin+(Qmin-Qmax)*rand();
w = umin +(umax-umin)*rand()+sigma*randn(); %The second modification (SIW method)
popv(i,:)=w*popv(i,:)+(pop(i,:)-bestS)*Q(i); %The second modification (SIW method)
Stemp = pop(i,:)+popv(i,:);
% 脉冲率
if rand>r(i)
Stemp=bestS-1+2*rand(1,dim);
end
fitTemp = evaluate2(Stemp);
if (fitTemp<=pfitness(i))&&(rand()
pop(i,:) = Stemp;
pfitness(i) = fitTemp;
A(i) = (A0-Alower)/(1-maxT)*(t-maxT)+Alower; %The 3th modification
r(i) = (R0-Rupper)/(1-maxT)*(t-maxT)+Rupper; %The 3th modification
end
if fitTemp <= bestMin
bestID = i;
bestMin = fitTemp;
bestS = Stemp;
end
end
interX = bestS.*rand(); %The 1th modification (ILS method)
interXfit = evaluate2(interX);
if interXfit < bestMin
bestMin = interXfit;
bestS = interX;
pop(bestID,:) = bestS;
pfitness(bestID,:) = bestMin;
else
if exp(bestMin-interXfit) > rand()
bestMin = interXfit;
bestS = interX;
pop(bestID,:) = bestS;
pfitness(bestID,:) = bestMin;
end
end
bestArchive(t) = bestMin;
fprintf('GEN: %d min: %.4f\n', t, bestMin);
t = t +1;
end
end%.m end