多输入多输出 | Matlab实现CPO-BP冠豪猪优化算法优化BP神经网络多输入多输出预测
目录
- 多输入多输出 | Matlab实现CPO-BP冠豪猪优化算法优化BP神经网络多输入多输出预测
- 预测效果
- 基本介绍
- 程序设计
- 往期精彩
- 参考资料
预测效果
基本介绍
多输入多输出 | Matlab实现CPO-BP冠豪猪优化算法优化BP神经网络多输入多输出预测
1.data为数据集,10个输入特征,3个输出变量。
2.main.m为主程序文件。
3.命令窗口输出MBE、MAE和R2,可在下载区获取数据和程序内容。
程序设计
- 完整程序和数据下载方式私信博主回复多输入多输出 | Matlab实现CPO-BP冠豪猪优化算法优化BP神经网络多输入多输出预测。
% % Crested Porcupine Optimizer: A new nature-inspired metaheuristic % % %
function [Gb_Fit,Gb_Sol,Conv_curve]=CPO(Pop_size,Tmax,lb,ub,dim,fobj)
%%%%-------------------Definitions--------------------------%%
%%
Conv_curve=zeros(1,Tmax);
ub=ub.*ones(1,dim);
lb=lb.*ones(1,dim);
%%-------------------Controlling parameters--------------------------%%
%%
N=Pop_size; %% Is the initial population size.
N_min=round(0.8*Pop_size); %% Is the minimum population size.
T=2; %% The number of cycles
alpha=0.2; %% The convergence rate
Tf=0.8; %% The percentage of the tradeoff between the third and fourth defense mechanisms
%%---------------Initialization----------------------%%
%%
X=initialization(Pop_size,dim,ub,lb); % Initialize the positions of crested porcupines
t=0; %% Function evaluation counter
%%---------------------Evaluation-----------------------%%
for i=1:Pop_size
fitness(i)=fobj(X(i,:));
end
% Update the best-so-far solution
[Gb_Fit,index]=min(fitness);
Gb_Sol=X(index,:);
%% A new array to store the personal best position for each crested porcupine
Xp=X;
%% Optimization Process of CPO
while t<=Tmax
r2=rand;
for i=1:Pop_size
U1=rand(1,dim)>rand;
if rand<rand %% Exploration phase
if rand<rand %% First defense mechanism
%% Calculate y_t
y=(X(i,:)+X(randi(Pop_size),:))/2;
X(i,:)=X(i,:)+(randn).*abs(2*rand*Gb_Sol-y);
else %% Second defense mechanism
y=(X(i,:)+X(randi(Pop_size),:))/2;
X(i,:)=(U1).*X(i,:)+(1-U1).*(y+rand*(X(randi(Pop_size),:)-X(randi(Pop_size),:)));
end
else
Yt=2*rand*(1-t/(Tmax))^(t/(Tmax));
U2=rand(1,dim)<0.5*2-1;
S=rand*U2;
if rand<Tf %% Third defense mechanism
%%
St=exp(fitness(i)/(sum(fitness)+eps)); % plus eps to avoid division by zero
S=S.*Yt.*St;
X(i,:)= (1-U1).*X(i,:)+U1.*(X(randi(Pop_size),:)+St*(X(randi(Pop_size),:)-X(randi(Pop_size),:))-S);
else %% Fourth defense mechanism
Mt=exp(fitness(i)/(sum(fitness)+eps));
vt=X(i,:);
Vtp=X(randi(Pop_size),:);
Ft=rand(1,dim).*(Mt*(-vt+Vtp));
S=S.*Yt.*Ft;
X(i,:)= (Gb_Sol+(alpha*(1-r2)+r2)*(U2.*Gb_Sol-X(i,:)))-S;
end
end
往期精彩
MATLAB实现RBF径向基神经网络多输入多输出预测
MATLAB实现BP神经网络多输入多输出预测
MATLAB实现DNN神经网络多输入多输出预测
参考资料
[1] https://blog.csdn.net/kjm13182345320/article/details/116377961
[2] https://blog.csdn.net/kjm13182345320/article/details/127931217
[3] https://blog.csdn.net/kjm13182345320/article/details/127894261