【优化算法】象群游牧优化算法(EHO)【含Matlab源码 1080期】
一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【优化算法】象群游牧优化算法(EHO)【含Matlab源码 1080期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、象群游牧优化算法(EHO)简介
象群游牧算法,是一种新提出来的元启发式智能算法,根据象群在草原上游牧的习性而建立来。象群被分为多个家族群,每个个体都向各自家族群里的家长靠拢;成年雄象在青春期会被分离出去等。以Sphere函数测试,效果相当良好。
1 象群游牧算法的数学模型
象群的游牧行为非常复杂,但是其中一些行为可以帮助我们寻找全局最优解和局部最优解。对此,进行数学建模为:
(1) 象群的每个部落都有固定数目的大象;
(2) 每次迭代中,部落中都有一定数目的大象离开部落,独自生活并与部落保持一定的联系;
(3) 每个部落都是由女族长领导-----在算法中,女族长是适应度值最大的大象。
2 部落中大象位置的更新公式
1)部落中普通大象的更新公式:
2)族长的位置更新公式:
3)公象的分离公式:
三、部分源代码
%% Elephant Herding Optimization Code
clear all;
close all;
clc;
%% Initialization parameters %%
n_clan = 5; % the number of clan
n = 10; % the number of individuals in each clan
n_KEL = 4; % the kept elephants
alpha = 0.5; % scale factor
beta = 0.1; % scale factor
T = 200; % generation maximum
D = 30; % individual dimension
Xmin = -100; % position minimum
Xmax = 100; % position maximum
t = 0; % the counter initial value
%% Initialization population %%
X = rand(n*n_clan,D)*(Xmax-Xmin)+Xmin; % generate population randomly
for i = 1:n*n_clan
Fit_X(i,:) = func(X(i,:)); % population fitness
end
%% Implement termination condition %%
while t < T
[Sa_Fit_X,I_X_a] = sort(Fit_X,'ascend'); % ascend order
I_KEL = I_X_a(1:n_KEL); % order number for KEL individuals
KEL = X(I_KEL,:); % obtain the KEL individuals
X = X(randperm(size(X,1)),:); % disorder population
%% Implement clan updating algorithm %%
for i = 1:n_clan
clan = X((i-1)*n+1:i*n,:); % obtain the clan
for j = 1:n
Fit_clan(j,:) = func(clan(j,:)); % calculate individual fitness in each clan
[Fit_Xbest,I_Xbest] = min(Fit_clan); % obtain the best fitness and order number in each clan
Xbest = clan(I_Xbest,:); % obtain the best individual in each clan
% Xbest refers to the matriarch in each clan
if X((i-1)*n+j,:) == Xbest
X_clan_center = sum(clan)/n_clan; % obtain the center individual in each clan
X((i-1)*n+j,:) = beta*X_clan_center; % update the best individual in each clan
else
X((i-1)*n+j,:) = X((i-1)*n+j,:)+alpha*(Xbest-X((i-1)*n+j,:))*rand; % update all individuals in each clan
end
end
end
%% Implement seperating operator %%
for i = 1:n_clan
clan_updated = X((i-1)*n+1:i*n,:); % obtain the clan
for j = 1:n
Fit_clan_updated(j,:) = func(clan_updated(j,:)); % calculate individual fitness in each updated clan
end
[Fit_Xworst,I_Xworst] = max(Fit_clan_updated); % the worst fitness and order number in each updated clan
X(I_Xworst,:) = rand(1,D)*(Xmax-Xmin+1)+Xmin; % replace the worst individual with a generated-randomly individual
end
for u = 1:n*n_clan
Fit_X_1(u,:) = func(X(u,:)); % population fitness
end
[Sd_Fit_X,I_X_d] = sort(Fit_X_1,'descend'); % descend order
I_X_worst = I_X_d(1:n_KEL); % order number for worst individuals
X(I_X_worst,:) = KEL; % replace the worst individuals with KEL
for v = 1:n*n_clan
Fit_X(v,:) = func(X(v,:)); % population fitness
end
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
四、运行结果
五、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.
[3]周品.MATLAB 神经网络设计与应用[M].清华大学出版社,2013.
[4]陈明.MATLAB神经网络原理与实例精解[M].清华大学出版社,2013.
[5]方清城.MATLAB R2016a神经网络设计与应用28个案例分析[M].清华大学出版社,2018.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/118437109
- 点赞
- 收藏
- 关注作者
评论(0)