【状态估计】 KEWLS和 KEWLS-KF (KKF) 研究(Matlab代码实现)

 💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

KEWLS和KEWLS-KF (KKF) 研究

一、概述

二、KEWLS(Kernel-Embedded Weighted Least Squares)

三、KEWLS-KF(KKF)

四、应用领域

五、结论

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

KEWLS(Kernel-Embedded Weighted Least Squares)和KEWLS-KF(KKF)是两种状态估计技术,常用于估计动态系统中的状态变量。这些技术通常应用于控制理论、机器学习和信号处理等领域。我可以为你提供一些关于它们的基本信息:

1. **KEWLS(Kernel-Embedded Weighted Least Squares)**:
   - KEWLS是一种基于加权最小二乘法的状态估计技术。
   - 它使用核函数来映射输入数据到高维空间,从而能够更好地捕捉非线性关系。
   - 通过对数据施加不同的权重,可以对不同数据点的重要性进行调整,以提高估计的准确性。
   - KEWLS通常适用于非线性系统或者系统具有复杂的动态特性的情况。

2. **KEWLS-KF(KKF)**:
   - KEWLS-KF是KEWLS与卡尔曼滤波(Kalman Filtering)技术相结合的一种方法。
   - 卡尔曼滤波是一种经典的状态估计方法,用于估计线性系统中的状态变量。
   - 将KEWLS与卡尔曼滤波相结合,可以在非线性系统中更好地进行状态估计,克服卡尔曼滤波在非线性系统中的局限性。
   - KEWLS-KF在处理非线性系统时具有较好的性能,能够更准确地估计系统的状态变量。

KEWLS和KEWLS-KF (KKF) 研究

一、概述

KEWLS(Kernel-Embedded Weighted Least Squares)和KEWLS-KF(KKF)是两种重要的状态估计技术,广泛应用于控制理论、机器学习和信号处理等领域。这些技术主要用于估计动态系统中的状态变量,尤其是在处理非线性系统或具有复杂动态特性的系统时表现出色。

二、KEWLS(Kernel-Embedded Weighted Least Squares)
  1. 基本原理
    • KEWLS是一种基于加权最小二乘法的状态估计技术。
    • 它通过核函数将输入数据映射到高维空间,以更好地捕捉非线性关系。
    • 通过对数据施加不同的权重,可以调整不同数据点的重要性,从而提高估计的准确性。
  2. 应用场景
    • KEWLS通常适用于非线性系统或系统具有复杂动态特性的情况。
    • 在这些情况下,传统的线性估计方法可能无法准确估计系统的状态变量,而KEWLS则能提供更准确的估计结果。
三、KEWLS-KF(KKF)
  1. 基本原理
    • KEWLS-KF是KEWLS与卡尔曼滤波(Kalman Filtering)技术相结合的方法。
    • 卡尔曼滤波是一种经典的状态估计方法,主要用于估计线性系统中的状态变量。
    • 将KEWLS与卡尔曼滤波相结合,可以在非线性系统中更好地进行状态估计,克服卡尔曼滤波在非线性系统中的局限性。
  2. 性能优势
    • KEWLS-KF在处理非线性系统时具有较好的性能,能够更准确地估计系统的状态变量。
    • 这种方法结合了KEWLS在非线性关系捕捉方面的优势和卡尔曼滤波在状态估计中的稳定性,从而实现了更高效的状态估计。
四、应用领域

KEWLS和KEWLS-KF技术通常用于各种领域,包括但不限于:

  • 机器学习:在机器学习领域,这些技术可以用于提高模型的预测精度和鲁棒性。
  • 自动控制:在自动控制系统中,准确的状态估计是实现精确控制的关键。KEWLS和KEWLS-KF技术可以帮助控制系统更准确地估计系统的状态变量,从而实现更精确的控制。
  • 信号处理:在信号处理领域,这些技术可以用于从噪声信号中提取有用信息,提高信号的信噪比和分辨率。
五、结论

KEWLS和KEWLS-KF作为两种先进的状态估计技术,在控制理论、机器学习和信号处理等领域具有广泛的应用前景。它们通过不同的方式提高了状态估计的准确性和鲁棒性,为解决复杂系统的状态估计问题提供了新的思路和方法。随着技术的不断发展和完善,KEWLS和KEWLS-KF将在更多领域发挥重要作用。

📚2 运行结果

部分代码:

clear all
clc

%%run variable loop 
%%/
%here we will change a variable and run it through the 'loop'
No_loops = 28;  %number of variable loops
No_it = 100;     %number of iterations
No_times = 1;   %number of times a process is repeated for tic/toc func

%loop storage
LS_RMSE     = zeros(1,No_loops); %classic least squares
UKF_RMSE    = zeros(1,No_loops); %classic Unscented Kalman filter
KEWLS_RMSE   = zeros(1,No_loops); %proposed = Sequential extrapolation / batch estimation 
KKF_RMSE = zeros(1,No_loops); %proposed but with an additional KF 
SUKF_RMSE   = zeros(1,No_loops); %sequential Unscented Kalman filter

LS_mean     = cell(1,No_loops); %classic least squares
UKF_mean    = cell(1,No_loops); %classic Unscented Kalman filter
KEWLS_mean   = cell(1,No_loops); %proposed = Sequential extrapolation / batch estimation 
KKF_mean = cell(1,No_loops); %proposed but with an additional KF 
SUKF_mean   = cell(1,No_loops); %sequential Unscented Kalman filter

LS_t    = zeros(1,No_loops);
UKF_t   = zeros(1,No_loops);
KEWLS_t  = zeros(1,No_loops);
KKF_t= zeros(1,No_loops);
SUKF_t  = zeros(1,No_loops);

%%// VARIABLES

bl = 10; %baseline
Lim = 1; %basline multiplier for travel limits 
xV = 1;
yV = 1; 

move_noise = 0; %Movement noise StD
s_pos = [0 ; 0]; %target start Position
delay = 1; % LEAVE AS 1 to delay the measurements by d_t or not
R = RRLH2D_positions(bl);   %generate pos of rx's
No_RRLHs = length(R(1,:));

%%/// MODIFIABLE VARIABLES

d_t = 0.01; %default measurment intervals (s)
r_z = 0.01;%measurmenet noise StD
q = d_t;   %std of process Q / prediction of D 
qt = 9;   %std of process Q / prediction of D 
q_a = 4; %irrelivant now %std of process Q / prediction of state X
ang = 0.2; %angle of the crcular path

%% VARIABLE LOOP //

for loop = 1:No_loops
    fprintf('\nloop = %d \n',loop)
    
    %changing variable = 
%    Var = linspace(0.001,0.1,No_loops); %starts at the second value
     %Var = logspace(-2,3,No_loops); %starts at the second value
     Var = [0.001,.002,.003,.004,.005,.006,.007,.008,.009,...
        .01,.02,.03,.04,.05,.06,.07,.08,.09,...
        .1,.2,.3,.4,.5,.6,.7,.8,.9,1];
    r_z = Var(loop); 
    ChangingVar = 'r_z';
    fprintf('value = %d \n',Var(loop))
%     
% q_KKF = q_a;
% q_SUKF= q_a;
% q_UKF = q_a;

    if d_t == 0.1
        q_KKF = 60;
        q_SUKF= 3;
        q_UKF = 100;
%         qt = 0.4;
    end
    if d_t == 0.01
        q_KKF = 20;
        q_SUKF= 20;
        q_UKF = 7;
%         qt = 3;
    end      
    if d_t == 0.001
        q_KKF = 2;
        q_SUKF= 30;
        q_UKF = 20;
%         qt = 10;
    end
    
%% storage in cells for each variable iteration
posX = cell(1,250);
posY = cell(1,250);
M_posX = cell(1,250);
M_posY = cell(1,250);
Measurments = cell(1,250); % noisy measurments 
True_distances = cell(1,250); % actual distances
True_dis_atEstPos = cell(1,250); % actual distances at the estimation point

%% Least squares and two step least squares
LS_estX = cell(1,250);
LS_estY = cell(1,250);
LS_Errors =  cell(1,250);
LS_time = zeros(1,100);

%% Classic Unscented Kalman filter
UKF_estX = cell(1,250);
UKF_estY = cell(1,250);
UKF_Errors =  cell(1,250);
UKF_time = zeros(1,100);

%% KEWLS
KEWLS_estX = cell(1,250);
KEWLS_estY = cell(1,250);
KEWLS_Errors = cell(1,250);
KEWLS_time = zeros(1,100); 

%% KEWLS-KF (KKF)
KKF_estX = cell(1,250);
KKF_estY = cell(1,250);
KKF_Errors = cell(1,250);
KKF_time = zeros(1,100);

%% SUKF solution 
SUKF_estX = cell(1,250);
SUKF_estY = cell(1,250);
SUKF_Errors = cell(1,250);
SUKF_time = zeros(1,100);

%%/// RUN ITERATIONS //

%% ITERATIONS

%% generate a circular path
C_path = 0;
if ang ~= 0
    %distance per simulation time interval = time interval to mainatin 1m/s
    Radius = 1/ang;
    No_steps = (2*pi*Radius)/0.0001; %circumfrence distance/simulation time 
    C_path = circle_move(Radius,bl,No_steps);
end
%run through iterations
for it = 1:No_it       
    
    %Run the simulation to collect measurment data
    if ang == 0
    [True_est_pos, measurment_pos, measurments, true_distances, true_dis_atEstPos] =...
        DelayedLaterationFunc_Str(R, delay, bl, Lim, xV, yV, d_t, s_pos, r_z, move_noise);
    else 
        [True_est_pos, measurment_pos, measurments, true_distances, true_dis_atEstPos] =...
        DelayedLaterationFunc_circ(R, delay, bl, Lim, xV, yV, d_t, s_pos, C_path, r_z, move_noise);
    end

    % store data
    %legendCell{it} = append(num2str(d_t),'s'); %convert d_t to string for legend
    posX{it} = True_est_pos(1,:);
    posY{it} = True_est_pos(2,:);
    M_posX{it} = measurment_pos(1,:);
    M_posY{it} = measurment_pos(2,:);
    Measurments{it} = measurments;
    True_distances{it} = true_distances;
    True_dis_atEstPos{it} = true_dis_atEstPos;

    %% perform standard LS on the measurments - (currently TS is turned off for fair timing)
    tic
    for i = 1:No_times
        [LS_Est] = LS_looped(R, measurments);
    end
    LS_time(it) = toc;
        LS_estX{it} = LS_Est(1,:);
        LS_estY{it} = LS_Est(2,:);
        LS_Errors{it} = Error_calc(LS_Est, True_est_pos, 0);

    %% Classic Unscented Kalman filter (ignoring the latencies)
    tic
    for i = 1:No_times
        [UKF_est] = Kalman_solution_UKF(R, measurments, True_est_pos, r_z, q_UKF, d_t, LS_Est(:,1));
    end
    UKF_time(it) = toc;
        UKF_estX{it} = UKF_est(1,:); 
        UKF_estY{it} = UKF_est(2,:);
        UKF_Errors{it} = Error_calc(UKF_est, True_est_pos, 0);
        
    %% KEWLS
    tic
    for i = 1:No_times
        [KEWLS_est] = KEWLS(R, measurments, r_z, q);
    end
    KEWLS_time(it) = toc;
        KEWLS_estX{it} = KEWLS_est(1,:); 
        KEWLS_estY{it} = KEWLS_est(2,:);
        KEWLS_Errors{it} = Error_calc(KEWLS_est, True_est_pos, 2);
        
    %% Weighted Proposed solution SS3WKF - Sequential Extrapolation/ Batch estimation (Scenario 3) + KF
    tic
    for i = 1:No_times
        [KKF_est] = KKF(R, measurments, True_est_pos, r_z, q, q_KKF, d_t, LS_Est(:,1));
    end
    KKF_time(it) = toc;
        KKF_estX{it} = KKF_est(1,:); 
        KKF_estY{it} = KKF_est(2,:);
        KKF_Errors{it} = Error_calc(KKF_est, True_est_pos, 2);

    %% Sequential Unscented Kalman filter solution
    tic
    for i = 1:No_times
        [SUKF_est] = Kalman_solution_SUKF(R, measurments, True_est_pos, r_z, q_SUKF, d_t, LS_Est(:,1));
    end
    SUKF_time(it) = toc;
        SUKF_estX{it} = SUKF_est(1,:); 
        SUKF_estY{it} = SUKF_est(2,:);
        SUKF_Errors{it} = Error_calc(SUKF_est(1:2,:), True_est_pos, 0);

    disp(it)
end

%%/ ERROR CALCULATIONS

%Pre-determine arrays for mean values of the data
LS_me   = zeros(1,length(LS_Errors{1}));
UKF_me  = zeros(1,length(UKF_Errors{1}));
KEWLS_me  = zeros(1,length(KEWLS_Errors{1}));
KKF_me= zeros(1,length(KKF_Errors{1}));
SUKF_me = zeros(1,length(SUKF_Errors{1}));

%% Average error calculation (per iteration)
for i = 1:it
    LS_me   = LS_me     + LS_Errors{i}; %add each iteration together
    UKF_me  = UKF_me    + UKF_Errors{i}; %add each iteration together
    KEWLS_me= KEWLS_me  + KEWLS_Errors{i}; %add each iteration together
    KKF_me  = KKF_me    + KKF_Errors{i}; %add each iteration together
    SUKF_me = SUKF_me   + SUKF_Errors{i}; %add each iteration together
end

%calculate average accross each point
LS_me    = LS_me/it;     
UKF_me   = UKF_me/it; 
KEWLS_me  = KEWLS_me/it;  
KKF_me= KKF_me/it;
SUKF_me  = SUKF_me/it;

LS_mean{loop}   = LS_me;     
UKF_mean{loop}  = UKF_me; 
KEWLS_mean{loop}  = KEWLS_me;    
KKF_mean{loop}= KKF_me;
SUKF_mean{loop} = SUKF_me;

%calculate RMSE for each scenario 
LS_RMSE(loop)    = sqrt(sum(LS_me.^2)    /length(LS_me));
UKF_RMSE(loop)   = sqrt(sum(UKF_me.^2)   /length(UKF_me));
KEWLS_RMSE(loop) = sqrt(sum(KEWLS_me.^2) /length(KEWLS_me));
KKF_RMSE(loop)   = sqrt(sum(KKF_me.^2)   /length(KKF_me));
SUKF_RMSE(loop)  = sqrt(sum(SUKF_me.^2)  /length(SUKF_me));

%calculate average time per estimation
LS_t(loop)    = (sum(LS_time)    /No_it)/No_times/length(True_est_pos(1,:));
UKF_t(loop)   = (sum(UKF_time)   /No_it)/No_times/length(True_est_pos(1,:));
KEWLS_t(loop) = (sum(KEWLS_time) /No_it)/No_times/(length(True_est_pos(1,:))-2);
KKF_t(loop)   = (sum(KKF_time)   /No_it)/No_times/(length(True_est_pos(1,:))-2);
SUKF_t(loop)  = (sum(SUKF_time)  /No_it)/No_times/length(True_est_pos(1,:));
end

% Diff_SUKF_SS3W = sum(SS3W_RMSE-SUKF_RMSE)/No_loops;
% fprintf('\n RMSE difference between SUKF and KEWLS = %d',Diff_SUKF_SS3W)
% Diff_SUKF_SS3WKF = sum(SS3WKF_RMSE-SUKF_RMSE)/No_loops;
% fprintf('\n RMSE difference between SUKF and KKF = %d',Diff_SUKF_SS3WKF)

perc_Diff_SUKF_SS3W = (sum((KEWLS_RMSE./SUKF_RMSE)*100)/No_loops)-100;
fprintf('\n RMSE difference between SUKF and KEWLS \n= %d',perc_Diff_SUKF_SS3W)
perc_Diff_SUKF_SS3WKF = (sum((KKF_RMSE./SUKF_RMSE)*100)/No_loops)-100;
fprintf('\n RMSE difference between SUKF and KKF \n= %d \n ',perc_Diff_SUKF_SS3WKF)

🎉3 参考文献

文章中一些内容引自网络,会注明出处或引用为参考文献,难免有未尽之处,如有不妥,请随时联系删除。

[1]陆可,肖建.IMM算法实现非线性状态估计的研究与仿真[J].计算机仿真, 2008(05):82-85+109.DOI:CNKI:SUN:JSJZ.0.2008-05-023.

[2]王克英,穆钢,陈学允.计及PMU的状态估计精度分析及配置研究[J].中国电机工程学报, 2001, 21(8):5.DOI:10.3321/j.issn:0258-8013.2001.08.007.

🌈4 Matlab代码实现

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值