?【优化求解】基于黑洞算法求解最优目标matlab源码

2021/10/24 22:43:27

本文主要是介绍?【优化求解】基于黑洞算法求解最优目标matlab源码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1 简介

2 部分代码

clear all
clc
close all

d=5;                % dimension
options.lk=-32*ones(1,d);   % lower bound
options.uk=32*ones(1,d);    % upper bound
options.m=50; % Size of the population
options.MAXITER=500; % Maximum number of iterations
options.n=length(options.uk);    % dimension of the problem.
options.ObjFunction=@Ackley; % the name of the objective function
options.Display_Flag=1; % Flag for displaying results over iterations
options.run_parallel_index=0;
options.run=10;

if options.run_parallel_index
   %     run_parallel
   stream = RandStream('mrg32k3a');
   parfor index=1:options.run
       %     tic
       %     index
       set(stream,'Substream',index);
       RandStream.setGlobalStream(stream)
      [bestX, bestFitness, bestFitnessEvolution,nEval]=BH_v1(options);
       bestX_M(index,:)=bestX;
       Fbest_M(index)=bestFitness;
       fbest_evolution_M(index,:)=bestFitnessEvolution;
   end
else
   rng('default')
   for index=1:options.run
      [bestX, bestFitness, bestFitnessEvolution,nEval]=BH_v1(options);
       bestX_M(index,:)=bestX;
       Fbest_M(index)=bestFitness;
       fbest_evolution_M(index,:)=bestFitnessEvolution;
   end
end


[a,b]=min(Fbest_M);
figure
plot(1:options.MAXITER,fbest_evolution_M(b,:))
xlabel('Iterations')
ylabel('Fitness')
img =gcf;  %获取当前画图的句柄
print(img, '-dpng', '-r600', './img.png')         %即可得到对应格式和期望dpi的图像
fprintf(' MIN=%g MEAN=%g MEDIAN=%g MAX=%g SD=%g \n',...
   min(Fbest_M),mean(Fbest_M),median(Fbest_M),max(Fbest_M),std(Fbest_M))

`

3 仿真结果

4 参考文献

[1]王通, 高宪文, and 蒋子健. "基于黑洞算法的LSSVM的参数优化." 东北大学学报:自然科学版 35.2(2014):5.

 



这篇关于?【优化求解】基于黑洞算法求解最优目标matlab源码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程