广义预测控制(GPC,含公式推导和仿真截图)

这篇具有很好参考价值的文章主要介绍了广义预测控制(GPC,含公式推导和仿真截图)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

一,广义预测控制

1,概念

2,推导公式

1,E,F丢番图方程求解​

2,G,H丢番图方程求解​

3,跟踪轨迹

4,求控制律u(t)

 二,matlab程序仿真结果

1,matlab程序

2,参数设置

3,仿真结果1

4,仿真结果2


一,广义预测控制

1,概念

广义预测控制,简单来说就是利用历史值去预测系统下一时刻的输出值。

2,推导公式

重点在求解丢番图方程E,F,G

预测模型:

广义预测控制(GPC,含公式推导和仿真截图)

1,E,F丢番图方程求解广义预测控制(GPC,含公式推导和仿真截图)

预测步长:j

广义预测控制(GPC,含公式推导和仿真截图)的矩阵表示如下:

广义预测控制(GPC,含公式推导和仿真截图)

 j步预测时的丢番图方程:

广义预测控制(GPC,含公式推导和仿真截图)

 j+1步预测时的丢番图方程:

广义预测控制(GPC,含公式推导和仿真截图)

式(1-4)减(1-1):

广义预测控制(GPC,含公式推导和仿真截图)

上式左边从0到j-1次的所以幂次项均为零,广义预测控制(GPC,含公式推导和仿真截图)广义预测控制(GPC,含公式推导和仿真截图)前j项系数相等,可知: 

广义预测控制(GPC,含公式推导和仿真截图)

把(1-6)代入式(1-5)中,并展开E,F

广义预测控制(GPC,含公式推导和仿真截图)

令上式左右两边同次幂相等,得递推公式: 

 广义预测控制(GPC,含公式推导和仿真截图)

递推初值由j=1时的丢番图方程解出。

 2,G,H丢番图方程求解广义预测控制(GPC,含公式推导和仿真截图):

广义预测控制(GPC,含公式推导和仿真截图)的矩阵形式:

 广义预测控制(GPC,含公式推导和仿真截图)

其中:

控制时域长度:广义预测控制(GPC,含公式推导和仿真截图)

最大预测长度:   广义预测控制(GPC,含公式推导和仿真截图)(广义预测控制(GPC,含公式推导和仿真截图))

广义预测控制(GPC,含公式推导和仿真截图)

 同次幂系数相等,得递推公式:

广义预测控制(GPC,含公式推导和仿真截图)

 在matlab程序中matrixg_whole矩阵用来缓存计算g和h的数值,随后从matrixg_whole中取出的g_part2即为丢番图方程G矩阵。

3,跟踪轨迹

广义预测控制(GPC,含公式推导和仿真截图)

4,求控制律u(t)

 二,matlab程序仿真结果

 1,matlab程序:

clear all
clc
close all


%---------------------------------------------------------%
%---GPC算法(水泥 分解炉温度控制)---%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                     part 1  参数                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%仿真时间或者步长(实控的时候 不需要了)
simulationiter1 =100;
simulationiter2 =200;
simulationiter3 = 300;

% 实际系统
a_real=[ 1 0.5];%A(q-1) of process 0.2
b_real=[  0.5  ];%B(q-1) of process 
k_real=1;%time delay of process
%实际系统包含噪声
for i=1:simulationiter3
    u(1,i)=0;%init U
    noise(1,i)=0*randn()/10;%init random noise
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=2:simulationiter3
    y_real(1,i)=noise(1,i);%init real y
end%init sum of noise
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%模型参数
% a_model=[1 0.5 0.2 ];%A(q-1) of model
% b_model=[1 0.5  ];%B(q-1) of model
% k_model=1;%time delay of model
a_model = a_real;
b_model = b_real;
k_model = k_real;
na=length(a_model)-1;
nb=length(b_model)-1;

%GPC配置参数%(实控的时候 需要)
GPC_p=6;%predict horizon
GPC_m=6;%control horizon
GPC_lambda=10;%control weight
GPC_alfa=0;%soften parameter 柔化因子
GPC_beta=0;%step scale 阶梯因子 可不用


DMC_sp1 = 5; %设定值
DMC_sp2 = 10; %设定值
DMC_sp3 = 15; %设定值
for i=1:simulationiter1
    y_set(1,i)=DMC_sp1;
end%init setpoint of y
for i=(simulationiter1+1):simulationiter2
    y_set(1,i)=DMC_sp2;
end%init setpoint of y
for i=(simulationiter2+1):simulationiter3
    y_set(1,i)=DMC_sp3;
end%init setpoint of y

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% for i=1:350
%         u(1,i)=1;%init U
%         noise(1,i)=normrnd(0,0.0);%init random noise
%         y_real(1,i)=0;%init real y
% end
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% for i=1:350
%     y_set(1,i)=10;
% end%init setpoint of y
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% noise_sum(1,1)=noise(1,1);
% for i=2:300
%     noise_sum(1,i)=noise_sum(1,i-1)+noise(1,i);
% end%init sum of noise
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                    part 2 init polynomials                            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
matrix_e=zeros(k_model+GPC_p-1,1); % E 丢番图方程   (6,1) 生成零矩阵
matrix_f=zeros(na+1,k_model+GPC_p-1); %F 丢番图方程   (2.6)
matrixg_whole=zeros(k_model+GPC_p-1,nb+k_model+GPC_p-1); % G= E*B 丢番图方程
%(6,6)
%计算F 丢番图方程
matrix_f(1,1)=1-a_model(1,2);
for i=1:1:na-1
    matrix_f(i+1,1)=a_model(1,i+1)-a_model(1,i+2);
end
matrix_f(na+1,1)=a_model(1,na+1);

%计算E 丢番图方程
matrix_e(1,1)=1;
for j=2:1:k_model+GPC_p-1
    matrix_e(j,1)=matrix_f(1,j-1);
    matrix_f(1,j)=matrix_f(2,j-1)-matrix_e(j,1)*(a_model(1,2)-1);
    for i=1:1:na-1
        matrix_f(i+1,j)=matrix_f(i+2,j-1)-matrix_e(j,1)*(a_model(1,i+2)-a_model(1,i+1));
    end
    matrix_f(na+1,j)=matrix_e(j,1)*a_model(1,na+1);
end%init e,f

%计算G= E*B 丢番图方程
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:nb+1
    matrixg_whole(1,i)=b_model(1,i);
end
for j=2:k_model+GPC_p-1
    for i=1:nb+j-1+1
        if i<=j-1
            matrixg_whole(j,i)=matrixg_whole(j-1,i);
        elseif i<=nb+j-1
            matrixg_whole(j,i)=matrixg_whole(j-1,i)+matrix_e(j,1)*b_model(1,i-j+1);
        elseif i==nb+j
            matrixg_whole(j,i)=matrix_e(j,1)*b_model(1,nb+1);
        end
    end
end%inint g


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:GPC_p
    g_single(1,i)=matrixg_whole(k_model+GPC_p-1,i);
end
for j=1:GPC_p
    for i=1:j
        g_part(j,i)=g_single(1,j-i+1);
    end
end   
for j=1:GPC_p
    for i=1:GPC_m
        g_part2(j,i)=g_part(j,i);
    end
end%init g_part for teh use of control of different forms

% 离线计算D矩阵
temp = inv((g_part2)'*(g_part2)+GPC_lambda*eye(GPC_m))*(g_part2)';%inv求逆矩阵 
matrix_d = temp(1,:);  %取temp第一行


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                       part 3  normoal control                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for t=3:simulationiter3       
    y_real(1,t)=noise(1,t);
   % for i=1:1 y_real(1,t)=b_real(1,i)*u(1,t-k_real-i+1)-a_real(1,i+1)*y_real(1,t-i)
   % end
    for i=1:nb+1
        y_real(1,t)=y_real(1,t)+b_real(1,i)*u(1,t-k_real-i+1);
    end
    for i=1:na
        y_real(1,t)=y_real(1,t)-a_real(1,i+1)*y_real(1,t-i);
    end%sampleing
    y_show = y_real(1,t)
    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    for i=0:GPC_p-1
        y1(i+1,1)=0;
        for l=1:na+1
            y1(i+1,1)=y1(i+1,1)+matrix_f(l,i+k_model)*y_real(1,t-l+1);
        end
        for l=i+2:nb+k_model+i
            y1(i+1,1)=y1(i+1,1)+matrixg_whole(k_model+i,l)*(u(1,t+i+1-l)-u(1,t+i-l));
        end
    end%init y1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  

    w_start=0;
    if k_model==1
        w_start=y_real(1,t);
    else
        for l=1:na+1
            w_start= w_start+matrix_f(l,k_model-1)*y_real(1,t-l+1);
        end
        for l=1:nb+k_model-1
            w_start= w_start+matrixg_whole(k_model-1,l)*(u(1,t-l)-u(1,t-l-1));
        end%init w_start
    end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    w(1,1)=GPC_alfa*w_start+(1-GPC_alfa)*y_set(1,t);
    for i=1:GPC_p-1
        w(i+1,1)=GPC_alfa*w(i,1)+(1-GPC_alfa)*y_set(1,t);
    end%init w
    
    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    u_delta = matrix_d *(w-y1)
    u(1,t)=u(1,t-1)+u_delta;%get u if you choose normal gpc        
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                        part 4 plot the result                          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,1,1),plot(y_set,'r');hold on;plot(y_real,'b');legend('设定值','输出值');hold on;axis([0,simulationiter3-10,-inf,inf])
subplot(2,1,2),plot(u,'g');legend('控制律');hold on;axis([0,simulationiter3-10,-inf,inf])

2,参数设置:

广义预测控制(GPC,含公式推导和仿真截图)

3,仿真结果1:

广义预测控制(GPC,含公式推导和仿真截图)

4,仿真结果2:

最大预测长度:2

控制时域长度:1

 广义预测控制(GPC,含公式推导和仿真截图)

由仿真结果可知:预测长度j越长,预测输出值越准确,响应越快,但阶数越高,对计算要求越高。文章来源地址https://www.toymoban.com/news/detail-425986.html

到了这里,关于广义预测控制(GPC,含公式推导和仿真截图)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • MPC(模型预测控制)-Simulink仿真

    一、为什么使用MPC控制器? ① MPC可以处理多输入耦合控制多输出的问题: ② MPC可以处理对于控制量有约束的问题 比如,驾驶汽车的时候,汽车速度和转角都有上限 ③ MPC具有预测效果 即MPC考虑的不是根据当前参考值进行控制,而是根据预测时间内的参考去预测当前的控制量,

    2024年01月25日
    浏览(41)
  • MATLAB 模型预测控制(MPC)控制入门 —— 设计并仿真 MPC 控制器

    MATLAB 模型预测控制(MPC) 模型预测控制工具箱™ 提供了用于开发模型预测控制 (MPC) 的函数、应用程序、Simulink® 模块和参考示例。对于线性问题,该工具箱支持设计隐式、显式、自适应和增益调度 MPC。对于非线性问题,您可以实现单级和多级非线性 MPC。该工具箱提供可部

    2024年02月02日
    浏览(50)
  • 【毕业设计】71-智能汽车路径跟踪控制_超声波测距系统的设计(原理图+仿真+源代码工程+相关截图+视频+答辩论文)

    资料包含:毕业设计全套资料(精品) 原理图工程文件 原理图截图 PCB工程文件 仿真模型工程文件 源代码工程 仿真截图 仿真实现录屏 答辩论文低重复率文档,27528字 英文文献及翻译 任务书 详情请私信! 主要研究内容: 以单片机作为系统控制单元,通过红外光电传感器实

    2024年02月21日
    浏览(38)
  • 基于预测控制模型的自适应巡航控制仿真与机器人实现(Matlab代码实现)

         目录 💥1 概述 📚2 运行结果 🎉3 参考文献 👨‍💻4 Matlab代码 自适应巡航控制技术为目前由于汽车保有量不断增长而带来的行车安全、驾驶舒适性及交通拥堵等问题提供了一条有效的解决途径,因此本文通过理论分析、仿真验证及实车实验对自适应巡航控制中的若干

    2024年02月16日
    浏览(47)
  • NW小世界网络公式推导

    假设网络中度数为 k k k 的节点有 N k N_k N k ​ 个,总共有 N N N 个节点,则度数为 k k k 的节点出现的概率可以表示为: P ( k ) = N k N P(k) = frac{N_k}{N} P ( k ) = N N k ​ ​ 在NW小世界网络中,每个节点有 k k k 条边,其中 k k k 是一个偶数, k / 2 k/2 k /2 条边与相邻节点相连,另外 k

    2024年02月05日
    浏览(85)
  • 华里士公式的推导及其推广

    华里士公式 I n = ∫ 0 π 2 sin ⁡ n x d x = ∫ 0 π 2 cos ⁡ n x d x = { n − 1 n n − 3 n − 2 ⋯ 2 3 n   i s   o d d , n − 1 n n − 3 n − 2 ⋯ 1 2 π 2 n   i s   e v e n Large begin{aligned} I_n = int_{0}^{frac{pi}{2}} sin^n{x} mathrm{d}x = int_{0}^{frac{pi}{2}} cos^n{x} mathrm{d}x = begin{cases} frac{n-1}{n} frac{n-3}

    2023年04月15日
    浏览(54)
  • 线性回归基本原理和公式推导

    回复我们公众号“1号程序员”的“E001”可以获取《BAT机器学习面试1000题》下载链接。[关注并回复:【E001】] 线性回归是一种监督式机器学习算法,它计算因变量与一个或多个独立特征之间的线性关系。当独立特征的数量为1时,被称为单变量线性回归;在存在多于一个特征

    2024年02月11日
    浏览(45)
  • 支持向量机(公式推导+举例应用)

    引言 在机器学习领域,支持向量机(Support Vector Machine,简称SVM)是一种强大而广泛应用的监督学习算法。其独特的优势在于在高维空间中进行准确分类,并在处理复杂数据集时表现出色。支持向量机的核心思想是在数据点间找到一个最优的超平面,以最大化不同类别之间的

    2024年01月16日
    浏览(41)
  • 西瓜书公式(10.24)的推导

    在西瓜书 10.4 节 “核化线性降维” 中,引入了一个映射函数 ϕ phi ϕ ,其作用是将样本点 x i x_i x i ​ 映射到高维特征空间中,即 z i = ϕ ( x i ) z_i=phi(x_i) z i ​ = ϕ ( x i ​ ) 由前文中的推导可以得到 式(10.21) 和 式(10.22) ( ∑ i = 1 m ϕ ( x i ) ϕ ( x i ) T ) w j = λ j w j (10.21) left(s

    2024年02月09日
    浏览(38)
  • PnP算法详解(超详细公式推导)

    博主缺粉丝希望大家能给个关注!!! PnP(Perspective-n-Point)是求解3D到2D点的对应方法。它描述了当知道n个3D空间点及其位置,如何估计相机的位姿。如果两张图像中的一张特征点3D位置已知,那么至少需要3个点对(以及至少一个额外验证点验证结果)就可以计算相机的运动。 P

    2024年02月03日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包