LMPC - eliminating steady state offset
3 ビュー (過去 30 日間)
古いコメントを表示
I have a hybrid non-linear model, i linearized it around a point in order to implement Linear MPC. However, i always get a small steady state offset. What is a good approach to eliminate this small offset?
You can find the relevant code here. function sslinmod(.) is used to linearize the system, while function fcn_dh(.) contains the nonlinear system in order to get the measured real states.
I would appreciate the feedback.
%% Linear MPC
% Create the linearized system
x_ss=[0.4 0.1]; % The system is linearized around this point
[A,B,C,D,u1_ss,u2_ss]=sslinmod(x_ss);
sys=ss(A,B,C,D);
sys.InputName={'u_1','u_2'};
sys.OutputName={'h_1','h_2'};
sys.StateName={'h_1','h_2'};
%initial state
x0=[0.8 ;0.5];
%LMPC
Ts=1; %Sampling time
p=5; %Prediction horizon
c=4; %Control horizon
MPCobj=mpc(sys,Ts,p,c);
MPCobj.Model.Plant.OutputUnit = {'m','m'};
MPCobj.Model.Nominal.Y = x0;%Initial point
old_status = mpcverbosity('off');
%setconstraint(MPCobj); %To remove constraints
%Setting constraints
MPCobj.MV(1).Min=0;
MPCobj.MV(2).Min=0;
MPCobj.MV(1).Max=1;
MPCobj.MV(2).Max=1;
MPCobj.OV(1).Min=0;
MPCobj.OV(2).Min=0;
MPCobj.OV(1).Max=1.2;
MPCobj.OV(2).Max=1;
%specify weights
mpc1.Weights.MV = [0 0];
mpc1.Weights.MVRate = [0.1 0.1];
mpc1.Weights.OV = [1 1];
mpc1.Weights.ECR = 100000;
%review(MPCobj)
%Main Loop
ref=[0.6 0.2]; %reference states
x0=[0.8 0.5]; %initial states
u0=[0 0]; %initial inputs
T=200; %Simulation time
Y=zeros(T,2); %History of states
U=zeros(T,2); %History of inputs
tic;
for i=1:1:T
Y(i,:)=x0;
U(i,:)=u0;
ode=@(t,y,u) fcn_dh(t,y,u0);
tspan = [0 1];
[tt,x] = ode45(ode,tspan,x0);
x0=x(size(x,1),:);
MPCobj.Model.Nominal.Y = x0';
[y,~,u]=sim(MPCobj,1,ref);
u0=u;
end
tEnd=toc;
display("Computational time for linear MPC: "+tEnd)
%Plotting the simulation
t=0:1:T-1;
figure;
subplot(2,1,1);
hold on; grid on;
plot(t,Y);
legend('h_1 real','h_2 real');
title('System responce to linear MPC inputs');
ylabel('height (m)');
xlabel('time (sec)');
hold off;
subplot(2,1,2);
stairs(t,U);
hold on; grid on;
legend('u_1','u_2');
title('MPC control inputs');
ylabel('Valve opening (%)');
xlabel('time (sec)');
hold off;
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Controller Creation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!