猎豹优化算法(Cheetah Optimizaer,CO)是一种新型群智能优化算法,该算法是Mohammad AminAkbari等人于2022年受自然界猎豹狩猎启发而提出一种新型群体智能优化算法,通过模拟猎豹在狩猎过程中搜索、坐等和攻击3种策略来实现位置更新,具有寻优能力强,收敛速度快等特点。该成果于2022年发表在知名SCI期刊Scientific Reports上,目前在谷歌学术上被引60次。
猎豹是生活在伊朗和非洲中部地区的主要猫科动物品种和速度最快的陆地动物。猎豹的时速可达120公里以上。猎豹是一种行动敏捷的动物,能隐蔽行动,捕食时能快速返回。
当猎豹巡逻或扫描周围环境时,有可能发现猎物。看到猎物后,猎豹可能会坐在原地等待猎物靠近,然后开始攻击。攻击模式包括冲撞和捕捉阶段。通过评估猎物、猎物状况、猎物区域和距离,猎豹可以选择其中一种策略,其行为如下图所示。
1、算法原理
(1)搜索策略
猎豹以两种方式寻找猎物;坐着或站着时扫描环境或积极巡逻周围地区。扫描模式更适合于猎物密集且在平原上行走时的情况。另一方面,如果猎物是分散和活跃的,那么选择比扫描模式需要更多能量的主动模式会更好。因此,在狩猎期间,根据猎物的情况,区域的覆盖范围以及猎豹本身的情况,猎豹可能会选择这两种搜索模式的连锁。为了对猎豹的这种搜索策略进行数学建模。
令Xt i,j表示猎豹i(i = 1,2,...,n)在排列j(j = 1,2,...,D)中的当前位置,其中n是猎豹种群的数量,D是优化问题的维数。事实上,每只猎豹在处理各种猎物时都会经历不同的情况。当猎豹的状态(其他安排)构成一个种群时,每一个猎物都是一个决策变量对应于最佳解决方案的位置。
然后,提出如下随机搜索方程,根据猎豹i在每个排列中当前的位置来更新其新位置,任意步长如下: 其中, 和 分别是第j排中猎豹i的下一个和当前位置。t是最大的狩猎时间长度。 和 分别是排列j中的猎豹i的随机化参数和步长。第二项是随机化项,其中随机化参数 是来自标准正态分布的正态随机数。
在大多数情况下,步长 > 0,可以设置为0.001 × t/ t,因为猎豹是缓慢行走的搜索者。在遇到其他猎人时,猎豹可能会迅速逃跑并改变方向。为了反映这种行为以及近/远的目标搜索模式,这里使用随机数 来表示不同狩猎时期的每只猎豹。
在某些情况下,αt i,j可以通过猎豹i和它的邻居或首领之间的距离来调整。假设αt i,j = 0.001 × t/ t乘以最大步长来更新领头在每个猎豹排列中的位置。对于其他成员,每个猎豹排列中的αt i,j是通过乘以猎豹i的位置与随机选择的猎豹之间的距离来计算的。
(2)坐等策略
在搜索模式下,猎物可能会暴露在猎豹的视野中。在这种情况下,猎豹的每一个动作都可能使猎物意识到它的存在,从而导致猎物逃跑。为了避免这种担心,猎豹可能决定伏击(躺在地上或藏在灌木丛中),以足够接近猎物。因此,在这种模式下,猎豹会保持原地不动,等待猎物靠近。这种行为可以建模如下: 其中,Xt+1 i,j和Xt i,j分别是第j排中猎豹i更新和当前的位置。该策略要求CO算法不同时改变每组中的所有猎豹,以增加狩猎的成功率,因此可以帮助它避免过早收敛。
(3)攻击策略
猎豹攻击猎物有两个关键因素:速度和灵活性。当猎豹决定攻击时,它会全速冲向猎物。过了一段时间,猎物注意到猎豹的攻击,开始逃跑。猎豹以其敏锐的目光在截击路径上快速追赶猎物。
由于猎豹以最快的速度与猎物的距离很短,所以猎物为了生存必须逃跑,并突然改变位置,即猎豹的下一个位置靠近猎物的最后一个位置。同样,可能有一只猎豹没有参与完全匹配猎豹自然狩猎的攻击策略。在这一阶段,猎豹利用速度和灵活性来捕获猎物。在群体狩猎法中,每只猎豹可能会根据逃跑的猎物和领头猎豹或邻近猎豹的位置调整自己的位置。简单地说,这些猎豹的攻击策略可以用数学方法定义如下: 其中 是排列j中猎物当前的位置,也是种群当前的最佳位置。ˇri,j,βt i,j分别是排列j中与猎豹i相关的转弯因子和交互因子。转弯因子ˇri,j是标准正态分布的随机数,反映了猎豹在捕捉模式下的急转弯。
CO算法的图形策略信息如下。
2、结果展示
3、matlab核心代码
clc;
clear all;
close all;
%% Problem Definition
f_name=['F1';'F2';'F3';'F4';'F5';'F6';'F7';'F8';'F9'];
f_name1=['F10';'F11';'F12';'F13';'F14';'F15';'F16';'F17';'F18';'F19';'F20';'F21';'F22';'F23'];
tic
for fnm = 1 % Test functions
for run = 1 : 1
%% Problem definition (Algorithm 1, L#1)
if fnm <= 9
Function_name = f_name(fnm,:);
else
Function_name = f_name1(fnm-9,:);
end
[lb,ub,D,fobj] = Get_Functions_details(Function_name); % The shifted functions' information
D = 100; % Number of Decision Variables
if length(lb) == 1
ub = ub.*ones(1,D); % Lower Bound of Decision Variables
lb = lb.*ones(1,D); % Upper Bound of Decision Variables
end
n = 6; % Population Size
m = 2; % Number of search agenets in a group
%% Generate initial population of cheetahs (Algorithm 1, L#2)
empty_individual.Position = [];
empty_individual.Cost = [];
BestSol.Cost = inf;
pop = repmat(empty_individual,n,1);
for i=1:n
pop(i).Position = lb+rand(1,D).*(ub-lb);
pop(i).Cost = fobj(pop(i).Position);
if pop(i).Cost < BestSol.Cost
BestSol = pop(i); % Initial leader position
end
end
%% Initialization (Algorithm 1, L#3)
pop1 = pop; % Population's initial home position
BestCost = []; % Leader fittnes value in a current hunting period
X_best = BestSol; % Prey solution sofar
Globest = BestCost; % Prey fittnes value sofar
%% Initial parameters
t = 0; % Hunting time counter (Algorithm 1, L#4)
it = 1; % Iteration counter(Algorithm 1, L#5)
MaxIt = D*10000; % Maximum number of iterations (Algorithm 1, L#6)
T = ceil(D/10)*60; % Hunting time (Algorithm 1, L#7)
FEs = 0; % Counter for function evaluations (FEs)
%% CO Main Loop
while FEs <= MaxIt % Algorithm 1, L#8
% m = 1+randi (ceil(n/2));
i0 = randi(n,1,m); % select a random member of cheetahs (Algorithm 1, L#9)
for k = 1 : m % Algorithm 1, L#10
i = i0(k);
% neighbor agent selection (Algorithm 1, L#11)
if k == length(i0)
a = i0(k-1);
else
a = i0(k+1);
end
X = pop(i).Position; % The current position of i-th cheetah
X1 = pop(a).Position; % The neighbor position
Xb = BestSol.Position; % The leader position
Xbest = X_best.Position;% The pery position
kk=0;
% Uncomment the follwing statements, it may improve the performance of CO
if i<=2 && t>2 && t>ceil(0.2*T+1) && abs(BestCost(t-2)-BestCost(t-ceil(0.2*T+1)))<=0.0001*Globest(t-1)
X = X_best.Position;
kk = 0;
elseif i == 3
X = BestSol.Position;
kk = -0.1*rand*t/T;
else
kk = 0.25;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if mod(it,100)==0 || it==1
xd = randperm(numel(X));
end
Z = X;
%% Algorithm 1, L#12
for j = xd % select arbitrary set of arrangements
%% Algorithm 1, L#13
r_Hat = randn; % Randomization paameter, Equation (1)
r1 = rand;
if k == 1 % The leader's step length (it is assumed that k==1 is associated to the leade number)
alpha = 0.0001*t/T.*(ub(j)-lb(j)); % Step length, Equation (1) %This can be updated by desired equation
else % The members' step length
alpha = 0.0001*t/T*abs(Xb(j)-X(j))+0.001.*round(double(rand>0.9));%member step length, Equation (1)%This can be updated by desired equation
end
r = randn;
r_Check = abs(r).^exp(r/2).*sin(2*pi*r); % Turning factor, Equation (3)%This can be updated by desired equation
beta = X1(j)-X(j); % Interaction factor, Equation (3)
h0 = exp(2-2*t/T);
H = abs(2*r1*h0-h0);
%% Algorithm 1, L#14
r2 = rand;
r3 = kk+rand;
%% Strategy selection mechanism
if r2 <= r3 % Algorithm 1, L#15
r4 = 3*rand; % Algorithm 1, L#16
if H > r4 % Algorithm 1, L#17
Z(j) = X(j)+r_Hat.^-1.*alpha; % Search, Equation(1) (Algorithm 1, L#18)
else
Z(j) = Xbest(j)+r_Check.*beta; % Attack, Equation(3) (Algorithm 1, L#20)
end
else
Z(j) = X(j); % Sit&wait, Equation(2) (Algorithm 1, L#23)
end
end
%% Update the solutions of member i (Algorithm 1, L#26)
% Check the limits
xx1=find(Z<lb);
Z(xx1)=lb(xx1)+rand(1,numel(xx1)).*(ub(xx1)-lb(xx1));
xx1=find(Z>ub);
Z(xx1)=lb(xx1)+rand(1,numel(xx1)).*(ub(xx1)-lb(xx1));
% Evaluate the new position
NewSol.Position = Z;
NewSol.Cost = fobj(NewSol.Position);
if NewSol.Cost < pop(i).Cost
pop(i) = NewSol;
if pop(i).Cost < BestSol.Cost
BestSol = pop(i);
end
end
FEs = FEs+1;
end
t = t+1; % (Algorithm 1, L#28)
%% Leave the prey and go back home (Algorithm 1, L#29)
if t>T && t-round(T)-1>=1 && t>2
if abs(BestCost(t-1)-BestCost(t-round(T)-1))<=abs(0.01*BestCost(t-1))
% Change the leader position (Algorithm 1, L#30)
best = X_best.Position;
j0=randi(D,1,ceil(D/10*rand));
best(j0) = lb(j0)+rand(1,length(j0)).*(ub(j0)-lb(j0));
BestSol.Cost = fobj(best);
BestSol.Position = best; % Leader's new position
FEs = FEs+1;
i0 = randi(n,1,round(1*n));
% Go back home, (Algorithm 1, L#30)
pop(i0(n-m+1:n)) = pop1(i0(1:m)); % Some members back their initial positions
pop(i) = X_best; % Substitude the member i by the prey (Algorithm 1, L#31)
t = 1; % Reset the hunting time (Algorithm 1, L#32)
end
end
it = it +1; % Algorithm 1, L#34
%% Update the prey (global best) position (Algorithm 1, L#35)
if BestSol.Cost<X_best.Cost
X_best=BestSol;
end
BestCost(t)=BestSol.Cost;
Globest(1,t)=X_best.Cost;
%% Display
if mod(it,500)==0
disp([' FEs>> ' num2str(FEs) ' BestCost = ' num2str(Globest(t))]);
end
end
% fit(run) = Globest(end) ;
% mean_f = mean (fit);
% std_f = std (fit);
% clc
end
end
toc
参考文献
[1] Akbari M A, Zare M, Azizipanah-Abarghooee R, et al. The cheetah optimizer: A nature-inspired metaheuristic algorithm for large-scale optimization problems[J]. Scientific reports, 2022, 12(1): 10953.
完整代码获取方式:后台回复关键字:
TGDM199