1 简介
2 部分代码
function [sFeat,Sf,Nf,curve] = jSSA2(feat,label,N,max_Iter,HO)
lb = 0;
ub = 1;
thres = 0.5;
fun = @jFitnessFunction;
dim = size(feat,2);
X = zeros(N,dim);
for i = 1:N
for d = 1:dim
X(i,d) = lb + (ub - lb) * rand();
end
end
% Pre
fit = zeros(1,N);
fitF = inf;
curve = inf;
t = 1;
%---Iteration start----------------------------------------------------
while t <= max_Iter
for i = 1:N
fit(i) = fun(feat,label,(X(i,:) > thres),HO);
if fit(i) < fitF
Xf = X(i,:);
fitF = fit(i);
end
end
% Additional sort in the first iteration to improve the
% initial behavior by divide salps into leader and followers
if t == 1
[fit, idx] = sort(fit,'ascend');
X = X(idx,:);
end
c1 = 2 * exp(-(4 * t / max_Iter) ^ 2);
for i = 1:N
if i == 1
for d = 1:dim
c2 = rand();
c3 = rand();
if c3 >= 0.5
X(i,d) = Xf(d) + c1 * ((ub - lb) * c2 + lb);
else
X(i,d) = Xf(d) - c1 * ((ub - lb) * c2 + lb);
end
end
else
for d = 1:dim
X(i,d) = (X(i,d) + X(i-1,d)) / 2;
end
end
XB = X(i,:); XB(XB > ub) = ub; XB(XB < lb) = lb;
X(i,:) = XB;
end
curve(t) = fitF;
fprintf('\nIteration %d Best (SSA)= %f',t,curve(t))
t = t + 1;
end
Pos = 1:dim;
Sf = Pos((Xf > thres) == 1);
Nf = length(Sf);
sFeat = feat(:,Sf);
end
3 仿真结果
4 参考文献
[1]范千、陈振健、夏樟华. 一种基于折射反向学习机制与自适应控制因子的改进樽海鞘群算法[J]. 哈尔滨工业大学学报, 2020, 52(10):9.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,有科研问题可私信交流。
**部分理论引用网络文献,若有侵权联系博主删除。**
完整代码获取关注微信公众号天天matlab