您的位置:首页 > 新闻 > 热点要闻 > 设计感超强的公司名字_网站开发技术论文_小蝌蚪幸福宝入口导航_湖北疫情最新消息

设计感超强的公司名字_网站开发技术论文_小蝌蚪幸福宝入口导航_湖北疫情最新消息

2025/5/24 16:19:17 来源:https://blog.csdn.net/weixin_46300916/article/details/147240174  浏览:    关键词:设计感超强的公司名字_网站开发技术论文_小蝌蚪幸福宝入口导航_湖北疫情最新消息
设计感超强的公司名字_网站开发技术论文_小蝌蚪幸福宝入口导航_湖北疫情最新消息

系列文章目录

目录

系列文章目录

前言

一、定义被控对象模型

二、设计 MPC 控制器

三、性能评估设置

四、设置仿真参数和信号

五、计算敏感度

六、调整 MPC 权重

七、验证性能变化

八、验证累积性能指数是否降低

九、使用用户定义的性能函数


前言

        本例展示了如何计算累积性能指标相对于 MPC 二次成本函数权重的数值导数,并利用这些导数来提高性能。


一、定义被控对象模型

        为被控对象创建一个状态空间模型。

plant = ss(tf( ...{1,1,2;1 -1 -1}, ...{[1 0 0],[1 0 0],[1 1];[1 2 8],[1 3],[1 1 3]}), ...'min');

        该模型为连续时间模型,有 3 个输入(假定为可控输入变量)、2 个输出(假定均可观测)和 8 个状态变量。

二、设计 MPC 控制器

        创建一个采样时间为 0.1、预测范围为 20 步、控制范围为 3 步的 MPC 控制器。

mpcobj = mpc(plant,0.1,20,3);

输出:

-->"Weights.ManipulatedVariables" is empty. Assuming default 0.00000.
-->"Weights.ManipulatedVariablesRate" is empty. Assuming default 0.10000.
-->"Weights.OutputVariables" is empty. Assuming default 1.00000.

        对可控输入变量及其变化率设置约束。

for i = 1:3mpcobj.MV(i).Min = -2;mpcobj.MV(i).Max = 2;mpcobj.MV(i).RateMin = -4;mpcobj.MV(i).RateMax = 4;
end

        显示输出变量、可控输入变量和可控输入变量率的默认成本函数权重。

mpcobj.Weights.OutputVariables
ans = 1×21     1
mpcobj.Weights.ManipulatedVariables
ans = 1×30     0     0
mpcobj.Weights.ManipulatedVariablesRate
ans = 1×30.1000    0.1000    0.1000

三、性能评估设置

        将闭环累积性能指标定义为被控对象信号与其参考信号之间的加权平方误差积分 (ISE),计算区间为 0 至 Tstop 秒。

        反映所需闭环行为的权重必须包含在一个结构中,该结构的字段与 MPC 对象的权重属性相同。

perfWeights = mpcobj.weights;

        在本例中,输出跟踪比保持较低的可控变量值更重要,因此,对输出误差定义相对较高的权重,对可控变量速率定义稍高的权重,对可控变量值保持默认权重。

perfWeights.OutputVariables = [100 100]; 
perfWeights.ManipulatedVariablesRate = [1 1 1];

        请注意,perfWeights 仅用于计算累积性能指数。它与 MPC 控制器对象内部指定的权重无关。因此,累积性能指数与 MPC 控制器通过选择可控输入变量值试图最小化的二次成本函数无关。事实上,性能指标是在闭环仿真的基础上得出的,仿真时间一般与预测时间不同,而 MPC 控制器则是在预测时间之前以开环方式计算使其内部成本函数最小化的动作。此外,即使性能指标被选择为 ISE 类型,其权重也应与 MPC 成本函数中定义的权重相匹配。

四、设置仿真参数和信号

        在本例中,您将计算设定点跟踪方案中的累积性能指标灵敏度。

Tstop = 80;              % number of time steps to be simulated
r = ones(Tstop,1)*[1 1]; % set point reference signals
v = [];                  % no disturbance is added
sopts = mpcsimopt;      % create simulation options object
sopts.PlantInitialState = zeros(8,1); % set plant initial state

五、计算敏感度

        使用灵敏度函数计算性能指数值及其对 mpcobj 成本函数权重的灵敏度。

[J1, Sens1] = sensitivity(mpcobj,'ISE',perfWeights,Tstop,r,v,sopts);
-->Converting model to discrete time.Assuming no disturbance added to measured output #1.
-->Assuming output disturbance added to measured output #2 is integrated white noise.
-->"Model.Noise" is empty. Assuming white noise on each measured output.

        显示输出误差信号的权重敏感度.

Sens1.OutputVariables
ans = 1×2
104 ×-2.7346    2.7166

        显示可控输入信号权重的敏感度

Sens1.ManipulatedVariables
ans = 1×33.3376 -125.8266  -35.1067

        显示可控输入率信号 J 的权重敏感度。

Sens1.ManipulatedVariablesRate
ans = 1×3
104 ×-0.0007    1.0250   -0.8370

六、调整 MPC 权重

        由于要降低闭环累积性能指标 J,本例中与输出权重相关的导数显示,应增加 y1 的权重(因为相应导数为负),同时减少 y2 的权重。

        复制 MPC 对象,对新对象进行修改。

mpcobj_new = mpcobj;

        负灵敏度建议将第一个输出权重从 1 增加到 2。

mpcobj_new.Weights.OutputVariables(1) = 2;

        正灵敏度建议将第二输出权重从 1 降至 0.2。

mpcobj_new.Weights.OutputVariables(2) = 0.2;

        请注意,灵敏度分析只能告诉您朝哪个方向改变参数,而不能告诉您改变多少。要选择适当的变化幅度,需要反复试验。

七、验证性能变化

        仿真两个 MPC 控制器。

[y1, t1, u1] = sim(mpcobj, Tstop, r, v, sopts);
[y2, t2, u2] = sim(mpcobj_new, Tstop, r, v, sopts);
-->Converting model to discrete time.Assuming no disturbance added to measured output #1.
-->Assuming output disturbance added to measured output #2 is integrated white noise.
-->"Model.Noise" is empty. Assuming white noise on each measured output.

        绘制两种控制器的仿真结果。

% Plot plant outputs
h1 = figure;subplot(211)
plot(t2,r(:,1),t1,y1(:,1),t2,y2(:,1));grid
legend('reference','original tuning','new tuning')
title('Output #1')subplot(212)
plot(t2,r(:,2),t1,y1(:,2),t2,y2(:,2));grid
legend('reference','original tuning','new tuning')
title('Output #2')

% Plot manipulated variables
h2 = figure;subplot(311)
plot(t1,u1(:,1),t2,u2(:,1));grid
legend('original tuning','new tuning')
title('Manipulated Variable #1')subplot(312)
plot(t1,u1(:,2),t2,u2(:,2));grid
legend('original tuning','new tuning')
title('Manipulated Variable #2')subplot(313)
plot(t1,u1(:,3),t2,u2(:,3));grid
legend('original tuning','new tuning')
title('Manipulated Variable #3')

八、验证累积性能指数是否降低

        使用相同的性能观测值计算新控制器的累积性能指数。

J2 = sensitivity(mpcobj_new,'ISE',perfWeights,Tstop,r,v,sopts);
-->Converting model to discrete time.Assuming no disturbance added to measured output #1.
-->Assuming output disturbance added to measured output #2 is integrated white noise.
-->"Model.Noise" is empty. Assuming white noise on each measured output.

        上一个累积性能指数。

J1
J1 = 
1.2865e+05

        新的累积性能指数。

J2
J2 = 
1.1623e+05

不出所料,累积性能指数的新值低于旧值。

九、使用用户定义的性能函数

        本例说明如何编写灵敏度方法使用的用户自定义性能函数。在本例中,自定义函数 custom_performance_function.m 基于 PerformanceWeights 实现了标准 ISE 性能指数。

显示函数。

type custom_performance_function.m
function J = custom_performance_function(mpcobj, perfWeights, Tsteps, r)
% This is an example of how to write a user defined performance function
% used by the "sensitivity" method.  In this example, the code illustrates
% using performance weights to compute the cumulative performance index.% Copyright 1990-2014 The MathWorks, Inc.% Carry out simulation 
[y,t,u] = sim(mpcobj, Tsteps, r);
du = [u(1,:);diff(u)];% Get Weights in mpcobj
ny = size(mpcobj,'mo') + size(mpcobj,'uo');
nmv = size(mpcobj,'mv');
Wy = perfWeights.OutputVariables(:);Wy=Wy(1:ny);
Wu = perfWeights.ManipulatedVariables(:);Wu=Wu(1:nmv);
Wdu = perfWeights.ManipulatedVariablesRate(:);Wdu=Wdu(1:nmv);% Set mv target to 0
utarget=zeros(nmv,1);% Compute J in ISE form
J=0;
aux=(y-r)*Wy;
J=J+aux'*aux;
aux=(u-ones(Tsteps,1)*utarget')*Wu;
J=J+aux'*aux;
aux=du*Wdu;
J=J+aux'*aux;

        使用自定义函数计算性能指数。

J3 = sensitivity(mpcobj,'custom_performance_function', ...perfWeights,Tstop,r)
J3 = 
1.2865e+05

        不出所料,对于 mpcobj,用户定义的累积性能指数 J3 的值与 J1 相同。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com