# 【樽海鞘算法】基于疯狂自适应的樽海鞘算法求解单目标优化问题附matlab代码

+关注继续查看

✅作者简介：热爱科研的Matlab仿真开发者，修心和技术同步精进，matlab项目合作可私信。

🍎个人主页：Matlab科研工作室

🍊个人信条：格物致知。

## ⛄ 部分代码

%_________________________________________________________________________________

%  Salp Swarm Algorithm (SSA) source codes version 1.0

%

%  Developed in MATLAB R2016a

%

%  Author and programmer: Seyedali Mirjalili

%

%         e-Mail: ali.mirjalili@gmail.com

%                 seyedali.mirjalili@griffithuni.edu.au

%

%       Homepage: http://www.alimirjalili.com

%

%   Main paper:

%   S. Mirjalili, A.H. Gandomi, S.Z. Mirjalili, S. Saremi, H. Faris, S.M. Mirjalili,

%   Salp Swarm Algorithm: A bio-inspired optimizer for engineering design problems

%____________________________________________________________________________________

function [FoodFitness,FoodPosition,Convergence_curve]=SSA(N,Max_iter,lb,ub,dim,fobj)

if size(ub,1)==1

ub=ones(dim,1)*ub;

lb=ones(dim,1)*lb;

end

Convergence_curve = zeros(1,Max_iter);

%Initialize the positions of salps

SalpPositions=initialization(N,dim,ub,lb);

FoodPosition=zeros(1,dim);

FoodFitness=inf;

%calculate the fitness of initial salps

for i=1:size(SalpPositions,1)

SalpFitness(1,i)=fobj(SalpPositions(i,:));

end

[sorted_salps_fitness,sorted_indexes]=sort(SalpFitness);

for newindex=1:N

Sorted_salps(newindex,:)=SalpPositions(sorted_indexes(newindex),:);

end

FoodPosition=Sorted_salps(1,:);

FoodFitness=sorted_salps_fitness(1);

%Main loop

l=2; % start from the second iteration since the first iteration was dedicated to calculating the fitness of salps

while l<Max_iter+1

c1 = 2*exp(-(4*l/Max_iter)^2); % Eq. (3.2) in the paper

for i=1:size(SalpPositions,1)

SalpPositions= SalpPositions';

if i<=N/2

for j=1:1:dim

c2=rand();

c3=rand();

%%%%%%%%%%%%% % Eq. (3.1) in the paper %%%%%%%%%%%%%%

if c3<0.5

SalpPositions(j,i)=FoodPosition(j)+c1*((ub(j)-lb(j))*c2+lb(j));

else

SalpPositions(j,i)=FoodPosition(j)-c1*((ub(j)-lb(j))*c2+lb(j));

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

end

elseif i>N/2 && i<N+1

point1=SalpPositions(:,i-1);

point2=SalpPositions(:,i);

SalpPositions(:,i)=(point2+point1)/2; % % Eq. (3.4) in the paper

end

SalpPositions= SalpPositions';

end

for i=1:size(SalpPositions,1)

Tp=SalpPositions(i,:)>ub';Tm=SalpPositions(i,:)<lb';SalpPositions(i,:)=(SalpPositions(i,:).*(~(Tp+Tm)))+ub'.*Tp+lb'.*Tm;

SalpFitness(1,i)=fobj(SalpPositions(i,:));

if SalpFitness(1,i)<FoodFitness

FoodPosition=SalpPositions(i,:);

FoodFitness=SalpFitness(1,i);

end

end

Convergence_curve(l)=FoodFitness;

l = l + 1;

end

## ⛄ 参考文献

[1]张达敏, 陈忠云, 辛梓芸,等. 基于疯狂自适应的樽海鞘群算法[J]. 控制与决策, 2020, 35(9):9.

##### ❤️部分理论引用网络文献，若有侵权联系博主删除

|
11月前
|

【电力系统】基于cplex求解综合能源系统优化问题附matlab代码
【电力系统】基于cplex求解综合能源系统优化问题附matlab代码
137 0
|
11月前
|

62 0
|
12月前
|

87 0
|
12月前
|

132 0
|
12月前
|

222 0
|
12月前
|

【TSP问题】基于状态转移算法求解旅行商问题附matlab代码
【TSP问题】基于状态转移算法求解旅行商问题附matlab代码
83 0
|
12月前
|

【无人机】基于混合粒子群算法求解无人机航迹规划问题附Matlab代码
【无人机】基于混合粒子群算法求解无人机航迹规划问题附Matlab代码
85 0
|
12月前
|

【电力系统经济调度】多元宇宙算法求解电力系统多目标优化问题附Matlab
【电力系统经济调度】多元宇宙算法求解电力系统多目标优化问题附Matlab
58 0
|
12月前
|

【多式联运】基于帝企鹅AFO 粒子群PSO 遗传GA算法求解不确定多式联运路径优化问题附matlab代码
【多式联运】基于帝企鹅AFO 粒子群PSO 遗传GA算法求解不确定多式联运路径优化问题附matlab代码
195 0
|
12月前
|

【无人机】基于遗传算法的卡车结合两架无人机求解旅行推销员问题（D2TSP）附Matlab代码
【无人机】基于遗传算法的卡车结合两架无人机求解旅行推销员问题（D2TSP）附Matlab代码
60 0