一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【优化算法】蝗虫优化算法(GOA)【含Matlab源码 936期】

获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、蝗虫优化算法(GOA)简介


1 GOA数学模型



2 GOA迭代模型


3 GOA算法的基本流程


4 GOA缺点

三、部分源代码

clear all
clcSearchAgents_no=100; % Number of search agentsFunction_name='F1'; % Name of the test function that can be from F1 to F23 (Table 1,2,3 in the paper)Max_iteration=500; % Maximum numbef of iterations% Load details of the selected benchmark function
[lb,ub,dim,fobj]=Get_Functions_details(Function_name);[Target_score,Target_pos,GOA_cg_curve, Trajectories,fitness_history, position_history]=GOA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);figure('Position',[454   445   894   297])
%Draw search space
subplot(1,5,1);
func_plot(Function_name);
title('Parameter space')
xlabel('x_1');
ylabel('x_2');
zlabel([Function_name,'( x_1 , x_2 )'])
box on
axis tightsubplot(1,5,2);
hold on
for k1 = 1: size(position_history,1)for k2 = 1: size(position_history,2)plot(position_history(k1,k2,1),position_history(k1,k2,2),'.','markersize',1,'MarkerEdgeColor','k','markerfacecolor','k');end
end
plot(Target_pos(1),Target_pos(2),'.','markersize',10,'MarkerEdgeColor','r','markerfacecolor','r');
title('Search history (x1 and x2 only)')
xlabel('x1')
ylabel('x2')
box on
axis tightsubplot(1,5,3);
hold on
plot(Trajectories(1,:));
title('Trajectory of 1st grasshopper')
xlabel('Iteration#')
box on
axis tightsubplot(1,5,4);
hold on
plot(mean(fitness_history));
title('Average fitness of all grasshoppers')
xlabel('Iteration#')
box on
axis tight%Draw objective space
subplot(1,5,5);
semilogy(GOA_cg_curve,'Color','r')
title('Convergence curve')
xlabel('Iteration#');
ylabel('Best score obtained so far');
box on
axis tight
set(gcf, 'position' , [39         479        1727         267]);display(['The best solution obtained by GOA is : ', num2str(Target_pos)]);
display(['The best optimal value of the objective funciton found by GOA is : ', num2str(Target_score)]);
function [TargetFitness,TargetPosition,Convergence_curve,Trajectories,fitness_history, position_history]=GOA(N, Max_iter, lb,ub, dim, fobj)disp('GOA is now estimating the global optimum for your problem....')flag=0;
if size(ub,1)==1ub=ones(dim,1)*ub;lb=ones(dim,1)*lb;
endif (rem(dim,2)~=0) % this algorithm should be run with a even number of variables. This line is to handle odd number of variablesdim = dim+1;ub = [ub; 100];lb = [lb; -100];flag=1;
end%Initialize the population of grasshoppers
GrassHopperPositions=initialization(N,dim,ub,lb);
GrassHopperFitness = zeros(1,N);fitness_history=zeros(N,Max_iter);
position_history=zeros(N,Max_iter,dim);
Convergence_curve=zeros(1,Max_iter);
Trajectories=zeros(N,Max_iter);cMax=1;
cMin=0.00004;
%Calculate the fitness of initial grasshoppersfor i=1:size(GrassHopperPositions,1)if flag == 1GrassHopperFitness(1,i)=fobj(GrassHopperPositions(i,1:end-1));elseGrassHopperFitness(1,i)=fobj(GrassHopperPositions(i,:));endfitness_history(i,1)=GrassHopperFitness(1,i);position_history(i,1,:)=GrassHopperPositions(i,:);Trajectories(:,1)=GrassHopperPositions(:,1);
end[sorted_fitness,sorted_indexes]=sort(GrassHopperFitness);% Find the best grasshopper (target) in the first population
for newindex=1:NSorted_grasshopper(newindex,:)=GrassHopperPositions(sorted_indexes(newindex),:);
endTargetPosition=Sorted_grasshopper(1,:);
TargetFitness=sorted_fitness(1);% Main loop
l=2; % Start from the second iteration since the first iteration was dedicated to calculating the fitness of antlions
while l<Max_iter+1c=cMax-l*((cMax-cMin)/Max_iter); % Eq. (2.8) in the paperfor i=1:size(GrassHopperPositions,1)temp= GrassHopperPositions';for k=1:2:dimS_i=zeros(2,1);for j=1:Nif i~=jDist=distance(temp(k:k+1,j), temp(k:k+1,i)); % Calculate the distance between two grasshoppersr_ij_vec=(temp(k:k+1,j)-temp(k:k+1,i))/(Dist+eps); % xj-xi/dij in Eq. (2.7)xj_xi=2+rem(Dist,2); % |xjd - xid| in Eq. (2.7) s_ij=((ub(k:k+1) - lb(k:k+1))*c/2)*S_func(xj_xi).*r_ij_vec; % The first part inside the big bracket in Eq. (2.7)S_i=S_i+s_ij;endendS_i_total(k:k+1, :) = S_i;endX_new = c * S_i_total'+ (TargetPosition); % Eq. (2.7) in the paper      GrassHopperPositions_temp(i,:)=X_new'; end% GrassHopperPositionsGrassHopperPositions=GrassHopperPositions_temp;for i=1:size(GrassHopperPositions,1)% Relocate grasshoppers that go outside the search space Tp=GrassHopperPositions(i,:)>ub';Tm=GrassHopperPositions(i,:)<lb';GrassHopperPositions(i,:)=(GrassHopperPositions(i,:).*(~(Tp+Tm)))+ub'.*Tp+lb'.*Tm;% Calculating the objective values for all grasshoppersif flag == 1GrassHopperFitness(1,i)=fobj(GrassHopperPositions(i,1:end-1));elseGrassHopperFitness(1,i)=fobj(GrassHopperPositions(i,:));endfitness_history(i,l)=GrassHopperFitness(1,i);position_history(i,l,:)=GrassHopperPositions(i,:);Trajectories(:,l)=GrassHopperPositions(:,1);

四、运行结果

五、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.

【优化算法】蝗虫优化算法(GOA)【含Matlab源码 936期】相关推荐

  1. 【优化算法】灰狼优化算法(GWO)【含Matlab源码 1305期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[优化算法]灰狼优化算法(GWO)[含Matlab源码 1305期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费专栏优化 ...

  2. 【优化算法】改进的灰狼优化算法(IGWO)【含Matlab源码 1349期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[优化算法]改进的灰狼优化算法(IGWO)[含Matlab源码 1349期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费 ...

  3. 【优化算法】多目标灰狼优化算法(MOGWO)【含Matlab源码 099期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[优化算法]多目标灰狼优化算法(MOGWO)[含Matlab源码 099期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费 ...

  4. 【优化算法】改进的侏儒猫鼬优化算法(IDMO)【含Matlab源码 2314期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[优化算法]改进的侏儒猫鼬优化算法(IDMO)[含Matlab源码 2314期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: ...

  5. 【优化算法】象群游牧优化算法(EHO)【含Matlab源码 1080期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[优化算法]象群游牧优化算法(EHO)[含Matlab源码 1080期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费专 ...

  6. 【优化算法】猫群优化算法(CSO)【含Matlab源码 1071期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[优化算法]猫群优化算法(CSO)[含Matlab源码 1071期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费专栏M ...

  7. 【优化算法】黑洞模拟算法(MVO)【含Matlab源码 479期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[优化算法]黑洞模拟算法(MVO)[含Matlab源码 479期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费专栏Ma ...

  8. 【优化算法】多目标蚁狮优化算法(MOALO)【含Matlab源码 1598期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[优化算法]多目标蚁狮优化算法(MOALO)[含Matlab源码 1598期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: ...

  9. 【故障检测问题】基于matlab免疫算法求解故障检测问题【含Matlab源码 196期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[故障检测问题]基于matlab免疫算法求解故障检测问题[含Matlab源码 196期] 获取代码方式2: 通过订阅紫极神光博客付费专栏,凭 ...

  10. 【图像增强】基于matlab萤火虫算法图像对比度增强【含Matlab源码 2142期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[图像增强]基于matlab萤火虫算法图像对比度增强[含Matlab源码 2142期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方 ...

最新文章

  1. 深入浅出 Java Concurrency (29): 线程池 part 2 Executor 以及Executors[转]
  2. fetch 发送 AJAX请求
  3. LCS(最长公共子串)系列问题
  4. 每天一道LeetCode-----删除链表倒数第n个节点
  5. JAVA框架Struts2 结果页配置
  6. Together与Visual.Studio.NET的结合使用(三)
  7. 全局曝光和卷帘曝光的区别
  8. leetCode 题 - 100. 相同的树
  9. [Unity脚本运行时更新]C#5新特性
  10. Bailian2749 分解因数【递归+枚举】
  11. Python--day26--封装和@property
  12. Oracle数据库性能优化的艺术pdf
  13. 拓端tecdat|R语言文本挖掘NASA数据网络分析,tf-idf和主题建模
  14. 拓端tecdat|Prophet在R语言中进行时间序列数据预测
  15. kafka_2.11-0.11.0.1集群搭建
  16. python 通达信公式函数,python使用通达信公式,请人用python编写如下公式,我对编程一窍不通...
  17. 数据库卡顿 sp_lock和sys.dm_tran_locks的用法
  18. 八:用MATLAB求传递函数的单位阶跃响应并绘制出曲线
  19. 关于“城市超脑DIGITAL TWIN”的一些保姆级干货
  20. Silvaco TCAD——二维工艺仿真

热门文章

  1. form表单提交的时候,传过去的值是键值对的形式
  2. NDT 算法和一些常见配准算法
  3. JIRA数据库的迁移,从HSQL到MYSQL/Oracle
  4. HDU 4050 wolf5x 概率dp 难度:1
  5. 隐马尔可夫模型模型评估及最优路径的matlab实现
  6. 20200131每日一句
  7. python全局变量的修改 线程共享全局变量
  8. 黑马程序员 Python学习笔记 之 名片管理系统
  9. Atitit nlp 自然语言处理attilax总结 目录 1.1. 主要范畴 1 1.2. 研究难点 2 2. Ati涉及的领域(文档 tts 分词 抽取 摘要 检索) 2 3. Atit
  10. Atitit 互联网技术公司防爆指南技术规范标准流程 30个危险物品