基于粒子群算法优化广义神经网络(岩爆预测实例)

粒子群算法优化广义神经网络(PSO_GRNN)

这里分享最近研究重现的一篇文章,核心算法是广义神经网络GRNN,依据岩石的抗拉强度、弹性能量指数等四个特征对岩爆危险等级的一种预测。算法思路比较简单,论文《基于粒子群算法和广义回归神经网络的岩爆预测 》欢迎大家引用原文~

这里附上主程序,完整代码可从这里下载://

download.csdn.net/download/weixin_40405758/12123029

 

论文摘要:岩爆是岩石深部开挖中一种常见的工程地质灾害。为评价岩爆发生的可能性,提出一种基于粒子群算法和广义回归神经网络模型(PSO-GRNN 模型)的岩爆预测方法。该方法利用已有岩爆数据,通过神经网络技术建立回
归模型,采用粒子群算法对模型参数进行优化,减少人为因素对神经网络设计的影响。据此方法,在能量理论的
基础上,选取洞壁围岩最大切向应力、岩石单轴抗压强度、抗拉强度和弹性能量指数作为主要影响因素,利用国
内外 26 组已有工程数据建立岩爆预测的 PSO-GRNN 模型。通过对苍岭隧道和冬瓜山铜矿岩爆预测的工程实例分
析验证该方法的可行性和适用性。所提方法可为类似工程的岩爆预测提供参考。 
 

%%将PSO_GRNN看做是一个神经网络模型的话,即一个函数,那么接下来加入交叉验证就方便多了
%加入4折交叉验证:
%主要问题是查看其数据的应用
%程序说明
%主程序:Cross_PSO_GRNN.m
%PSO_GRNN.m为粒子群优化模型
%此程序仅为示例
%版权归作者所有,未经作者同意不得转载
clc;clear;
data_all=textread('data1.txt');%读取数据
data_cl=textread('cldata.txt');%读取苍岭隧道数据作为模型输出值
%获得网络训练数据
%使用交叉验证处理训练集样本,找到最适合的某组数据
%数据集分类
 P_train=data_all(:,2:5)
 T_train=data_all(:,6)
 [M,N]=size(data_all);
 indices=crossvalind('Kfold',M,4);
 P_test_cl=data_cl(:,1:4)'; %实验工程数据 
 Result_out=[];
 Best_fitness_cv=[];
 G_Best_position_cv=[];
 Gbest_position_cv=[];
  
 for i=1:4  %2折交叉验证训练过程,首先将训练数据集分为两类
       test=(indices==i);train=~test;
       P_train_first_cv=P_train(train,:)';    
       T_train_first_cv=T_train(train,:)'; 
       P_test_second_cv=P_train(test,:)';
       T_test_second_cv=T_train(test,:)';
       %调用PSO_GRNN获取相应参数
       [Gbest_position,Best_fitness,G_Best_position]=PSO_GRNN(P_train_first_cv,T_train_first_cv,P_test_second_cv,T_test_second_cv,P_test_cl); 
       Gbest_position_cv=[Gbest_position_cv;Gbest_position];
       Best_fitness_cv=[Best_fitness_cv;Best_fitness];
       G_Best_position_cv=[G_Best_position_cv;G_Best_position];
       %训练网络
  net=newgrnn(P_train_first_cv,T_train_first_cv,Gbest_position);
  %测试网络
  T_out_cl=sim(net,P_test_cl);
  disp(T_out_cl);disp(Gbest_position);
  Result_out=[Result_out;T_out_cl];
   end
 n=1:size(P_test_cl,2);
 Num=size(Best_fitness_cv,2);
%画图进行比较
figure(1)
plot(n,Result_out(1,:),'-ro',n,Result_out(2,:),'-bo',n,Result_out(3,:),'-*b',n,Result_out(4,:),'-*r');
legend('第一组','第二组','第三组','第四组');
% plot(1:4,Result_out(4:8),'-bo');
title('预测值');
xlabel('次序');
ylabel('预测值');
figure(2);
plot(1:Num,Best_fitness_cv(1,:),'-ro',1:Num,Best_fitness_cv(2,:),'-bo',1:Num,Best_fitness_cv(3,:),'-*b',1:Num,Best_fitness_cv(4,:),'-*r');
legend('第一组','第二组','第三组','第四组');
title('最优适应度值');
xlabel('迭代次数');
ylabel('适应度值');
figure(3);
plot(1:Num,G_Best_position_cv(1,:),'-ro',1:Num,G_Best_position_cv(2,:),'-bo',1:Num,G_Best_position_cv(3,:),'-*b',1:Num,G_Best_position_cv(4,:),'-*r');
legend('第一组','第二组','第三组','第四组');
title('粒子最优位置');
xlabel('迭代次数');
ylabel('光滑因子');
%画柱状图
figure(4)
b= bar(Result_out');
grid  on;
hold on  
set(gca,'XGrid','off');
ch=get(b,'children');
set(gca,'XTickLabel',{'1','2','3','4'});
%set(gca,'YTickLabel',{'0','0.25','0.5','0.75','1'});
legend('第一组','第二组','第三组','第四组');
ylabel('岩爆预测值');
xlabel('次序')
%实验结论:出现样本数据对结果影响太大的情况,即同一份数据不同的选择结果会不同甚至完全相反,那么,请思考方法还能信任?

 

This add-in to the PSO Research toolbox (Evers 2009) aims to allow an artificial neural network (ANN or simply NN) to be trained using the Particle Swarm Optimization (PSO) technique (Kennedy, Eberhart et al. 2001). This add-in acts like a bridge or interface between MATLAB’s NN toolbox and the PSO Research Toolbox. In this way, MATLAB’s NN functions can call the NN add-in, which in turn calls the PSO Research toolbox for NN training. This approach to training a NN by PSO treats each PSO particle as one possible solution of weight and bias combinations for the NN (Settles and Rylander ; Rui Mendes 2002; Venayagamoorthy 2003). The PSO particles therefore move about in the search space aiming to minimise the output of the NN performance function. The author acknowledges that there already exists code for PSO training of a NN (Birge 2005), however that code was found to work only with MATLAB version 2005 and older. This NN-addin works with newer versions of MATLAB till versions 2010a. HELPFUL LINKS: 1. This NN add-in only works when used with the PSORT found at, http://www.mathworks.com/matlabcentral/fileexchange/28291-particle-swarm-optimization-research-toolbox. 2. The author acknowledges the modification of code used in an old PSO toolbox for NN training found at http://www.mathworks.com.au/matlabcentral/fileexchange/7506. 3. User support and contact information for the author of this NN add-in can be found at http://www.tricia-rambharose.com/ ACKNOWLEDGEMENTS The author acknowledges the support of advisors and fellow researchers who supported in various ways to better her understanding of PSO and NN which lead to the creation of this add-in for PSO training of NNs. The acknowledged are as follows: * Dr. Alexander Nikov - Senior lecturer and Head of Usaility Lab, UWI, St. Augustine, Trinidad, W.I. http://www2.sta.uwi.edu/~anikov/ * Dr. Sabine Graf - Assistant Professor, Athabasca University, Alberta, Canada. http://scis.athabascau.ca/scis/staff/faculty.jsp?id=sabineg * Dr. Kinshuk - Professor, Athabasca University, Alberta, Canada. http://scis.athabascau.ca/scis/staff/faculty.jsp?id=kinshuk * Members of the iCore group at Athabasca University, Edmonton, Alberta, Canada.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值