海象优化器(Walrus optimizer,WO)是期刊“EXPERT SYSTEMS WITH APPLICATIONS”(中科院一区 IF 8.3)的2024年智能优化算法
01.引言
海象优化器(Walrus optimizer,WO)的灵感来自海象通过接收关键信号(危险信号和安全信号)选择迁徙、繁殖、栖息、觅食、聚集和逃跑的行为。为了测试所提出算法的能力,使用了IEEE(电气和电子工程师协会)2021年进化计算大会(CEC)的23个标准函数和基准套件。此外,为了评估所提出的算法在解决各种现实优化问题中的实用性,对6个标准的经典工程优化问题进行了检验和比较。出于统计目的,通过考虑预定义的停止准则,进行100次独立的优化运行,以确定统计度量,包括程序的平均值、标准差和计算时间。
02.优化算法的流程
03.优化算法论文中的效果展示
04.部分代码
function [Best_Score,Best_Pos,Convergence_curve]=WO(SearchAgents_no,Max_iter,lb,ub,dim,fobj)
% Initialize Best_pos and Second_pos
Best_Pos=zeros(1,dim); Second_Pos=zeros(1,dim);
Best_Score=inf; Second_Score=inf;%change this to -inf for maximization problems
GBestX=repmat(Best_Pos,SearchAgents_no,1);
%Initialize the positions of search agents
X=initialization(SearchAgents_no,dim,ub,lb);
Convergence_curve=zeros(1,Max_iter);
% fitness=inf(SearchAgents_no,1);
P=0.4; % Proportion of females
F_number=round(SearchAgents_no*P); % Number of females
M_number=F_number; % The males are equal in number to the females
C_number=SearchAgents_no-F_number-M_number; % Number of children
t=0;% Loop counter
% fobj = @(x) funtest(x);
while t<Max_iter
for i=1:size(X,1)
Flag4ub=X(i,:)>ub;
Flag4lb=X(i,:)<lb;
X(i,:)=(X(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb; % Check boundries
fitness=fobj(X(i,:)); % Calculate objective function
if fitness<Best_Score
Best_Score=fitness;
Best_Pos=X(i,:); % Update Best_pos
end
if fitness>Best_Score && fitness<Second_Score
Second_Score=fitness;
Second_Pos=X(i,:); % Update Second_pos
end
end
Alpha=1-t/Max_iter;
Beta=1-1/(1+exp((1/2*Max_iter-t)/Max_iter*10));
A=2*Alpha; % A decreases linearly fron 2 to 0
r1=rand();
R=2*r1-1;
Danger_signal=A*R;
r2=rand();
Satey_signal=r2;
if abs(Danger_signal)>=1
r3=rand();
Rs=size(X,1);
Migration_step=(Beta*r3^2)*(X(randperm(Rs),:)-X(randperm(Rs),:));
X=X+Migration_step;
elseif abs(Danger_signal)<1
if Satey_signal>=0.5
for i = 1:M_number
xy=zeros(M_number,0);
base=7;
xy(i,1)=hal(i,base);
M=[];
m1=xy(i,:);
m1=lb+m1.*(ub-lb);
M=[M; m1];
X(i,:)=M;
end
for j = M_number+1:M_number+F_number
X(j,:) = X(j,:)+Alpha*(X(i,:)-X(j,:))+(1-Alpha)*(GBestX(j,:)-X(j,:));
end
for i = SearchAgents_no-C_number+1:SearchAgents_no
P=rand;
o=GBestX(i,:)+X(i,:).*levyFlight(dim);
X(i,:)=P*(o-X(i,:));
end
end
if Satey_signal<0.5 && abs(Danger_signal)>=0.5
for i = 1:SearchAgents_no
r4=rand;
X(i,:)=X(i,:)*R-abs(GBestX(i,:)-X(i,:))*r4^2;
end
end
if Satey_signal<0.5 && abs(Danger_signal)<0.5
for i=1:size(X,1)
for j=1:size(X,2)
theta1=rand();
a1=Beta*rand()-Beta;
b1=tan(theta1.*pi);
X1=Best_Pos(j)-a1*b1*abs(Best_Pos(j)-X(i,j));
theta2=rand();
a2=Beta*rand()-Beta;
b2=tan(theta2.*pi);
X2=Second_Pos(j)-a2*b2*abs(Second_Pos(j)-X(i,j));
X(i,j)=(X1+X2)/2;
end
end
end
end
t=t+1;
Convergence_curve(t)=Best_Score;
end
end
function halton=hal(index,base)
result=0;
f=1/base;
i=index;
while(i>0)
result=result+f*mod(i,base);
i=floor(i/base);
f=f/base;
end
halton=result;
end
function [ o ]=levyFlight(d)
beta=3/2;
sigma=(gamma(1+beta)*sin(pi*beta/2)/(gamma((1+beta)/2)*beta*2^((beta-1)/2)))^(1/beta);
u=randn(1,d)*sigma;
v=randn(1,d);
step=u./abs(v).^(1/beta);
o=step;
end
05.本代码效果图
获取代码请关注MATLAB科研小白的个人公众号(即文章下方二维码),并回复智能优化算法本公众号致力于解决找代码难,写代码怵。各位有什么急需的代码,欢迎后台留言~不定时更新科研技巧类推文,可以一起探讨科研,写作,文献,代码等诸多学术问题,我们一起进步。