1 简介
针对基本蝴蝶优化算法(Butterfly Optimization Algorithm,BOA)存在的收敛精度较低、容易陷入局部最优解的问题,提出柯西变异和自适应权重优化的蝴蝶算法(Cauchy variation and adaptive Weight Butterfly Optimization Algorithm,CWBOA)。通过在全局位置更新处引入柯西分布函数进行变异,在局部位置更新处引入自适应权重因子,改进了蝴蝶算法的局部搜索能力;并且引入动态切换概率 p 来权衡全局探索与局部开发过程的比重。改进的算法通过对多个单峰、多峰和固定测试维度的函数进行求解,结果表明,CWBOA对大多数测试函数有更好的求解精度、速度和稳定性。
Sankalap Arora和Satvir Singh两位学者,通过观察蝴蝶觅食行为而受到启发,提出了一种新的群智能优化算法——蝴蝶优化算法(Butterfly Optimization Algorithm)[6]。该算法的主要思想是模拟蝴蝶的觅食和求偶行为实现对目标问题的求解。蝴蝶的行为可以描述为它们向食物源位置的合作运动。蝴蝶接收、感知和分析空气中的气味以确定食物源或配对伴侣的潜在方向。BOA算法模拟此行为在搜索空间中寻找最优解。与现有的一些元启发式算法相比,基本BOA操作简单、调整的参数少、鲁棒性好,并在工程实践的初步应用中取得了良好的效果。
基本的蝴蝶优化算法存在着依赖初始种群、收敛精度低和易陷入局部最优等问题,针对这些问题本文提出了一种多策略改进的蝴蝶优化算法。利用柯西分布函数对蝴蝶的全局位置更新进行变异,提升算法的全局搜索能力,在蝴蝶算法的局部位置更新处引入自适应惯性权重因子,改进了算法的局部开采能力,并且使用动态切换概率来平衡局部搜索和全局搜索的比重,提高了寻优性能。通过 14 个基准测试函数测试,结果表明改进算法具有更高的收敛精度和鲁棒性。
在自然界之中,蝴蝶可以使用它们的各种感官如:嗅觉、视觉、味觉、触觉和听觉去寻找食物和求偶,这些感觉能够帮助它们迁徙、躲避狩猎者以及帮助它们找到合适的地方产卵。在所有的感觉中最重要的是嗅觉,嗅觉能够帮助蝴蝶寻找食物(花蜜),即使在很远的地方也不例外。为了能够找到食物,蝴蝶使用感觉受体用于嗅觉,这些受体分散在蝴蝶的身体部位,如触角、腿和手掌等。这些受体实际上是蝴蝶身体表面的神经细胞,被称为化学感受器。这些化学感受器引导蝴蝶找到最佳的交配伙伴,以便继续强大的遗传系统。雄性蝴蝶能够通过信息素来识别雌性,这是雌性蝴蝶发出的气味分泌物引起特异性反应。蝴蝶会产生一些强度与其适应性相关的香味,即当蝴蝶从一个位置移动到另一个位置时,它的适应性会相应地变化,香味会在远处传播,其他蝴蝶个体能够感知它,这就是蝴蝶个体如何与其他蝴蝶共享个体信息,形成一个群体的社会知识网络。当一只蝴蝶能够闻到来自其他的蝴蝶分泌的香味的时候,它将会朝着香味最浓的方向移动,该阶段在算法中被称为全局搜索。在另一种情况下,当蝴蝶不能从周围感知香味时它将随机移动,这一阶段是局部搜索阶段。针对上述行为,提出如下假设: (1)所有的蝴蝶都应该散发一些香味,使蝴蝶能够相互吸引。 (2)每只蝴蝶都会随机移动或向发出最多香味的蝴蝶移动。 (3)蝴蝶的刺激强度受目标函数的影响或决定。 (4)全局搜索和局部搜索使用切换概率 p 来控制,受到物理接近度以及风、雨、雷、电等各种其他自然因素,局部搜索和全局搜索中的切换概率 p 具有重要意义。
2 部分代码
<span style="color:#333333"><span style="background-color:#f8f8f8"><span style="color:#aa5500">%% 清除环境变量</span>
<span style="color:#3300aa">clear</span>
<span style="color:#000000">clc</span>
<span style="color:#aa5500">%% 参数设置</span>
<span style="color:#000000">N</span> = <span style="color:#116644">30</span>; <span style="color:#aa5500">% 种群规模</span>
<span style="color:#000000">Function_name</span> = <span style="color:#aa1111">'F23'</span>; <span style="color:#aa5500">% 从F1到F23的测试函数的名称(本文中的表1、2、3)</span>
<span style="color:#000000">Max_iteration</span> = <span style="color:#116644">500</span>; <span style="color:#aa5500">% 最大迭代次数</span>
<span style="color:#000000">cnt_max</span> = <span style="color:#116644">30</span>;
<span style="color:#aa5500">% 加载所选基准函数的详细信息</span>
[<span style="color:#000000">lb</span>, <span style="color:#000000">ub</span>, <span style="color:#000000">dim</span>, <span style="color:#000000">fobj</span>] = <span style="color:#000000">Get_Functions_details</span>(<span style="color:#000000">Function_name</span>);
<span style="color:#000000">Curve_BOA</span> = <span style="color:#3300aa">zeros</span>(<span style="color:#116644">1</span>, <span style="color:#000000">Max_iteration</span>);
<span style="color:#000000">Curve_WOA</span> = <span style="color:#3300aa">zeros</span>(<span style="color:#116644">1</span>, <span style="color:#000000">Max_iteration</span>);
<span style="color:#000000">Curve_FPA</span> = <span style="color:#3300aa">zeros</span>(<span style="color:#116644">1</span>, <span style="color:#000000">Max_iteration</span>);
<span style="color:#000000">Curve_CWBOA</span> = <span style="color:#3300aa">zeros</span>(<span style="color:#116644">1</span>, <span style="color:#000000">Max_iteration</span>);
<span style="color:#770088">for</span> <span style="color:#000000">cnt</span> = <span style="color:#116644">1</span>:<span style="color:#000000">cnt_max</span>
<span style="color:#aa5500">% 初始化种群位置</span>
<span style="color:#000000">X</span> = <span style="color:#000000">initialization</span>(<span style="color:#000000">N</span>, <span style="color:#000000">dim</span>, <span style="color:#000000">ub</span>, <span style="color:#000000">lb</span>);
[<span style="color:#000000">BOA_Best_score</span>(<span style="color:#000000">cnt</span>), <span style="color:#000000">BOA_Best_pos</span>(<span style="color:#000000">cnt</span>, :), <span style="color:#000000">BOA_Curve</span>] = <span style="color:#000000">BOA</span>(<span style="color:#000000">X</span>, <span style="color:#000000">N</span>, <span style="color:#000000">Max_iteration</span>, <span style="color:#000000">lb</span>, <span style="color:#000000">ub</span>, <span style="color:#000000">dim</span>, <span style="color:#000000">fobj</span>);
[<span style="color:#000000">WOA_Best_score</span>(<span style="color:#000000">cnt</span>), <span style="color:#000000">WOA_Best_pos</span>(<span style="color:#000000">cnt</span>, :), <span style="color:#000000">WOA_Curve</span>] = <span style="color:#000000">WOA</span>(<span style="color:#000000">X</span>, <span style="color:#000000">N</span>, <span style="color:#000000">Max_iteration</span>, <span style="color:#000000">lb</span>, <span style="color:#000000">ub</span>, <span style="color:#000000">dim</span>, <span style="color:#000000">fobj</span>);
[<span style="color:#000000">FPA_Best_score</span>(<span style="color:#000000">cnt</span>), <span style="color:#000000">FPA_Best_pos</span>(<span style="color:#000000">cnt</span>, :), <span style="color:#000000">FPA_Curve</span>] = <span style="color:#000000">FPA</span>(<span style="color:#000000">X</span>, <span style="color:#000000">N</span>, <span style="color:#000000">Max_iteration</span>, <span style="color:#000000">lb</span>, <span style="color:#000000">ub</span>, <span style="color:#000000">dim</span>, <span style="color:#000000">fobj</span>);
[<span style="color:#000000">CWBOA_Best_score</span>(<span style="color:#000000">cnt</span>), <span style="color:#000000">CWBOA_Best_pos</span>(<span style="color:#000000">cnt</span>, :), <span style="color:#000000">CWBOA_Curve</span>] = <span style="color:#000000">CWBOA</span>(<span style="color:#000000">X</span>, <span style="color:#000000">N</span>, <span style="color:#000000">Max_iteration</span>, <span style="color:#000000">lb</span>, <span style="color:#000000">ub</span>, <span style="color:#000000">dim</span>, <span style="color:#000000">fobj</span>);
<span style="color:#000000">Curve_BOA</span> = <span style="color:#000000">Curve_BOA</span><span style="color:#981a1a">+</span><span style="color:#000000">BOA_Curve</span>;
<span style="color:#000000">Curve_WOA</span> = <span style="color:#000000">Curve_WOA</span><span style="color:#981a1a">+</span><span style="color:#000000">WOA_Curve</span>;
<span style="color:#000000">Curve_FPA</span> = <span style="color:#000000">Curve_FPA</span><span style="color:#981a1a">+</span><span style="color:#000000">FPA_Curve</span>;
<span style="color:#000000">Curve_CWBOA</span> = <span style="color:#000000">Curve_CWBOA</span><span style="color:#981a1a">+</span><span style="color:#000000">CWBOA_Curve</span>;
<span style="color:#770088">end</span>
<span style="color:#000000">Curve_BOA</span> = <span style="color:#000000">Curve_BOA</span><span style="color:#981a1a">/</span><span style="color:#000000">cnt_max</span>;
<span style="color:#000000">Curve_WOA</span> = <span style="color:#000000">Curve_WOA</span><span style="color:#981a1a">/</span><span style="color:#000000">cnt_max</span>;
<span style="color:#000000">Curve_FPA</span> = <span style="color:#000000">Curve_FPA</span><span style="color:#981a1a">/</span><span style="color:#000000">cnt_max</span>;
<span style="color:#000000">Curve_CWBOA</span> = <span style="color:#000000">Curve_CWBOA</span><span style="color:#981a1a">/</span><span style="color:#000000">cnt_max</span>;
<span style="color:#000000">std_BOA</span> = <span style="color:#3300aa">std</span>(<span style="color:#000000">BOA_Best_score</span>);
<span style="color:#000000">std_WOA</span> = <span style="color:#3300aa">std</span>(<span style="color:#000000">WOA_Best_score</span>);
<span style="color:#000000">std_FPA</span> = <span style="color:#3300aa">std</span>(<span style="color:#000000">FPA_Best_score</span>);
<span style="color:#000000">std_CWBOA</span> = <span style="color:#3300aa">std</span>(<span style="color:#000000">CWBOA_Best_score</span>);
<span style="color:#000000">best_BOA</span> = <span style="color:#3300aa">max</span>(<span style="color:#000000">BOA_Best_score</span>);
<span style="color:#000000">best_WOA</span> = <span style="color:#3300aa">max</span>(<span style="color:#000000">WOA_Best_score</span>);
<span style="color:#000000">best_FPA</span> = <span style="color:#3300aa">max</span>(<span style="color:#000000">FPA_Best_score</span>);
<span style="color:#000000">best_CWBOA</span> = <span style="color:#3300aa">max</span>(<span style="color:#000000">CWBOA_Best_score</span>);
<span style="color:#000000">worst_BOA</span> = <span style="color:#3300aa">min</span>(<span style="color:#000000">BOA_Best_score</span>);
<span style="color:#000000">worst_WOA</span> = <span style="color:#3300aa">min</span>(<span style="color:#000000">WOA_Best_score</span>);
<span style="color:#000000">worst_FPA</span> = <span style="color:#3300aa">min</span>(<span style="color:#000000">FPA_Best_score</span>);
<span style="color:#000000">worst_CWBOA</span> = <span style="color:#3300aa">min</span>(<span style="color:#000000">CWBOA_Best_score</span>);
<span style="color:#000000">mean_BOA</span> = <span style="color:#3300aa">mean</span>(<span style="color:#000000">BOA_Best_score</span>);
<span style="color:#000000">mean_WOA</span> = <span style="color:#3300aa">mean</span>(<span style="color:#000000">WOA_Best_score</span>);
<span style="color:#000000">mean_FPA</span> = <span style="color:#3300aa">mean</span>(<span style="color:#000000">FPA_Best_score</span>);
<span style="color:#000000">mean_CWBOA</span> = <span style="color:#3300aa">mean</span>(<span style="color:#000000">CWBOA_Best_score</span>);
<span style="color:#aa5500">%% 画图</span>
<span style="color:#aa5500">% 1、画出所选基准函数的三维立体图形</span>
<span style="color:#aa5500">% figure;</span>
<span style="color:#aa5500">% func_plot(Function_name);</span>
<span style="color:#aa5500">% title(Function_name)</span>
<span style="color:#aa5500">% xlabel('x_1');</span>
<span style="color:#aa5500">% ylabel('x_2');</span>
<span style="color:#aa5500">% zlabel([Function_name,'( x_1 , x_2 )'])</span>
<span style="color:#aa5500">% 2、画出目标函数值变化曲线图</span>
<span style="color:#000000">figure</span>;
<span style="color:#000000">t</span> = <span style="color:#116644">1</span>:<span style="color:#000000">Max_iteration</span>;
<span style="color:#000000">semilogy</span>(<span style="color:#000000">t</span>, <span style="color:#000000">Curve_BOA</span>, <span style="color:#aa1111">'k^-'</span>, <span style="color:#000000">t</span>, <span style="color:#000000">Curve_WOA</span>, <span style="color:#aa1111">'bo-'</span>, <span style="color:#000000">t</span>, <span style="color:#000000">Curve_FPA</span>, <span style="color:#aa1111">'mv-'</span>, <span style="color:#000000">t</span>, <span style="color:#000000">Curve_CWBOA</span>, <span style="color:#aa1111">'rd-'</span>, <span style="color:red">...</span>
<span style="color:#aa1111">'linewidth'</span>, <span style="color:#116644">1.5</span>, <span style="color:#aa1111">'MarkerSize'</span>, <span style="color:#116644">8</span>, <span style="color:#aa1111">'MarkerIndices'</span>, <span style="color:#116644">1</span>:<span style="color:#116644">50</span>:<span style="color:#000000">Max_iteration</span>);
<span style="color:#3300aa">title</span>(<span style="color:#000000">Function_name</span>)
<span style="color:#3300aa">xlabel</span>(<span style="color:#aa1111">'Iteration'</span>);
<span style="color:#3300aa">ylabel</span>(<span style="color:#aa1111">'Fitness'</span>);
<span style="color:#000000">axis</span> <span style="color:#000000">fill</span>
<span style="color:#3300aa">grid</span> <span style="color:#000000">on</span>
<span style="color:#000000">box</span> <span style="color:#000000">on</span>
<span style="color:#3300aa">legend</span>(<span style="color:#aa1111">'BOA'</span>, <span style="color:#aa1111">'WOA'</span>, <span style="color:#aa1111">'FPA'</span>, <span style="color:#aa1111">'CWBOA'</span>);
<span style="color:#aa5500">%% 显示结果</span>
<span style="color:#770088">disp</span>([<span style="color:#aa1111">'函数:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">Function_name</span>)]);
<span style="color:#770088">disp</span>([<span style="color:#aa1111">'BOA:最大值: '</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">best_BOA</span>), <span style="color:#aa1111">',最小值:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">worst_BOA</span>), <span style="color:#aa1111">',平均值:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">mean_BOA</span>), <span style="color:#aa1111">',标准差:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">std_BOA</span>)]);
<span style="color:#770088">disp</span>([<span style="color:#aa1111">'WOA:最大值: '</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">best_WOA</span>), <span style="color:#aa1111">',最小值:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">worst_WOA</span>), <span style="color:#aa1111">',平均值:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">mean_WOA</span>), <span style="color:#aa1111">',标准差:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">std_WOA</span>)]);
<span style="color:#770088">disp</span>([<span style="color:#aa1111">'FPA:最大值: '</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">best_FPA</span>), <span style="color:#aa1111">',最小值:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">worst_FPA</span>), <span style="color:#aa1111">',平均值:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">mean_FPA</span>), <span style="color:#aa1111">',标准差:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">std_FPA</span>)]);
<span style="color:#770088">disp</span>([<span style="color:#aa1111">'CWBOA:最大值: '</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">best_CWBOA</span>), <span style="color:#aa1111">',最小值:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">worst_CWBOA</span>), <span style="color:#aa1111">',平均值:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">mean_CWBOA</span>), <span style="color:#aa1111">',标准差:'</span>, <span style="color:#3300aa">num2str</span>(<span style="color:#000000">std_CWBOA</span>)]);
</span></span>
3 仿真结果
4 参考文献
[1]高文欣等. "柯西变异和自适应权重优化的蝴蝶算法." 计算机工程与应用 56.15(2020):8.