在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

  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
非线性系统辨识是指通过观察非线性系统的输入输出数据,推断出该系统模型结构和参数的过程。非线性系统辨识在实际工程应用具有广泛的领域,例如自动控制系统、神经网络、机器视觉、机器人等。 Matlab是一个强大的数学软件工具,提供了各种辨识算法和工具箱,方便用户进行非线性系统辨识。其最常用的方法包括非线性最小二乘法、基于神经网络模型的辨识法、基于遗传算法的优化辨识法等。 在Matlab非线性系统辨识的流程一般包括以下几个步骤: 1. 数据采集和预处理:收集非线性系统的输入输出数据,对数据进行预处理,如去噪、滤波等。 2. 模型结构选择:根据非线性系统的性质和实验数据,选择适合的模型结构,如ARX模型Hammerstein模型、Wiener模型等。 3. 参数估计:根据所选择的模型,采用对应的参数估计方法,如基于最小二乘法的参数估计、基于神经网络的参数估计等,得到非线性系统模型参数。 4. 模型验证:利用所得到的模型对新的输入数据进行验证,检验模型的拟合效果和预测能力。 5. 模型应用:将所得到的模型应用于实际系统,提供相应的控制策略和优化方案。 总之,Matlab提供了丰富的工具和方法,可用于实现非线性系统辨识。通过这些工具和方法的应用,可以更好地理解和控制非线性系统的行为,提高实际系统的性能和效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fpga和matlab

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值