【BP预测】基于人工蜂群算法优化BP神经网络实现数据预测附matlab代码
【BP预测】基于人工蜂群算法优化BP神经网络实现数据预测附matlab代码
TT_Matlab
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,完整matlab代码或者程序定制加qq1575304183。
1 简介
针对BP网络水质评价模型的不足,引入人工蜂群(ABC)算法,将求解BP神经网络各层权值、阀值的过程转化为蜜蜂寻找最佳蜜源的过程,提出了一种新的结合人工蜂群算法的BP网络水质评价方法(ABC-BP)。并以2000—2006年渭河监测断面的10组实测数据作为测试样本对其水质进行了评价,实验结果表明该方法得到的水质评价结果准确,并具有很强的稳定性和鲁棒性。
2 部分代码
function [bestsol,yy] = ABC(prob,lb,ub,Np,T,limit)
%% Starting of ABC
f = NaN(Np,
1
); % Vector to store the objective function
value
of the population members
fit = NaN(Np,
1
); % Vector to store the fitness function
value
of the population members
trial = NaN(Np,
1
); % Initialization of the trial vector
D = length(lb); % Determining the number of decision variables
in
the problem
P = repmat(lb,Np,
1
) + repmat((ub-lb),Np,
1
).*rand(Np,D); % Generation of the initial population
for
p =
1
:
Np
f
(
p
)
= prob(P(p,:)); %
Evaluating the objective function
value
fit
(
p
)
= CalFit(f(p)); % Evaluating the fitness function
value
end
[
bestobj, ind
] = min(f); % Determine and memorize the best objective
value
bestsol = P(ind,:); % Determine and memorize the best solution
bestobj1=
1000
;
for
t =
1
:T
%% Employed Bee Phase
for
i =
1
:Np
[
trial,P,fit,f
] = GenNewSol(prob, lb, ub, Np, i, P, fit, trial, f, D);
end
%% Onlooker Bee Phase
%
as
per the code of the inventors available at https:
//abc.erciyes.edu.tr/
% prob=(
0.9
.*Fitness./max(Fitness))+
0.1
;
% MATLAB Code of the ABC algorithm version
2
has been
released
(
14.12
.2009
) (
more optimized coding
)
probability
=
0.9
* (fit/max(fit)) +
0.1
;
m =
0
; n =
1
;
while
(m < Np)
if
(rand < probability(n))
[
trial,P,fit,f
] = GenNewSol(prob, lb, ub, Np, n, P, fit, trial, f, D);
m = m +
1
;
end
n = mod(n,Np) +
1
;
end
[
bestobj,ind
] = min([f;bestobj]);
CombinedSol = [P;bestsol];
bestsol = CombinedSol(ind,:);
if
bestobj<
bestobj1
yy
(
t
)
=bestobj;
else
yy(t)=bestobj1;
end
%% Scout Bee Phase
[
val,ind
] = max(trial);
if
(val > limit)
trial(ind) =
0
; %
Reset the trial
value
to zero
P
(
ind,:
)
= lb + (ub-lb).*rand(
1
,D); %
Generate a random solution
f
(
ind
)
= prob(P(ind,:)); %
Determine the objective function
value
of the newly generated solution
fit
(
ind
)
= CalFit(f(ind)); % Determine the fitness function
value
of the newly generated solution
end
end
[
bestfitness,ind
] = min([f;bestobj]);
CombinedSol = [P;bestsol];
bestsol = CombinedSol(ind,:);
3 仿真结果
4 参考文献
[1]苏彩红, 向娜, 陈广义,等. 基于人工蜂群算法与BP神经网络的水质评价模型[J]. 环境工程学报, 2012.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
-
2023年血糖新标准公布,不是3.9-6.1,快来看看你的血糖正常吗? 2023-02-07
-
2023年各省最新电价一览!8省中午执行谷段电价! 2023-01-03
-
GB 55009-2021《燃气工程项目规范》(含条文说明),2022年1月1日起实施 2021-11-07
-
PPT导出高分辨率图片的四种方法 2022-09-22
-
2023年最新!国家电网27家省级电力公司负责人大盘点 2023-03-14
-
全国消防救援总队主官及简历(2023.2) 2023-02-10
-
盘点 l 中国石油大庆油田现任领导班子 2023-02-28
-
我们的前辈!历届全国工程勘察设计大师完整名单! 2022-11-18
-
关于某送变电公司“4·22”人身死亡事故的快报 2022-04-26
