全新一区!速看!PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)


目录
  • 全新一区!速看!PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)
  • 效果一览
  • 基本介绍
  • 程序设计
  • 参考资料


效果一览

全新一区!速看!PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)_PSA-Transformer

全新一区!速看!PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)_回归_02


全新一区!速看!PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)_lstm_03


全新一区!速看!PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)_回归_04


全新一区!速看!PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)_lstm_05


全新一区!速看!PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)_回归_06

基本介绍

1.【JCR一区级】Matlab实现PSA-Transformer-LSTM多变量回归预测,PID搜索算法(PSA)优化Transformer-LSTM组合模型(程序可以作为JCR一区级论文代码支撑,目前尚未发表);

2.优化参数为:学习率,隐含层节点,正则化参数,运行环境为Matlab2023b及以上;

3.data为数据集,输入多个特征,输出单个变量,多变量回归预测,main.m为主程序,运行即可,所有文件放在一个文件夹;

4.命令窗口输出R2、MSE、RMSE、MAE、MAPE、MBE等多指标评价;

一种新的元启发式优化算法–PID搜索算法,PID-based search algorithm (PSA)。该算法基于增量PID算法,通过不断调整系统偏差,使整个种群收敛到最优状态。该成果于2023年12月发表在中科院1区SCI期刊Expert Systems with Applications。

全新一区!速看!PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)_PSA-Transformer_07

全新一区!速看!PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)_transformer_08

程序设计
  • 完整程序和数据获取方式私信博主回复PID搜索算法!PSA-Transformer-LSTM多变量回归预测(Matlab)
%%  清空环境变量
warning off             % 关闭报警信息
close all               % 关闭开启的图窗
clear                   % 清空变量
clc                     % 清空命令行



%%  划分训练集和测试集
P_train = res(1: num_train_s, 1: f_)';
T_train = res(1: num_train_s, f_ + 1: end)';
M = size(P_train, 2);

P_test = res(num_train_s + 1: end, 1: f_)';
T_test = res(num_train_s + 1: end, f_ + 1: end)';
N = size(P_test, 2);

%%  数据归一化
[P_train, ps_input] = mapminmax(P_train, 0, 1);
P_test = mapminmax('apply', P_test, ps_input);

[t_train, ps_output] = mapminmax(T_train, 0, 1);
t_test = mapminmax('apply', T_test, ps_output);

%%  数据平铺
P_train =  double(reshape(P_train, f_, 1, 1, M));
P_test  =  double(reshape(P_test , f_, 1, 1, N));

t_train = t_train';
t_test  = t_test' ;

%%  数据格式转换
for i = 1 : M
    p_train{i, 1} = P_train(:, :, 1, i);
end

for i = 1 : N
    p_test{i, 1}  = P_test( :, :, 1, i);
end

function [Best_rime_rate,Best_rime,Convergence_curve]=RIME(N,Max_iter,lb,ub,dim,fobj)

% initialize position
Best_rime=zeros(1,dim);
Best_rime_rate=inf;%change this to -inf for maximization problems
Rimepop=initialization(N,dim,ub,lb);%Initialize the set of random solutions
Lb=lb.*ones(1,dim);% lower boundary 
Ub=ub.*ones(1,dim);% upper boundary
it=1;%Number of iterations
Convergence_curve=zeros(1,Max_iter);
Rime_rates=zeros(1,N);%Initialize the fitness value
newRime_rates=zeros(1,N);
W = 5;%Soft-rime parameters, discussed in subsection 4.3.1 of the paper
%Calculate the fitness value of the initial position
for i=1:N
    Rime_rates(1,i)=fobj(Rimepop(i,:));%Calculate the fitness value for each search agent
    %Make greedy selections
    if Rime_rates(1,i)<Best_rime_rate
        Best_rime_rate=Rime_rates(1,i);
        Best_rime=Rimepop(i,:);
    end
end
% Main loop
while it <= Max_iter
    it
    RimeFactor = (rand-0.5)*2*cos((pi*it/(Max_iter/10)))*(1-round(it*W/Max_iter)/W);%Parameters of Eq.(3),(4),(5)
    E =(it/Max_iter)^0.5;%Eq.(6)
    newRimepop = Rimepop;%Recording new populations
    normalized_rime_rates=normr(Rime_rates);%Parameters of Eq.(7)
    for i=1:N
        for j=1:dim
            %Soft-rime search strategy
            r1=rand();
            if r1< E
                newRimepop(i,j)=Best_rime(1,j)+RimeFactor*((Ub(j)-Lb(j))*rand+Lb(j));%Eq.(3)
            end
            %Hard-rime puncture mechanism
            r2=rand();
            if r2<normalized_rime_rates(i)
                newRimepop(i,j)=Best_rime(1,j);%Eq.(7)
            end
        end
    end
    for i=1:N
        %Boundary absorption
        Flag4ub=newRimepop(i,:)>ub;
        Flag4lb=newRimepop(i,:)<lb;
        newRimepop(i,:)=(newRimepop(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb;
        newRime_rates(1,i)=fobj(newRimepop(i,:));
        %Positive greedy selection mechanism
        if newRime_rates(1,i)<Rime_rates(1,i)
            Rime_rates(1,i) = newRime_rates(1,i);
            Rimepop(i,:) = newRimepop(i,:);
            if newRime_rates(1,i)< Best_rime_rate
               Best_rime_rate=Rime_rates(1,i);
               Best_rime=Rimepop(i,:);
            end
        end
    end
    Convergence_curve(it)=Best_rime_rate;
    it=it+1;
end
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.