一种新的数据聚类启发式优化方法——黑洞算法(基于Matlab代码实现)

  欢迎关注

个人主页:我爱Matlab


点赞➕评论➕收藏 == 养成习惯(一键三连)

希望大家多多支持~一起加油

语录:将来的我一定会感谢现在奋斗的自己!

摘要

黑洞算法是根据自然界的黑洞现象生成的一种启发式优化方法, 现阶段已被用于配电网潮流计算、图像处理、参数寻优等领域, 具有寻优精度高、容易达到全局最优等优点.Hatamlou等将黑洞算法与k-Means, PSO, GSA, BB-BC聚类算法做对比, 证明了黑洞算法应用于数值型数据中具有良好的聚类效果。

✨⚡运行结果⚡✨

一种新的数据聚类启发式优化方法——黑洞算法(基于Matlab代码实现)_第1张图片

 一种新的数据聚类启发式优化方法——黑洞算法(基于Matlab代码实现)_第2张图片

 一种新的数据聚类启发式优化方法——黑洞算法(基于Matlab代码实现)_第3张图片

 

♨️‍Matlab代码‍♨️

clc;
clear all;
close all;

%% Problem Definitoion
rng(5);
numberOfVariable = 10;          % Number of input variables
lowerBound = -10*ones(1,10);          % Lower Bound of input variables
higherBound = 10*ones(1,10);         % Higher Bound of input variables

%% Parameter of BH
numberOfStars = 100; %Number Of Stars
maxIter = 500; %Maximum Number of Iteration

%% Calling
blackHole = BH(numberOfVariable, lowerBound, higherBound, numberOfStars,maxIter);
[blackHole, bestSolution, bestCost, allBestCost] = BH_Func(blackHole);

%% Results
disp(['BestSolution is: ' num2str(bestSolution)]);
disp(['BestCost is: ' num2str(bestCost)]);
h=figure(1);

semilogx(1:maxIter, allBestCost, 'LineWidth', 2);
title('ObjFunc 2 & Seed 2','FontSize',16);
legend('All Best Costs');
xlabel('Iteration');
ylabel('Best Cost');
grid on;
%saveas(h,'f2seed5optional2', 'png');

pause(0.01)

完整代码:一种新的数据聚类启发式优化方法——黑洞算法(基于Matlab代码实现)

参考文献

[1]许文俊,王锡淮,肖健梅,顾俊瑜.基于改进自适应黑洞机制的引力搜索算法[J].计算机应用研究,2022,39(10):3046-3054+3070.DOI:10.19734/j.issn.1001-3695.2022.03.0096.

你可能感兴趣的:(优化算法,matlab,开发语言)