Main Content

使用比例因素促进MPC权重调整

此示例显示了如何在MPC控制器中指定比例因子,以使权重调整更容易。

定义植物模型

离散的时间,线性,状态空间植物模型具有10个州,5个输入和3个输出。

[Plant,TS] = mpcscscalefactor_model;[ny,nu] = size(plant.d);

工厂的输入包括操纵变量(MV),测量的干扰(MD)和未衡量的干扰(UD)。工厂的产出包括测量的输出(MO)和未测量的输出(UO)。

mvIndex = [1,3,5];mdindex = 4;udindex = 2;moindex = [1 3];uoindex = 2;植物= setmpcsignals(植物,'MV',,,,MVindex,'MD',,,,MDindex,'UD',,,,UDindex,'MO',,,,MOindex,'UO',,,,UOindex);

植物模型的名义值和操作范围如下:

  • 输入1:操纵变量,名义值为100,范围为[50 150]

  • Input 2: unmeasured disturbance, nominal value is 10, range is [5 15]

  • 输入3:操纵变量,名义值为0.01,范围为[0.005 0.015]

  • Input 4: measured disturbance, nominal value is 0.1, range is [0.05 0.15]

  • Input 5: manipulated variable, nominal value is 1, range is [0.5 1.5]

  • Output 1: measured output, nominal value is 0.01, range is [0.005 0.015]

  • 输出2:未测量的输出,名义值为1,范围为[0.5 1.5]

  • Output 3: measured output, nominal value is 100, range is [50 150]

Define and Analyze Open-Loop Plant Signals

Uselsimcommand to run an open loop linear simulation to verify that plant outputs are within the range and their average are close to the nominal values when input signals vary randomly around their nominal values.

%设置输入和输出范围Urange = [100;10;0.01;0.1;1]; Yrange = [0.01;1;100];%设置输入和输出名义值对于此示例,名义值等于范围Unominal = [100;10;0.01;0.1;1]; Ynominal = [0.01;1;100];% define time intervalst =(0:1000)'*ts;nt =长度(t);%定义输入和输出信号uol =(rand(nt,nu)-​​0.5)。*(一个(nt,1)*urange');% design input signalYol = lsim(plant,Uol,t);% compute plant outputfprintf('平均输出值和名义值之间的差异分别为.2f %%,%.2F %%,%.2F %%。\ n',,,,...abs(mean(Yol(:,1)))/Ynominal(1)*100,abs(mean(Yol(:,2)))/Ynominal(2)*100,abs(mean(Yol(:,3)))/Ynominal(3)*100);
The difference between average output values and the nominal values are 2.25%, 3.53%, 2.47% respectively.

输入和输出信号的显示均值和标准偏差。

%可ut平均(UOL)
ans =1×50.6682 -0.1202 -0.0000 0.0009 0.0025
性病(UOL)
ans =1×528.3302 2.9136 0.0029 0.0281 0.2805
% output平均(YOL)
ans =1×3-0.0002 0.0353 2.4706
std(Yol)
ans =1×30.0038 0.5615 39.6285

Here, the mean values give a good idea of the actual nominal values and the standard deviation capture some idea of the range.

Evaluate MPC with Default MPC Weights

When plant input and output signals have different orders of magnitude, default MPC weight settings often give poor performance.

创建具有默认权重的MPC控制器:

  • 重量.mv = 0

  • Weight.MVRate = 0.1

  • 重量.ov = 1

% create mpc objectmpcobjunscaled = mpc(植物);
- >“预测Horizo​​n”属性为空。假设默认值10.  - >“ ControlHorizo​​n”属性为空。假设默认为2。->“ werges.manipulationvariables”属性是空的。假设默认为0.00000。- >“ weights.manipulationVariablesrate”属性为空。假设默认为0.10000。- >“ weight.outputvariables”属性为空。假设默认为1.00000。
植物状态的名义值%Xnominal = zeros(10,1);% nominal values for unmeasured disturbanceUnominal(UDindex) = 0;未衡量干扰的名义值必须为0%设置名义值mpcobjUnscaled.Model.Nominal = struct('X',XnoMinal,'dx',XnoMinal,'Y',,,,Ynominal,'U',单位);

为了计算植物产量,sim将从输入和当前状态的名义状态中减去标称工厂输入,然后应用线性工厂方程,最后将标称输出值添加到计算的输出中。

To calculate the manipulated variables, it will remove the nominal output from the plant output signal, calculate the MPC control sequence, and add the nominal value of the manipulated variables to the calculated sequence.

First, test a sequence of step setpoint changes in three reference signals.

nsteplen = 15;% expected step response durationns1 = nsteplen*ny;%计算模拟时间以适应纽约步骤r1 = ones(Ns1,1)*Ynominal(:)';%参考信号%循环通过每个输出,并以斯坦的间隔定义参考StepTime = 1;为了i = 1:ny r1(StepTime:end,i) = r1(StepTime:end,i) + Yrange(i); StepTime = StepTime + nStepLen;end% simulate closed loop for Ns1 steps and subject to reference r1SIM(mpcobjunscaled,NS1,R1)
——>”模式。干扰”属性是空的:Assuming unmeasured input disturbance #2 is integrated white noise. -->Assuming output disturbance added to measured output channel #1 is integrated white noise. Assuming no disturbance added to measured output channel #3. -->The "Model.Noise" property is empty. Assuming white noise on each measured output.

图包含5个轴对象。轴对象1包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象2包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象3包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象4包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象5包含类型行的对象。 These objects represent Driving inputs, MPC response1.

Figure contains 3 axes objects. Axes object 1 contains 2 objects of type line. These objects represent Driving inputs, MPC response1. Axes object 2 contains 2 objects of type line. These objects represent Driving inputs, MPC response1. Axes object 3 contains 2 objects of type line. These objects represent Driving inputs, MPC response1.

The tracking response of the first output is poor. The reason is that its range is small compared to the other outputs. If the default controller tuning weights are used, the MPC controller does not pay much attention to regulating this output because the associated penalty is so small compared to the other outputs in the objective function.

其次,测试未衡量的干扰拒绝。

% create simulation options object and set unmeasured disturbanceSimOpt = mpcsimopt; SimOpt.UnmeasuredDisturbance = Urange(UDindex)';% set number of simulation steps and reference signal%参考信号is equal to the range valuesNS2 = 100;r2 =一个(ns2,1)*yrange(:)';%模拟闭环主题为参考R2sim(mpcobjUnscaled,Ns2,r2,[],SimOpt)

Figure contains 3 axes objects. Axes object 1 contains 2 objects of type line. These objects represent Driving inputs, MPC response1. Axes object 2 contains 2 objects of type line. These objects represent Driving inputs, MPC response1. Axes object 3 contains 2 objects of type line. These objects represent Driving inputs, MPC response1.

图包含5个轴对象。轴对象1包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象2包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象3包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象4包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象5包含类型行的对象。 These objects represent Driving inputs, MPC response1.

The disturbance rejection response is also poor. None of the outputs return to their setpoints.

指定量表因子后,用默认的MPC权重评估MPC

Specifying input and output scale factors for the MPC controller:

  • Improves the numerical quality of the optimization and state estimation calculations.

  • 使默认调整权重更有可能达到良好的控制器性能。

Copy the MPC controller with default weights.

mpcobjscaled = mpcobjunscaled;

为了指定比例因素,最好使用每个输入和输出的预期工作范围。

% scale manipulated variables为了i = 1:长度(mvIndex)mpcobjscaled.manipulationVariobles(i).scaleFactor = urange(mvindex(i));end%比例测量的干扰nmd =长度(mdindex);为了i = 1:nmd mpcobjScaled.DisturbanceVariables(i).ScaleFactor = Urange(MDindex(i));end%缩放未衡量的干扰为了i = 1:length(UDindex) mpcobjScaled.DisturbanceVariables(i+nmd).ScaleFactor = Urange(UDindex(i));end% scale outputs为了i = 1:ny mpcobjscaled.ov(i).scaleFactor = yrange(i);end

Repeat the first test, which is a sequence of step setpoint changes in three reference signals.

SIM(mpcobjscaled,NS1,R1)
——>”模式。干扰”属性是空的:Assuming unmeasured input disturbance #2 is integrated white noise. -->Assuming output disturbance added to measured output channel #1 is integrated white noise. Assuming no disturbance added to measured output channel #3. -->The "Model.Noise" property is empty. Assuming white noise on each measured output.

Figure contains 3 axes objects. Axes object 1 contains 2 objects of type line. These objects represent Driving inputs, MPC response1. Axes object 2 contains 2 objects of type line. These objects represent Driving inputs, MPC response1. Axes object 3 contains 2 objects of type line. These objects represent Driving inputs, MPC response1.

图包含5个轴对象。轴对象1包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象2包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象3包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象4包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象5包含类型行的对象。 These objects represent Driving inputs, MPC response1.

Repeat the second test, which is an unmeasured disturbance.

SIM(mpcobjscaled,ns2,r2,[],simopt)

Figure contains 3 axes objects. Axes object 1 contains 2 objects of type line. These objects represent Driving inputs, MPC response1. Axes object 2 contains 2 objects of type line. These objects represent Driving inputs, MPC response1. Axes object 3 contains 2 objects of type line. These objects represent Driving inputs, MPC response1.

图包含5个轴对象。轴对象1包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象2包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象3包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象4包含类型行的对象。这些对象代表驱动输入,MPC响应1。轴对象5包含类型行的对象。 These objects represent Driving inputs, MPC response1.

Both setpoint tracking and disturbance rejection responses are good even without tuning MPC weights. This is because now the original weights apply to scaled signals, and therefore the weighting effect is not distorted.

也可以看看

|

Related Topics