資源簡(jiǎn)介
基于狀態(tài)空間的模型預(yù)測(cè)MPC控制器的設(shè)計(jì),附帶例子(MATLAB)

代碼片段和文件信息
function?f=mpcsetup(ABCDpmQRx0u0)
%?MPCSETUP??Set-up?State?Space?MPC?controller
%
%???SSMPC=MPCSETUP(ABCDPMQRX0U0)?returns?a?function?handle?for?a
%???state?space?model?predictive?control?for?the?state?space?model
%???x(k+1)?=?Ax(k)?+?Bu(k)
%???y(k)???=?Cx(k)?+?Du(k)
%???with?predictive?horizon?P?and?moving?horizon?M?performance?weights?of
%???output?Q?and?of?input?R?initial?state?X0?and?initial?control?U0.
%
%???SSMPC?is?the?online?controller?which?can?be?called?as?follows?
%
%???U?=?SSMPC(YREF)?returns?the?control?input?U?(nu?by?1)?according?to
%???current?measured?output?Y?(1?by?ny)?and?future?reference?REF?(nr?by
%???ny?nr>=1).?
%
%???The?MPC?minimize?the?following?performance?criterion:
%
%???J?=?min?Y‘QY?+?U‘RU
%
%???The?online?controller?is?implemented?as?a?nested?function?so?that?the
%???state?of?the?internal?model?can?be?kept?inside?of?the?function.?This
%???simplifies?the?input?and?output?interface?of?the?online?controller.
%
%?See?also:?mpc?dmc
%?Version?1.0?by?Yi?Cao?at?Cranfield?University?on?20?April?2008
%?Example:?2-CSTR?model
%{
%?Six-state?model
A=[?0.1555??-13.7665???-0.0604?????????0?????????0?????????0
????0.0010????1.0008????0.0068?????????0?????????0?????????0
?????????0????0.0374????0.9232?????????0?????????0?????????0
????0.0015???-0.1024???-0.0003????0.1587??-13.6705???-0.0506
?????????0????0.0061?????????0????0.0006????0.9929????0.0057
?????????0????0.0001?????????0?????????0????0.0366????0.9398];
Bu=[0.0001???????0
?????????0???????0
???-0.0036???????0
?????????0??0.0001
?????????0???????0
?????????0?-0.0028];
Bd=[??????0?????????0
??????????0?????????0
?????0.0013?????????0
??????????0?????????0
??????????0?????????0
??????????0????0.0008];
C=[0?362.995?0?0?0?0
???0?0?0?0?362.995?0];
D=zeros(22);
%?Prediction?horizon?and?moving?horizon
p=10;
m=3;
%?Performance?wights
Q=1.5*eye(2*p);
R=eye(2*m);
%?MPC?set-up
ssmpc=mpcsetup(ABuCDpmQR);
%?Simulation?length?and?variables?for?results
N=1500;
x0=zeros(61);
Y=zeros(N2);
U=zeros(N2);
%?Predefined?reference
T=zeros(N2);
T(10:N:)=1;
T(351:N:)=3;
T(600:N:)=5;
T(1100:N:)=3;
%?Simulation
for?k=1:N
????%?Process?disturbances
????w=Bd*(rand(21)-0.5)*2;
????%?Measurements?noise
????v=0.01*randn(21);
????%?actual?measurement
????y=C*x0+v;
????%?online?controller
????u=ssmpc(yT(k:end:));
????%?plant?update
????x0=A*x0+Bu*u+w;
????%?save?results
????Y(k:)=y‘;
????U(k:)=u‘;
end
t=(0:N-1)*0.1;
subplot(211)
plot(tYtT‘r--‘‘linewidth‘2)
title(‘output?and?setpoint‘)
ylabel(‘temp?C^\circ‘)
legend(‘T_1‘‘T_2‘‘Ref‘‘location‘‘southeast‘)
subplot(212)
stairs(tU‘linewidth‘2)
legend(‘u_1‘‘u_2‘‘location‘‘southeast‘)
title(‘input‘)
ylabel(‘flow?rate?m^3/s‘)
xlabel(‘time?s‘)
%}
%?Input?and?output?check
error(nargchk(810nargin));
error(nargoutchk(11nargout));
%?dimension?of?the?system
nx=size(A1);
[nynu]=size(D);
%
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-11-13?11:04??基于狀態(tài)空間的模型預(yù)測(cè)控制ssmpc\
?????文件????????1327??2009-05-20?16:16??基于狀態(tài)空間的模型預(yù)測(cè)控制ssmpc\license.txt
?????文件????????4696??2008-04-22?00:12??基于狀態(tài)空間的模型預(yù)測(cè)控制ssmpc\mpcsetup.m
?????文件????????3819??2008-04-22?00:11??基于狀態(tài)空間的模型預(yù)測(cè)控制ssmpc\ssmpctutorial.m
評(píng)論
共有 條評(píng)論