1 简介
群居蜘蛛优化算法(SSO)是一种新的随机全局优化技术,是基于对群居蜘蛛协作行为的模拟,将搜索个体按性别分为两类,按照不同的搜索准则进行寻优,即能避免个体在优势群体周围的聚集,又能促使个体在全局进行搜索,很好地避免了早熟收敛和搜索结果不稳定的窘境,函数优化结果表明,该方法对初值和参数选择不敏感、稳健性强、收敛速度快。其主要步骤如下。
2 部分代码
function [msp] = MaMove(fn,mn,fsp,msp,femass,mamass,d,lb,ub,pm)
%MAMOVE Summary of this function goes here
% Detailed explanation goes here
%Preliminaries
dt=zeros(1,mn);
% Scale for distance
scale=(-lb(1)+ub(1));%/2;
[Indb,~] = find(mamass>=median(mamass)); % Male spiders above median
for i=1:mn
if ismember(i,Indb) % Spider above the median
% Start looking for a female with stronger vibration
for j=1:fn
if femass(j)>mamass(i)
% Calculate the distance
dt(j)=norm(msp(i,:)-fsp(j,:));
else
dt(j)=0;
end
end
% Choose the shortest distance
[~,Ind,val] = find(dt); % Choose where the distance in non zero
[~,Imin] = min(val); % Get the shortest distance
Ish = Ind(Imin);
% Update moves
if isempty(val)
Vib=0;
spaux=zeros(1,d);
else
dt=dt./scale;
Vib = 2*femass(Ish)*exp(-(rand*dt(Ish).^2));
spaux=fsp(Ish,:);
end
delta = 2*rand(1,d)-.5;
tmpf = 2*pm.*(rand(1,d)-0.5);
msp(i,:) = msp(i,:)+Vib*(spaux-msp(i,:)).*delta+tmpf;
else % de aqui para abajo falta
%% Spider below median, go to weigthed mean
% Generate the weighted mean
spdpos = [fsp' msp']';
spdwei = [femass' mamass']';
weigth = repmat(spdwei,1,d);
dim = find(size(spdpos)~=1,1);
wmean = sum(weigth.*spdpos,dim)./sum(weigth,dim);
%% Move
delta = 2*rand(1,d)-.5;
tmpf = 2*pm.*(rand(1,d)-0.5);
msp(i,:) = msp(i,:)+(wmean-msp(i,:)).*delta+tmpf;
end
end
% Check limits
for i=1:d
for j=1:mn
if msp(j,i)<lb(i), msp(j,i)=lb(i)+(ub(i)-lb(i)).*rand(1,1); end
if msp(j,i)==lb(i), msp(j,i)=lb(i); end
if msp(j,i)>ub(i), msp(j,i)=lb(i)+(ub(i)-lb(i)).*rand(1,1); end
if msp(j,i)==ub(i), msp(j,i)=ub(i); end
end
end
end
3 仿真结果
4 参考文献
[1]黄超杰, 胡成华. 一种求解柔性作业车间调度问题的群居蜘蛛优化算法:, CN106611214A[P]. 2017.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,有科研问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。