%% Fire Hawk Optimizer (FHO) source code - version 1.0
% Fire Hawk Optimizer: a novel metaheuristic algorithm
% https://link.springer.com/article/10.1007/s10462-022-10173-w
%% Clear Workspace & Command Window
clc; clear all;
%% Problem Information
CostFunction = @(x) Sphere(x); % @ Cost Function
VarNumber = 10; % Number of variables;
VarMin = -10 *ones(1,VarNumber); % Lower bound of variable;
VarMax = 10 *ones(1,VarNumber); % Upper bound of variable;
%% General Parameters of the Algorithm
MaxFes = 1500 ; % Maximum number of generations
nPop = 25 ; % Maximum number of initial candidates
HN = randi([1 ceil(nPop/5)],1,1) ; % Maximum number of FireHawks
% Counters
Iter=0;
FEs=0;
%% Initialization
Pop=[]; Cost=[];
for i=1:nPop
% Initialize Positions
Pop(i,:)=unifrnd(VarMin,VarMax,[1 VarNumber]);
% Cost Function Evaluations
Cost(i,1)=CostFunction(Pop(i,:));
FEs=FEs+1;
end
% Sort Population
[Cost, SortOrder]=sort(Cost);
Pop=Pop(SortOrder,:);
BestPop=Pop(1,:);
SP=mean(Pop);
% Fire Hawks
FHPops=Pop(1:HN,:);
% Prey
Pop2=Pop(HN+1:end,:);
% Distance between Fire Hawks and Prey
for i=1:HN
nPop2=size(Pop2,1);
if nPop2<HN
break
end
Dist=[];
for q=1:nPop2
Dist(q,1)=distance(FHPops(i,:), Pop2(q,:));
end
[ ~, b]=sort(Dist);
alfa=randi(nPop2);
PopNew{i,:}=Pop2(b(1:alfa),:);
Pop2(b(1:alfa),:)=[];
if isempty(Pop2)==1
break
end
end
if isempty(Pop2)==0
PopNew{end,:}=[PopNew{end,:} ;Pop2];
end
% Update Bests
GB=Cost(1);
BestPos=BestPop;
%% Main Loop
while FEs<MaxFes
Iter=Iter+1;
PopTot=[];
Cost=[];
for i=1:size(PopNew,1)
PR=cell2mat(PopNew(i));
FHl=FHPops(i,:);
SPl=mean(PR);
Ir=unifrnd(0,1,1,2);
FHnear=FHPops(randi(HN),:);
FHl_new=FHl+(Ir(1)*GB-Ir(2)*FHnear);
FHl_new = max(FHl_new,VarMin);
FHl_new = min(FHl_new,VarMax);
PopTot=[PopTot ;FHl_new];
for q=1:size(PR,1)
Ir=unifrnd(0,1,1,2);
PRq_new1=PR(q,:)+((Ir(1)*FHl-Ir(2)*SPl));
PRq_new1 = max(PRq_new1,VarMin);
PRq_new1 = min(PRq_new1,VarMax);
PopTot=[PopTot ;PRq_new1];
Ir=unifrnd(0,1,1,2);
FHAlter=FHPops(randi(HN),:);
PRq_new2=PR(q,:)+((Ir(1)*FHAlter-Ir(2)*SP));
PRq_new2 = max(PRq_new2,VarMin);
PRq_new2 = min(PRq_new2,VarMax);
PopTot=[PopTot ;PRq_new2];
end
end
for i=1:size(PopTot,1)
Cost(i,1)=CostFunction(PopTot(i,:));
FEs=FEs+1;
end
% Sort Population
[Cost, SortOrder]=sort(Cost);
PopTot=PopTot(SortOrder,:);
Pop=PopTot(1:nPop,:);
HN = randi([1 ceil(nPop/5)],1,1);
BestPop=Pop(1,:);
SP=mean(Pop);
FHPops=Pop(1:HN,:);
Pop2=Pop(HN+1:end,:);
clear PopNew
% Distance between Fire Hawks and Prey
for i=1:HN
nPop2=size(Pop2,1);
if nPop2<HN
break
end
Dist=[];
for q=1:nPop2
Dist(q,1)=distance(FHPops(i,:), Pop2(q,:));
end
[ ~, b]=sort(Dist);
alfa=randi(nPop2);
PopNew{i,:}=Pop2(b(1:alfa),:);
Pop2(b(1:alfa),:)=[];
if isempty(Pop2)==1
break
end
end
if isempty(Pop2)==0
PopNew{end,:}=[PopNew{end,:} ;Pop2];
end
% Update Bests
if Cost(1)<GB
BestPos=BestPop;
end
GB=min(GB,Cost(1));
% Store Best Cost Ever Found
BestCosts(Iter,1)=GB;
% Show Iteration Information
disp(['Iteration ' num2str(Iter) ': Best Cost = ' num2str(BestCosts(Iter))]);
end
Eval_Number=FEs;
Conv_History=BestCosts;
Best_Pos=BestPop;
figure
xlabel('迭代次数')
ylabel('适应度值')
plot( BestCosts)
没有合适的资源?快使用搜索试试~ 我知道了~
火鹰优化算法Fire Hawk Optimizer (FHO) matlab代码
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共4个文件
m:3个
png:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
温馨提示
1.版本:matlab2019a,不会运行可私信 2.领域:基础教程 3.内容:【智能优化算法-火鹰优化算法】Fire Hawk Optimizer (FHO) matlab代码 4.适合人群:本科,硕士等教研学习使用
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 4 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- weixin_545621432023-04-05资源很受用,资源主总结的很全面,内容与描述一致,解决了我当下的问题。
- m0_749343932023-06-19这个资源内容超赞,对我来说很有价值,很实用,感谢大佬分享~
- 屹清Study_room2023-05-30总算找到了想要的资源,搞定遇到的大问题,赞赞赞!
- 2201_758863742023-04-24资源有一定的参考价值,与资源描述一致,很实用,能够借鉴的部分挺多的,值得下载。
![avatar](https://profile-avatar.csdnimg.cn/0952dabfe4084a058a29f6b3884c6064_qq_59747472.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
天天Matlab科研工作室
- 粉丝: 3w+
- 资源: 7249
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 以下是一些适用于英语六级作文的万能句型模板,涵盖了引言、正文和结论部分的各类表达方式.docx
- MATLAB中的非线性规划
- 进行C语言面试资格确认是招聘过程中一个重要的步骤,目的是确保候选人具备足够的C语言编程能力和知识.docx
- Java 轻量级的集群负载均衡设计
- 纹身师个人网站模板.jpg
- 在C语言中,连接两个字符串(即将一个字符串附加到另一个字符串的末尾)通常可以使用标准库中的 `strcat` 函数.docx
- 数据库管理工具:dbeaver-ce-23.1.1-stable.x86-64.rpm
- 以下是几个具体竞赛题目的详细解答,包括建模思路、方法和步骤 .docx
- 一份关于全国大学生建模大赛的相关教程!!
- 以下是关于计算机网络和现代通信组网的详细教程、案例和相关项目的推荐.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)