• 大小: 55KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: Matlab
  • 标签:

资源简介

滚动时域优化(RHC)MATLAB源代码,用于动态环境下影响下系统的自适应控制,可以运行。

资源截图

代码片段和文件信息

% Example 6.2: Constrained Receding Horizon Control
% Demonstration of Receding Horizon Control (RHC) using LMI

% ###################################################################
% Edited by Giovani Tonel ( giotonel@enq.ufrgs.br ) March 28th 2007
% ###################################################################
%
% Retired from the book: 
% Receding Horizon Control - Model Predictive Control for State Models
% Authors: W.H. Kwon and S. Han



clear all
close all
clc
disp(‘ ‘);
disp(‘=================================================================================‘);
disp(‘                   Constrained Receding Horizon Control  ‘);
disp(‘=================================================================================‘);
disp(‘ ‘);



%% System State Equation
A =  [1 0.2212; 0 0.7788];
B  =  [0.0288; 0.2212]; 
G  = [1 0; 0 1; 1.5 1];

%% Initial State
x0  =  [1;0.3];
[nn] = size(A); 
[nm] = size(B);

% Let‘s get predictor
N  = input(‘ Horizon Length N:‘ ); 
tsim = input(‘Total simulation time:‘);

% Input Constraint
u_lim = 0.5; 
ubar_lim  = []; 

for i=1:N
   ubar_lim=[ubar_lim; u_lim];
end

% State Constraint
x_lim  =  [1.5; 0.3]; 
G  = [1 0; 0 1];
g_lim  =  [1.5; 0.3]; 
gbar_lim  =  []; 

for i=1:N
   gbar_lim = [gbar_lim; g_lim];
end

[ng_r ng_c] = size(G);

% Weighting Matrix
Q  =  1*eye(size(A)); 
R  =  1;
A_hat = []; 
B_hat = []; 

for i=1:N-1
   A_hat = daug(A_hat A);
   B_hat = daug(B_hat B);
end 

A_hat  =  [zeros(nn*N); A_hat zeros(n*(N-1)n)];
B_hat  =  [zeros(nm*N); B_hat zeros(n*(N-1)m)];
W_hat  =  inv(eye(n*N)-A_hat)*B_hat; 
V0_hat = inv(eye(n*N)-A_hat)*[x0;zeros(n*(N-1)1)];
B_bar=[]; 

for i=1:N
   B_bar = [B_bar A^(N-i)*B];
end

% Let‘s get stacked weighting matrix
[mn] = size(Q); 
[pq]  = size(R); 
Q_hat  = []; 
R_hat  = []; 


for i=1:N
   Q_hat = daug(Q_hat Q);
   R_hat = daug(R_hat R);
end

% Let‘s get constraint matrix
G_bar = []; 

for i=1:N
   G_bar = daug(G_bar G);
end

W = W_hat‘*Q_hat*W_hat + R_hat; 
W = (W+W‘)/2;

% Simulation starts !
t = []; 
State  = []; 
U  = []; 
summed_cost = 0; 
Summed_cost = [];
Cost_at_k = []; 
x = x0;

R1=[]; 
R2=[]; 

for i=0:(tsim-1)
   V0_hat =  inv(eye(n*N)-A_hat)*[x;zeros(n*(N-1)1)];
   V  =  2*W_hat‘*Q_hat*V0_hat;
   V0  =  V0_hat‘*Q_hat*V0_hat;
   
   %% Solve LMI
   [XYr1r2opt_u] = rhc_lmi(xNABQRW_hatV0_hatQ_hatB_bar...
      WVV0GG_barubar_limgbar_limu_limg_lim);
   
   P = r2*inv(X);
   
   if (i==0)
      boundary0=[];
      for th=0:0.01:2*pi
         z  =  sqrt(r2)*inv(P^0.5)*[cos(th);sin(th)];
         boundary0 = [boundary0 z];
      end
   elseif(i==1)
      boundary1=[];
      for th=0:0.01:2*pi
         z = sqrt(r2)*inv(P^0.5)*[cos(th);sin(th)];
         boundary1=[boundary1 z];
      end
   elseif(i==2)
      boundary2=[];
      for th=0:0.01:2*pi
       

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        3913  2007-03-28 18:06  rhc_lmi.m
     文件        4914  2007-03-28 18:52  RHC.m
     文件       63497  2007-03-29 10:46  example6.2.JPG

评论

共有 条评论