【BP预测】基于斑点鬣狗算法优化BP神经网络实现数据预
测附matlab代码
1 简介
为了寻求有效控制和改善环境质量的相应措施,选用了英国伦敦Bloomsbury监测站的PM10小时平均浓度
监测资料,采用基于斑点鬣狗算法的BP神经网络模型,预测PM1024 h内的小时平均浓度.结果表明:采用BP
神经网络法对大气污染物浓度进行预测,预测相对误差在2%-48%之间,且绝大部分在2%-17%之间,预测精
度较高,泛化能力较好,为大气污染物浓度预测提供了一种全新的思路和方法.
2 部分代码
3 仿真结果
function
[Best_hyena_score,Best_hyena_pos,Convergence_curve]=sho(N,Max_iterations,lowerbo
und,upperbound,dimension,fitness)hyena_pos=init(N,dimension,upperbound,lowerboun
d);Convergence_curve=zeros(1,Max_iterations);Iteration=1;while
Iteration<Max_iterations for i=1:size(hyena_pos,1)
H_ub=hyena_pos(i,:)>upperbound; H_lb=hyena_pos(i,:)<lowerbound;
hyena_pos(i,:)=(hyena_pos(i,:).*(~
(H_ub+H_lb)))+upperbound.*H_ub+lowerbound.*H_lb;
hyena_fitness(1,i)=fitness(hyena_pos(i,:)); end if
Iteration==1 [fitness_sorted FS]=sort(hyena_fitness);
sorted_population=hyena_pos(FS,:); best_hyenas=sorted_population;
best_hyena_fitness=fitness_sorted; else double_population=
[pre_population;best_hyenas]; double_fitness=[pre_fitness
best_hyena_fitness]; [double_fitness_sorted FS]=sort(double_fitness);
double_sorted_population=double_population(FS,:);
fitness_sorted=double_fitness_sorted(1:N);
sorted_population=double_sorted_population(1:N,:);
best_hyenas=sorted_population; best_hyena_fitness=fitness_sorted; end
NOH=noh(best_hyena_fitness); Best_hyena_score=fitness_sorted(1);
Best_hyena_pos=sorted_population(1,:); pre_population=hyena_pos;
pre_fitness=hyena_fitness; a=5-Iteration*((5)/Max_iterations); HYE=0;
CV=0; for i=1:size(hyena_pos,1) for j=1:size(hyena_pos,2)
for k=1:NOH HYE=0; r1=rand(); r2=rand();
Var1=2*a*r1-a; Var2=2*r2;
distance_to_hyena=abs(Var2*sorted_population(k)-hyena_pos(i,j));
HYE=sorted_population(k)-Var1*distance_to_hyena; CV=CV+HYE;
distance_to_hyena=0; end hyena_pos(i,j)=
(CV/(NOH+1)); CV=0; end end
Convergence_curve(Iteration)=Best_hyena_score; Iteration=Iteration+1;
end