日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

在Hammerstein非线性模型中,基于PSO的参数辨识系统

發布時間:2025/4/5 windows 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在Hammerstein非线性模型中,基于PSO的参数辨识系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Hammerstein非線性模型的基于PSO的參數辨識系統的本質就是將參數的辨識問題轉換為參數空間優化問題,對整個參數域進行搜索并最終獲得最優的參數估計。我們需要的參數辨識模型具體描述如下所示:

? ? ? ? 將Hammerstein非線性模型進行分離,得到8個不同的模型,逐個對其參數進行識辨。下面從較為簡單的NL8開始說明直到NL1,NL這九個結果。最后對整個Hammerstein非線性模型進行識辨仿真。

NL

原非線性模型的坐標圖。

PSO最佳適應曲線。

V(t)中七個參數的辨識過程。

Y(t)的三個參數的辨識過程如下所示:

部分核心代碼如下:

?

clc;
close all;
clear;
%對a1,b1,b2進行參數辨識
Len = ?1000;
%開始粒子群優化
%開始粒子群優化
%粒子群參數設置
ys ? ? ? ? = zeros(1,Len);
y0 ? ? ? ? = zeros(1,Len);
var ? ? ? ?= 0.001; ? ? ? ? % 噪聲方差
err ? ? ? ?= 0.01;
iter_max ? = 200; ? ? ? ? ?% 最大迭代次數
N ? ? ? ? ?= 50; ? ? ? ? ? % 種群規模
C1 ? ? ? ? = 2; ? ? ? ? ? ?% 加速度常數
C2 ? ? ? ? = 2;
Xmin ? ? ? = -1; ? ? ? ? ? % 解取值范圍[Xmin,Xmax]
Xmax ? ? ? = 1;
p ? ? ? ? ?= 3; ? ? ? ? ? % 粒子維數
w ? ? ? ? ?= linspace(0.9,0.4,iter_max); ? % 慣性權重
X ? ? ? ? ?= Xmin+(Xmax-Xmin)*rand(p,N); ? % 粒子位置
Xpbest ? ? = X; ? ? ? ? ? ? ? ? ? ? ? ? ? ?% 個體最佳位置
Xgbest ? ? = Xmin+(Xmax-Xmin)*rand(p,1); ? % 種群最佳位置
fpbest ? ? = 0*rand(1,N); ? ? ? ? ? ? ? ? ?% 個體最佳適應度值
fgbest ? ? = 0; ? ? ? ? ? ? ? ? ? ? ? ? ? ?% 種群最佳適應度值
fgbest_fig = zeros(1,iter_max);?
Xgbest_fig = zeros(p,iter_max);
Vmax ? ? ? = 1;
V ? ? ? ? ?= Vmax*(2*rand(p,N)-1);
e ? ? ? ? ?= idinput(Len,'rgs',[0 1],[-var var]); ?% 高斯白噪聲,均值為0,方差為var


%定義輸入輸出
load ? data1.mat
clear ?u alpha v f1 f2 f3 h1 h2 h1pr h2pr
load ? result.mat
clear ?Xgbest_fig p_best pa_best pb_best Z1_best Z2_best e1_best e2_best Xgbest_fig
for t=1:Len
? ? y0(t) = y(t) + e(t);
end

iter=0;

while iter<iter_max
? ? iter=iter+1;%進行迭代
? ? iter
? ? for i=1:N
? ? ? ? for t = 3:Len

? ? ? ? ? ? a1 ? ? ? ? = ? X(1,i);
? ? ? ? ? ? a2 ? ? ? ? = ? X(2,i);
? ? ? ? ? ? b1 ? ? ? ? = ? X(3,i); ? ? ? ? ??
? ? ? ? ? ? %y(t)
? ? ? ? ? ? ys(t) ? ? ?= ? -a1*ys(t-1) - a2*ys(t-2) + vs(t-1) + b1*vs(t-2); ? ? ? ? ? ?

? ? ? ? end

? ? ? ? J=1/(1+(ys-y0)*(ys-y0)');

? ? ? ? if J>fpbest(i)
? ? ? ? ? ? fpbest(i) ? = J;
? ? ? ? ? ? Xpbest(:,i) = X(:,i);
? ? ? ? end?
? ? end

? ? [fitnessmax,index]=max(fpbest);

? ? if fitnessmax>fgbest
? ? ? ? fgbest=fitnessmax;
? ? ? ? Xgbest=X(:,index);
? ? end

? ? for i=1:N
? ? ? ? r1 ? = rand;?
? ? ? ? r2 ? = rand;
? ? ? ? fai1 = C1*r1;
? ? ? ? fai2 = C2*r2; ?

? ? ? ? % 速度更新
? ? ? ? V(:,i) = w(iter) * V(:,i) +fai1 *( Xpbest(:,i) - X(:,i) ) + fai2 * ( Xgbest(:,1) - X(:,i) );
? ? ? ? % 若速度超過限定值,則讓其等于邊界值
? ? ? ? index ?= find(abs(V(:,i))>Vmax);

? ? ? ? if(any(index))
? ? ? ? ? ? V(index,i)=V(index,i)./abs(V(index,i)).*Vmax;
? ? ? ? end

? ? ? ? %位置更新
? ? ? ? X(:,i)=X(:,i)+V(:,i);
? ? end

? ? fgbest_fig(iter) ? = fgbest;%種群最佳適應度值
? ? Xgbest_fig(:,iter) = Xgbest;%種群最佳位置
end


figure;
plot(1:iter_max,fgbest_fig,'r-*');
%參數優化過程曲線


figure
plot(1:iter_max,Xgbest_fig(1,:),'r-.','LineWidth',2);
hold on?
plot(1:iter_max,Xgbest_fig(2,:),'b-.','LineWidth',2);
hold on?
plot(1:iter_max,Xgbest_fig(3,:),'m-.','LineWidth',2);
hold on?

legend('a1 PSO','a2 PSO','b1 PSO');

plot(1:iter_max,a1,'k');
hold on
plot(1:iter_max,a2,'k');
hold on
plot(1:iter_max,b1,'k');
hold off


disp(Xgbest)

a1_best ? = ? Xgbest(1);
a2_best ? = ? Xgbest(2);
b1_best ? = ? Xgbest(3); ??


figure;
subplot(5,2,8);
plot(1:iter_max,Xgbest_fig(1,:),'r-.','LineWidth',2);
hold on?
plot(1:iter_max,a1,'k');
hold off
xlabel('迭代次數');
ylabel('a1')

subplot(5,2,9);
plot(1:iter_max,Xgbest_fig(2,:),'r-.','LineWidth',2);
hold on?
plot(1:iter_max,a2,'k');
hold off
xlabel('迭代次數');
ylabel('a2')

subplot(5,2,10);
plot(1:iter_max,Xgbest_fig(3,:),'r-.','LineWidth',2);
hold on?
plot(1:iter_max,b1,'k');
hold off
xlabel('迭代次數');
ylabel('b1')


load ? result.mat
subplot(5,2,1);
plot(1:iter_max,Xgbest_fig(1,:),'r-.','LineWidth',2);
hold on?
p ? = ?2;
plot(1:iter_max,p,'k');
hold off
xlabel('迭代次數');
ylabel('p');

subplot(5,2,2);
plot(1:iter_max,Xgbest_fig(2,:),'r-.','LineWidth',2);
hold on?
pa ?= ?0.5;
plot(1:iter_max,pa,'k');
hold off
xlabel('迭代次數');
ylabel('pa')

subplot(5,2,3);
plot(1:iter_max,Xgbest_fig(3,:),'r-.','LineWidth',2);
hold on?
pb ?= ?1;
plot(1:iter_max,pb,'k');
hold off
xlabel('迭代次數');
ylabel('pb')

subplot(5,2,4);
plot(1:iter_max,Xgbest_fig(4,:),'r-.','LineWidth',2);
hold on?
Z1 ?= ?1.2;
plot(1:iter_max,Z1,'k');
hold off
xlabel('迭代次數');
ylabel('Z1')

subplot(5,2,5);
plot(1:iter_max,Xgbest_fig(5,:),'r-.','LineWidth',2);
hold on?
Z2 ?= -1;
plot(1:iter_max,Z2,'k');
hold off
xlabel('迭代次數');
ylabel('Z2')

subplot(5,2,6);
plot(1:iter_max,Xgbest_fig(6,:),'r-.','LineWidth',2);
hold on?
e1 ?= ?1.5;
plot(1:iter_max,e1,'k');
hold off
xlabel('迭代次數');
ylabel('e1')

subplot(5,2,7);
plot(1:iter_max,Xgbest_fig(7,:),'r-.','LineWidth',2);
hold on?
e2 ?= -1.2;
plot(1:iter_max,e2,'k');
hold off
xlabel('迭代次數');
ylabel('e2')

A27-01

總結

以上是生活随笔為你收集整理的在Hammerstein非线性模型中,基于PSO的参数辨识系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。