【优化求解】基于磷虾群算法求解最优目标matlab源码
2021/10/24 22:14:47
本文主要是介绍【优化求解】基于磷虾群算法求解最优目标matlab源码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1 简介
磷虾群算法(Krill Herd Algorithm,KHA)是 Gandomi 等于2012年提出的一种新型优化算法 。具体原理如下:
2 部分代码
% Krill Herd Algorithm V 1.1 % Main paper: % Gandomi A.H., Alavi A.H., Krill Herd: A New Bio-Inspired Optimization Algorithm. % Communications in Nonlinear Science and Numerical Simulation, function KH clc; close all; clear all format long %% Initial Parameter Setting NR = 10; % Number if Runs NK = 25; % Number if Krills MI = 200; % Maximum Iteration C_flag = 1; % Crossover flag [Yes=1] % Bounds (Normalize search space in case of highly imbalanced search space) UB = 10*ones(1,10); LB = -10*ones(1,10); NP = length(LB); % Number if Parameter(s) Dt = mean(abs(UB-LB))/2; % Scale Factor F = zeros(NP,NK);D = zeros(1,NK);N = zeros(NP,NK); %R = zeros(NP,NK); Vf = 0.02; Dmax = 0.005; Nmax = 0.01; Sr = 0; %% Optimization & Simulation for nr = 1:NR %Initial Krills positions for z1 = 1:NP X(z1,:) = LB(z1) + (UB(z1) - LB(z1)).*rand(1,NK); end for z2 = 1:NK K(z2)=cost(X(:,z2)); end Kib=K; Xib=X; [Kgb(1,nr), A] = min(K); Xgb(:,1,nr) = X(:,A); for j = 1:MI % Virtual Food for ll = 1:NP; Sf(ll) = (sum(X(ll,:)./K)); end Xf(:,j) = Sf./(sum(1./K)); %Food Location Xf(:,j) =findlimits(Xf(:,j)',LB,UB,Xgb(:,j,nr)');% Bounds Checking Kf(j) = cost(Xf(:,j)); if 2<=j if Kf(j-1)<Kf(j) Xf(:,j) = Xf(:,j-1); Kf(j) = Kf(j-1); end end Kw_Kgb = max(K)-Kgb(j,nr); w = (0.1+0.8*(1-j/MI)); for i = 1:NK % Calculation of distances Rf = Xf(:,j)-X(:,i); Rgb = Xgb(:,j,nr)-X(:,i); for ii = 1:NK RR(:,ii) = X(:,ii)-X(:,i); end R = sqrt(sum(RR.*RR)); % % % % % % % % % % % % % Movement Induced % % % % % % % % % % %% Post-Processing [Best, Ron_No] = min(Kgb(end,:)) Xgb(:,end,Ron_No) Mean = mean(Kgb(end,:)) Worst = max(Kgb(end,:)) Standard_Deviation = std(Kgb(end,:)) % Convergence plot of the best run semilogy(1:MI+1,Kgb(:,Ron_No),1:MI+1,mean(Kgb')) xlabel('{\itNo. of Iterations}') ylabel('{\itf}({\bfx_{best}})') legend('Best run values','Average run values') img =gcf; %获取当前画图的句柄 print(img, '-dpng', '-r600', './img.png') %即可得到对应格式和期望dpi的图像
3 仿真结果
4 参考文献
[1]肖雄、高渺、陈功贵. "基于混合混沌磷虾算法的短期水火电调度研究." 计算机工程与科学 42.9(2020):12.
这篇关于【优化求解】基于磷虾群算法求解最优目标matlab源码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南