【优化求解】基于收敛因子和黄金正弦指引机制的蝴蝶优化算法求解单目标优化问题matlab代码(AGSABOA)

发布时间:2026/8/20 22:09:41

【优化求解】基于收敛因子和黄金正弦指引机制的蝴蝶优化算法求解单目标优化问题matlab代码(AGSABOA)
1 简介针对蝴蝶优化算法(butterfly optimization algorithm,BOA)中存在的局部开采和全局探索能力不均衡,易陷入局部最优值,收敛精度低等缺陷,提出收敛因子和黄金正弦指引机制的蝴蝶优化算法(convergence factor and gold sinusoidal guidance mechanism of butterfly optimization algorithm,AGSABOA).受到鲸鱼优化算法的启发将收敛因子融入算法的全局位置更新处,提高算法全局搜索的多样性;结合黄金正弦指引机制,弥补BOA算法迭代后期种群多样性下降,易陷入局部最优的不足.选取9个常用的基准测试函数进行的仿真结果表明,AGSABOA算法在寻优精度,收敛速度,鲁棒性方面更优.2 部分代码%% Monarch Butterfly Optimization (MBO) % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %% %% Notes: % Different run may generate different solutions, this is determined by % the the nature of metaheuristic algorithms. %% function [MinCost] MBO(ProblemFunction, DisplayFlag, RandSeed) % Monarch Butterfly Optimization (MBO) software for minimizing a general function % The fixed Function Evaluations (FEs) is considered as termination condition. % INPUTS: ProblemFunction is the handle of the function that returns % the handles of the initialization, cost, and feasibility functions. % DisplayFlag true or false, whether or not to display and plot results. % ProbFlag true or false, whether or not to use probabilities to update emigration rates. % RandSeed random number seed % OUTPUTS: MinCost array of best solution, one element for each generation % Hamming final Hamming distance between solutions % CAVEAT: The ClearDups function that is called below replaces duplicates with randomly-generated % individuals, but it does not then recalculate the cost of the replaced individuals. tic if ~exist(ProblemFunction, var) ProblemFunction Ackley; end if ~exist(DisplayFlag, var) DisplayFlag true; end if ~exist(RandSeed, var) RandSeed round(sum(100*clock)); end [OPTIONS, MinCost, AvgCost, InitFunction, CostFunction, FeasibleFunction, ... MaxParValue, MinParValue, Population] Init(DisplayFlag, ProblemFunction, RandSeed); nEvaluations OPTIONS.popsize; % % % % % % % % % % % % Initial parameter setting % % % % % % % % % % % %%%% %% Initial parameter setting Keep 2; % elitism parameter: how many of the best habitats to keep from one generation to the next maxStepSize 1.0; %Max Step size partition OPTIONS.partition; numButterfly1 ceil(partition*OPTIONS.popsize); % NP1 in paper numButterfly2 OPTIONS.popsize - numButterfly1; % NP2 in paper period 1.2; % 12 months in a year Land1 zeros(numButterfly1, OPTIONS.numVar); Land2 zeros(numButterfly2, OPTIONS.numVar); BAR partition; % you can change the BAR value in order to get much better performance % % % % % % % % % % % % End of Initial parameter setting % % % % % % % % % % % %% %% % % % % % % % % % % % % Begin the optimization loop % % % % % % % % % %%%% % Begin the optimization loop GenIndex 1; % for GenIndex 1 : OPTIONS.Maxgen while nEvaluations OPTIONS.MaxFEs % % % % % % % % % % % % Elitism Strategy % % % % % % % % % % % %%%%% %% Save the best monarch butterflis in a temporary array. for j 1 : Keep chromKeep(j,:) Population(j).chrom; costKeep(j) Population(j).cost; end % % % % % % % % % % % % End of Elitism Strategy % % % % % % % % % % % %%%% %% % % % % % % % % % % % % Divide the whole population into two subpopulations % % % %%% %% Divide the whole population into Population1 (Land1) and Population2 (Land2) % according to their fitness. % The monarch butterflis in Population1 are better than or equal to Population2. % Of course, we can randomly divide the whole population into Population1 and Population2. % We do not test the different performance between two ways. for popindex 1 : OPTIONS.popsize if popindex numButterfly1 Population1(popindex).chrom Population(popindex).chrom; else Population2(popindex-numButterfly1).chrom Population(popindex).chrom; end end % % % % % % % % % % % End of Divide the whole population into two subpopulations % % %%% %% % % % % % % % % % % % %% Migration operator % % % % % % % % % % % %%%% %% Migration operator for k1 1 : numButterfly1 for parnum1 1 : OPTIONS.numVar r1 rand*period; if r1 partition r2 round(numButterfly1 * rand 0.5); Land1(k1,parnum1) Population1(r2).chrom(parnum1); else r3 round(numButterfly2 * rand 0.5); Land1(k1,parnum1) Population2(r3).chrom(parnum1); end end %% for parnum1 NewPopulation1(k1).chrom Land1(k1,:); end %% for k1 % % % % % % % % % % % %%% End of Migration operator % % % % % % % % % % % %%% %% % % % % % % % % % % % % Evaluate NewPopulation1 % % % % % % % % % % % %% %% Evaluate NewPopulation1 SavePopSize OPTIONS.popsize; OPTIONS.popsize numButterfly1; % Make sure each individual is legal. NewPopulation1 FeasibleFunction(OPTIONS, NewPopulation1); % Calculate cost NewPopulation1 CostFunction(OPTIONS, NewPopulation1); % the number of fitness evaluations nEvaluations nEvaluations OPTIONS.popsize; OPTIONS.popsize SavePopSize; % % % % % % % % % % % % End of Evaluate NewPopulation1 % % % % % % % % % % % %% %% % % % % % % % % % % % % Butterfly adjusting operator % % % % % % % % % % % %% %% Butterfly adjusting operator for k2 1 : numButterfly2 scale maxStepSize/(GenIndex^2); %Smaller step for local walk StepSzie ceil(exprnd(2*OPTIONS.Maxgen,1,1)); delataX LevyFlight(StepSzie,OPTIONS.numVar); for parnum2 1:OPTIONS.numVar, if (rand partition) Land2(k2,parnum2) Population(1).chrom(parnum2); else r4 round(numButterfly2*rand 0.5); Land2(k2,parnum2) Population2(r4).chrom(1); if (rand BAR) % Butterfly-Adjusting rate Land2(k2,parnum2) Land2(k2,parnum2) scale*(delataX(parnum2)-0.5); end end end %% for parnum2 NewPopulation2(k2).chrom Land2(k2,:); end %% for k2 % % % % % % % % % % % % End of Butterfly adjusting operator % % % % % % % % % % % % %% % % % % % % % % % % % % Evaluate NewPopulation2 % % % % % % % % % % % %% %% Evaluate NewPopulation2 SavePopSize OPTIONS.popsize; OPTIONS.popsize numButterfly2; % Make sure each individual is legal. NewPopulation2 FeasibleFunction(OPTIONS, NewPopulation2); % Calculate cost NewPopulation2 CostFunction(OPTIONS, NewPopulation2); % the number of fitness evaluations nEvaluations nEvaluations OPTIONS.popsize; OPTIONS.popsize SavePopSize; % % % % % % % % % % % % End of Evaluate NewPopulation2 % % % % % % % % % % % %% %% % % % % % % % Combine two subpopulations into one and rank monarch butterflis % % % % % % %% Combine Population1 with Population2 to generate a new Population Population CombinePopulation(OPTIONS, NewPopulation1, NewPopulation2); % Sort from best to worst Population PopSort(Population); % % % % % % End of Combine two subpopulations into one and rank monarch butterflis % %% % % %% % % % % % % % % % % % % Elitism Strategy % % % % % % % % % % % %%% %% % %% Replace the worst with the previous generations elites. n length(Population); for k3 1 : Keep Population(n-k31).chrom chromKeep(k3,:); Population(n-k31).cost costKeep(k3); end % end for k3 % % % % % % % % % % % % End of Elitism Strategy % % % % % % % % % % % %%% %% % %% % % % % % % % % % % Precess and output the results % % % % % % % % % % % %%% % Sort from best to worst Population PopSort(Population); % Compute the average cost [AverageCost, nLegal] ComputeAveCost(Population); % Display info to screen MinCost [MinCost Population(1).cost]; AvgCost [AvgCost AverageCost]; if DisplayFlag disp([The best and mean of Generation # , num2str(GenIndex), are ,... num2str(MinCost(end)), and , num2str(AvgCost(end))]); end % % % % % % % % % % % End of Precess and output the results %%%%%%%%%% %% % %% %% Update generation number GenIndex GenIndex1; end % end for GenIndex Conclude2(DisplayFlag, OPTIONS, Population, nLegal, MinCost, AvgCost); toc % % % % % % % % % % End of Monarch Butterfly Optimization implementation %%%% %% % %% function [delataX] LevyFlight(StepSize, Dim) %Allocate matrix for solutions delataX zeros(1,Dim); %Loop over each dimension for i1:Dim % Cauchy distribution fx tan(pi * rand(1,StepSize)); delataX(i) sum(fx); end3 仿真结果4 参考文献[1]高文欣、刘升、肖子雅、于建芳. 收敛因子和黄金正弦指引机制的蝴蝶优化算法[J]. 计算机工程与设计, 2020, 41(12):6.博主简介擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真有科研问题可私信交流。部分理论引用网络文献若有侵权联系博主删除。

相关新闻

Programming for Kids之calc:用摩尔斯电码打造孩子的第一台计算器

Programming for Kids之calc:用摩尔斯电码打造孩子的第一台计算器

2026/8/20 21:59:41

Programming for Kids之calc:用摩尔斯电码打造孩子的第一台计算器 【免费下载链接】programming-for-kids book for parents and kids. 项目地址: https://gitcode.com/gh_mirrors/pr/programming-for-kids 如果说有什么装置能同时点亮"电子"和&qu…

四步玩转 MediaCrawler-new:一文搞定小红书、抖音、快手、B站、微博五大平台数据采集

四步玩转 MediaCrawler-new:一文搞定小红书、抖音、快手、B站、微博五大平台数据采集

2026/8/20 21:59:41

四步玩转 MediaCrawler-new:一文搞定小红书、抖音、快手、B站、微博五大平台数据采集 【免费下载链接】MediaCrawler-new 项目地址: https://gitcode.com/GitHub_Trending/me/MediaCrawler-new 想批量拿到小红书、抖音、快手、B站、微博的笔记、视频、评论和…

Tauri Tutorial 快速开始:只需 2 条命令启动你的第一个跨端桌面应用

Tauri Tutorial 快速开始:只需 2 条命令启动你的第一个跨端桌面应用

2026/8/20 21:59:41

Tauri Tutorial 快速开始:只需 2 条命令启动你的第一个跨端桌面应用 【免费下载链接】tauri-tutorial 📚 Tauri Tutorial (系列教程 - 打造属于自己的跨端应用) 项目地址: https://gitcode.com/gh_mirrors/ta/tauri-tutorial Tauri Tutorial 是一…

蓝桥杯Vue

蓝桥杯Vue

2026/8/20 23:19:45

el-rate 组件 show-score 属性详解1. 作用show-score 是 Element UI 评分(el-rate)内置布尔属性:加上 show-score:星星右侧实时显示当前打分数字分值不写该属性:只展示星星,不显示分数数字 默认值&#xff…

基于MQTT与ESP8266的物联网遥控车:从游戏手柄到物理执行

基于MQTT与ESP8266的物联网遥控车:从游戏手柄到物理执行

2026/8/20 23:19:45

1. 项目缘起:当游戏手柄遇上遥控车几年前,我在整理旧物时翻出了一台尘封已久的玩具遥控车。它结构简单,一个塑料底盘,两个直流电机驱动后轮,一个舵机控制前轮转向。看着它,一个念头突然冒了出来&#xff1a…

OR值与HR值Meta分析结果解读:森林图与漏斗图解读

OR值与HR值Meta分析结果解读:森林图与漏斗图解读

2026/8/20 23:19:45

OR值和HR值Meta分析结果解读 一、方法概述 Meta分析是一种将多项独立研究结果进行定量合并的统计分析方法,其核心思想是通过加权平均的方式增大样本信息量,从而提高统计检验效能并获得更为精确的效应量估计。在医学、流行病学及社会科学领域&#xff0…

K均值聚类结果解读:轮廓系数与聚类中心特征

K均值聚类结果解读:轮廓系数与聚类中心特征

2026/8/20 23:19:45

K均值聚类分析结果解读一、分析方法介绍K均值聚类分析(K-means Clustering)是一种经典的无监督学习方法,其基本思想是将n个样本划分为k个互不重叠的簇(cluster),使得每个样本到其所属簇中心的距离最小化。该…

IGBT驱动电路设计:从核心原理到工程实践的关键技术解析

IGBT驱动电路设计:从核心原理到工程实践的关键技术解析

2026/8/20 23:19:45

1. 从“开关”到“心脏”:为什么IGBT驱动如此关键如果你拆开一台变频空调、一台工业变频器,或者一辆电动汽车的电机控制器,在密密麻麻的电路板深处,你总会找到几个被巨大散热片压着的黑色方块——那就是IGBT。很多人把IGBT称为电力…

从1只到30只:PKHeX-Plugins 把宝可梦数据合法化与批量生成变成几次点击

从1只到30只:PKHeX-Plugins 把宝可梦数据合法化与批量生成变成几次点击

2026/8/20 23:09:44

从1只到30只:PKHeX-Plugins 把宝可梦数据合法化与批量生成变成几次点击 【免费下载链接】PKHeX-Plugins Plugins for PKHeX 项目地址: https://gitcode.com/gh_mirrors/pk/PKHeX-Plugins 如果你也曾在深夜对着宝可梦编辑器里那一排"红色感叹号"束手…

【文章复现】非线性值迭代自适应动态规划(ADP):离散时间非线性系统的策略迭代自适应动态规划算法研究附Matlab代码

【文章复现】非线性值迭代自适应动态规划(ADP):离散时间非线性系统的策略迭代自适应动态规划算法研究附Matlab代码

2026/8/19 3:36:59

✅作者简介:热爱科研的Matlab仿真开发者,擅长毕业设计辅导、数学建模、数据处理、建模仿真、程序设计、完整代码获取、论文复现及科研仿真。🍎 往期回顾关注个人主页:Matlab科研工作室👇 关注我领取海量matlab电子书和…

【双层规划,节点出清价,绿证交易,CVaR方法】两级电力市场环境下计及风险的省间交易商最优购电模型附Matlab代码

【双层规划,节点出清价,绿证交易,CVaR方法】两级电力市场环境下计及风险的省间交易商最优购电模型附Matlab代码

2026/8/20 21:07:35

✅作者简介:热爱科研的Matlab仿真开发者,擅长毕业设计辅导、数学建模、数据处理、建模仿真、程序设计、完整代码获取、论文复现及科研仿真。🍎 往期回顾关注个人主页:Matlab科研工作室👇 关注我领取海量matlab电子书和…

隐式mpc+自适应mpc+时变mpc,线性时变模型预测控制附Simulink仿真

隐式mpc+自适应mpc+时变mpc,线性时变模型预测控制附Simulink仿真

2026/8/19 8:02:16

✅作者简介:热爱科研的Matlab仿真开发者,擅长毕业设计辅导、数学建模、数据处理、建模仿真、程序设计、完整代码获取、论文复现及科研仿真。🍎 往期回顾关注个人主页:Matlab科研工作室👇 关注我领取海量matlab电子书和…

微信聊天记录如何完整导出?WeChatMsg备份指南:HTML/Word/CSV一键转换

微信聊天记录如何完整导出?WeChatMsg备份指南:HTML/Word/CSV一键转换

2026/8/20 0:08:45

微信聊天记录如何完整导出?WeChatMsg备份指南:HTML/Word/CSV一键转换 【免费下载链接】WeChatMsg 提取微信聊天记录,将其导出成HTML、Word、CSV文档永久保存,对聊天记录进行分析生成年度聊天报告 项目地址: https://gitcode.com…

B站缓存m4s打不开?m4s-converter无损合成MP4,实测1.46GB仅5秒

B站缓存m4s打不开?m4s-converter无损合成MP4,实测1.46GB仅5秒

2026/8/20 0:08:45

B站缓存m4s打不开?m4s-converter无损合成MP4,实测1.46GB仅5秒 【免费下载链接】m4s-converter 一个跨平台小工具,将bilibili缓存的m4s格式音视频文件合并成mp4 项目地址: https://gitcode.com/gh_mirrors/m4/m4s-converter 判断你是否…

告别白模时代:Blender3mfFormat 让 3MF 导入导出一次跑通设计到打印

告别白模时代:Blender3mfFormat 让 3MF 导入导出一次跑通设计到打印

2026/8/20 0:08:45

告别白模时代:Blender3mfFormat 让 3MF 导入导出一次跑通设计到打印 【免费下载链接】Blender3mfFormat Blender add-on to import/export 3MF files 项目地址: https://gitcode.com/gh_mirrors/bl/Blender3mfFormat 按 3MF 官方规范的字面意思,一…

摆脱论文困扰!盘点2026年全网爆红的的AI论文写作工具

摆脱论文困扰!盘点2026年全网爆红的的AI论文写作工具

2026/8/17 12:00:53

一天写完毕业论文在2026年已不再是天方夜谭。2026年最炸裂、实测能大幅提速的AI论文写作工具,覆盖选题构思、文献整理、内容生成、格式排版等核心场景,真正帮你高效搞定论文难题。 一、全流程王者:一站式搞定论文全链路(一天定稿首…

导师推荐!2026最新AI论文工具测评与实用推荐

导师推荐!2026最新AI论文工具测评与实用推荐

2026/8/15 10:10:27

2026年真正好用的AI论文工具,核心看生成的论文质量、低AI味、格式正确、学术适配四大指标。综合实测,千笔AI、ThouPen、豆包、DeepSeek、Grammarly 是当前最值得推荐的梯队,覆盖从免费到付费、从中文到英文、从文科到理工的全场景需求。 一、…

告别游戏崩溃:XCOM 2模组管理器的智能革命

告别游戏崩溃:XCOM 2模组管理器的智能革命

2026/8/18 12:20:24

告别游戏崩溃:XCOM 2模组管理器的智能革命 【免费下载链接】xcom2-launcher The Alternative Mod Launcher (AML) is a replacement for the default game launchers from XCOM 2 and XCOM Chimera Squad. 项目地址: https://gitcode.com/gh_mirrors/xc/xcom2-lau…