1.软件版本
matlab2013b
2.本算法理论知识
3.核心代码
clc
clear
close all;
warning off;
addpath 'functions'
%外部输入的标准的值,这里可以在具体的验证的时候加入扰动。
CR = 0.4;
h = 0.6;
selt = 1;%1:加入扰动;0:不加扰动
%以下两个值越大,那么其PSO优化的RBF性能就越好
%进化次数
iteration = 250;
%种群规模
Sizes = 20;
sel = 0;%1进行PSO优化得到最佳值,0直接进行实际测试
%本代码是在普通的PSO下的RBF神经网络解耦程序
%本代码是在普通的PSO下的RBF神经网络解耦程序
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%以下为PSO%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if sel == 1
%输入的CR和h
%分别仅输入CR和h,使其达到解耦的结果
[yy,Zbest] = func_train_online(iteration,Sizes,CR,h);
figure(1)
plot(yy,'LineWidth',2);grid on;
xlabel('进化代数');
ylabel('适应度');
individual=Zbest;
save trainPSO.mat Zbest yy
else
load trainPSO.mat
figure(1)
plot(yy,'LineWidth',2);grid on;
xlabel('进化代数');
ylabel('适应度');
individual=Zbest;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%以下为RBF%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
w11=reshape(individual(1:6),3,2);
w12=reshape(individual(7:12),3,2);
w13=reshape(individual(13:18),3,2);
w21=individual(19:27);
w22=individual(28:36);
w23=individual(37:45);
rate1=0.006;rate2=0.001; %学习率
k=0.3;K=3;
y_1=zeros(3,1);y_2=y_1;y_3=y_2; %输出值
u_1=zeros(3,1);u_2=u_1;u_3=u_2; %控制率
h1i=zeros(3,1);h1i_1=h1i; %第一个控制量
h2i=zeros(3,1);h2i_1=h2i; %第二个控制量
h3i=zeros(3,1);h3i_1=h3i; %第三个空置量
x1i=zeros(3,1);x2i=x1i;x3i=x2i;x1i_1=x1i;x2i_1=x2i;x3i_1=x3i; %隐含层输出
%权值初始化
k0=0.03;
%值限定
ynmax=1;ynmin=-1; %系统输出值限定
xpmax=1;xpmin=-1; %P节点输出限定
qimax=1;qimin=-1; %I节点输出限定
qdmax=1;qdmin=-1; %D节点输出限定
uhmax=1;uhmin=-1; %输出结果限定
for k=1:1:6000
k
%系统输出
y1(k) = (0.4*y_1(1)+u_1(1)/(1+u_1(1)^2)+0.2*u_1(1)^3+0.5*u_1(2))+0.3*y_1(2);
y2(k) = (0.4*y_1(2)+u_1(2)/(1+u_1(2)^2)+0.2*u_1(2)^3+0.5*u_1(1))+0.3*y_1(1);
y3(k) = 0;
%控制目标
if selt == 1%加扰测试
r1(k) = CR + 0.005*sin(2*pi*k/200);
r2(k) = h + 0.015*sin(2*pi*k/200);
r3(k) = 0;
r1s(k) = CR;
r2s(k) = h;
r3s(k) = 0;
else %跟踪测试
r1(k) = sign(0.001*sin(2*pi*k/2000));
r2(k) = sign(0.003*sin(2*pi*k/2000));
r3(k) = 0;
r1s(k) = CR;
r2s(k) = h;
r3s(k) = 0;
end
%系统输出限制
yn=[y1(k),y2(k),y3(k)];
yn(find(yn>ynmax))=ynmax;
yn(find(ynxpmax))=xpmax;
xp(find(xpqimax))=qimax;
qi(find(qiqdmax))=qdmax;
qd(find(qduhmax))=uhmax;
uh(find(uh
4.操作步骤与仿真结论
普通PSO下的RBF解耦仿真结果:
这个PSO粒子群的优化适应度曲线,其反应了PSO的收敛情况以及最终的性能。
这个是系统的跟踪效果。
加入扰动之后的误差曲线。
HPSO下的RBF解耦仿真结果:
HPSO的收敛曲线。
HPSO的跟踪效果。
HPSO的加入扰动后的误差曲线。
5.参考文献
[1]付龙海, 李蒙. 基于PID神经网络解耦控制的变风量空调系统[J]. 西南交通大学学报, 2005, 40(1):13-17.
A05-05
6.完整源码获得方式
方式1:微信c840893或者QQ联系博主
方式2:订阅
文章出处登录后可见!
已经登录?立即刷新