永州冷水滩网站建设,专门做装修的网站,wordpress增加404,弋阳县建设工程网站时序预测 | MATLAB实现基于PSO-BiLSTM、BiLSTM时间序列预测对比 目录 时序预测 | MATLAB实现基于PSO-BiLSTM、BiLSTM时间序列预测对比效果一览基本描述程序设计参考资料 效果一览 基本描述 MATLAB实现基于PSO-BiLSTM、BiLSTM时间序列预测对比。 1.Matlab实现PSO-BiLSTM和BiLSTM…时序预测 | MATLAB实现基于PSO-BiLSTM、BiLSTM时间序列预测对比 目录 时序预测 | MATLAB实现基于PSO-BiLSTM、BiLSTM时间序列预测对比效果一览基本描述程序设计参考资料 效果一览 基本描述 MATLAB实现基于PSO-BiLSTM、BiLSTM时间序列预测对比。 1.Matlab实现PSO-BiLSTM和BiLSTM神经网络时间序列预测 2.输入数据为单变量时间序列数据即一维数据 3.运行环境Matlab2020及以上,依次运行Main1BiLSTMTS、Main2PSOBiLSTMTS、Main3CDM即可其余为函数文件无需运行,所有程序放在一个文件夹,data为数据集 BiLSTM双向长短时记忆模型与粒子群算法优化后的BiLSTMPSOBiLSTM对比实验可用于风电、光伏等负荷预测时序预测数据为单输入单输出PSO优化超参数为隐含层1节点数、隐含层2节点数、最大迭代次数和学习率。 4.命令窗口输出MAE、MAPE、RMSE和R2 程序设计
完整程序和数据下载私信博主回复MATLAB实现基于PSO-BiLSTM、BiLSTM时间序列预测对比。
for i1:PopNum%随机初始化速度,随机初始化位置for j1:dimif jdim% % 隐含层节点与训练次数是整数 学习率是浮点型pop(i,j)(xmax(j)-xmin(j))*randxmin(j);elsepop(i,j)round((xmax(j)-xmin(j))*randxmin(j)); %endend
end% calculate the fitness_value of Pop
pbest pop;
gbest zeros(1,dim);
data1 zeros(Maxstep,PopNum,dim);
data2 zeros(Maxstep,PopNum);
for i 1:PopNumfit(i) fitness(pop(i,:),p_train,t_train,p_test,t_test);f_pbest(i) fit(i);
end
g min(find(f_pbest min(f_pbest(1:PopNum))));
gbest pbest(g,:);
f_gbest f_pbest(g);%-------- in the loop -------------
for step 1:Maxstepmbest sum(pbest(:))/PopNum;% linear weigh factorb 1-step/Maxstep*0.5;data1(step,:,:) pop;data2(step,:) fit;for i 1:PopNuma rand(1,dim);u rand(1,dim);p a.*pbest(i,:)(1-a).*gbest;pop(i,:) p b*abs(mbest-pop(i,:)).*...log(1./u).*(1-2*(u 0.5));% boundary detectionfor j1:dimif j dimif pop(i,j)xmax(j) | pop(i,j)xmin(j)pop(i,j)(xmax(j)-xmin(j))*randxmin(j); %endelsepop(i,j)round(pop(i,j));if pop(i,j)xmax(j) | pop(i,j)xmin(j)pop(i,j)round((xmax(j)-xmin(j))*randxmin(j)); %endendendfit(i) fitness(pop(i,:),p_train,t_train,p_test,t_test);if fit(i) f_pbest(i)pbest(i,:) pop(i,:);f_pbest(i) fit(i);endif f_pbest(i) f_gbestgbest pbest(i,:);f_gbest f_pbest(i);endendtrace(step)f_gbest;step,f_gbest,gbestresult(step,:)gbest;
end
or i1:N%随机初始化速度,随机初始化位置for j1:Dif jD% % 隐含层节点与训练次数是整数 学习率是浮点型x(i,j)(xmax(j)-xmin(j))*randxmin(j);elsex(i,j)round((xmax(j)-xmin(j))*randxmin(j)); %endendv(i,:)rand(1,D);
end%------先计算各个粒子的适应度并初始化Pi和Pg----------------------
for i1:Np(i)fitness(x(i,:),p_train,t_train,p_test,t_test);y(i,:)x(i,:);end
[fg,index]min(p);
pg x(index,:); %Pg为全局最优%------进入主要循环按照公式依次迭代------------for t1:Mfor i1:Nv(i,:)w*v(i,:)c1*rand*(y(i,:)-x(i,:))c2*rand*(pg-x(i,:));x(i,:)x(i,:)v(i,:);for j1:Dif j ~Dx(i,j)round(x(i,j));endif x(i,j)xmax(j) | x(i,j)xmin(j)if jDx(i,j)(xmax(j)-xmin(j))*randxmin(j); %elsex(i,j)round((xmax(j)-xmin(j))*randxmin(j)); %endendendtempfitness(x(i,:),p_train,t_train,p_test,t_test);if tempp(i)p(i)temp;y(i,:)x(i,:);endif p(i)fgpgy(i,:);fgp(i);endendtrace(t)fg;result(t,:)pg;参考资料 [1] https://blog.csdn.net/kjm13182345320/article/details/127596777?spm1001.2014.3001.5501 [2] https://download.csdn.net/download/kjm13182345320/86830096?spm1001.2014.3001.5501