Constraint Handling in MPC, Vector plot using 'plot' command

2 vues (au cours des 30 derniers jours)
shweta
shweta le 25 Oct 2012
I have written following program for MPC controller:
% A quadruple tank system consisting of four interconnected tanks** % No disturbance is considered, No model mismatch % MPC Control Action - Step by step Simulation
A1=28; A3=28; A2=32; A4=32; a1=0.071; a3=0.071; % Cross-section of outlet level a2=0.057; a4=0.057; % Cross-section of outlet level kc=0.5; g=981; k1=3.33; k2=3.35; r1=0.70; r2=0.60; h1= 12.4; % Level of water in tank1 h2=12.7; % Level of water in tank2 h3=1.8; % Level of water in tank3 h4=1.4; % Level of water in tank4
T1=(A1/a1)*(2*h1/g)^(1/2) % Time Constant T2=(A2/a2)*(2*h2/g)^(1/2) % Time Constant T3=(A3/a3)*(2*h3/g)^(1/2) % Time Constant T4=(A4/a4)*(2*h4/g)^(1/2) % Time Constant
A=[(-1/T1) 0 (A3/A1*T3) 0; 0 (-1/T2) 0 (A4/A2*A4); 0 0 (-1/T3) 0; 0 0 0 (-1/T4)] B=[(r1*k1/A1) 0; 0 (r2*k2/A2); 0 ((1-r2)*k2/A3); ((1-r1)*k1/A4) 0] C=[kc 0 0 0;0 kc 0 0] D=zeros(2,2)
sys=ss(A,B,C,D) % Continuous Time State Space Model
Ts=5; % Sampling Time model=c2d(sys,Ts) % Discrete time State Space Model [Ad,Bd,Cd,Dd] = c2dm(A,B,C,D,Ts)
%% Assign names to I/O variables (note: the model has no physical meaning)
model.InputName={'Voltage_Pump1';'Voltage_Pump2'}; model.OutputName={'Level_Tank1';'Level_Tank2'}; %model.InputUnit = {'V';'V'}; %model.OutputUnit = {'cm';'cm'};
%% Define I/O constraints and units
clear InputSpecs OutputSpecs InputSpecs(1)=struct('Min',-1,'Max',1,'RateMin',-0.1,'Ratemax',0.1); % Constraint on Voltage_Pump1 InputSpecs(2)=struct('Min',-1,'Max',1,'RateMin',-0.1,'Ratemax',0.1); % Constraint on Voltage_Pump2 OutputSpecs(1)=struct('Min',-5,'Max',5); % Constraint on Level_Tank1 OutputSpecs(2)=struct('Min',-5,'Max',5); % Constraint on Level_Tank2
%% Define weights on manipulated and controlled variables
Weights=struct('ManipulatedVariables',[1 1],... 'ManipulatedVariablesRate',[.1 .1],... 'OutputVariables',[1 1]);
%% Define prediction and control horizons, and set up the MPC object
ts=1; m=2; p=5;
MPCobj=mpc(model,ts,p,m,Weights,InputSpecs,OutputSpecs)
%% Closed-loop MPC Simulation Using the Command SIM
Tstop=30; % simulation time x=[0 0 0 0]'; % Initial state of the plant xmpc=mpcstate(MPCobj); % Initial State of the MPC controller r=[1 1]; % Output reference trajectory u=[0 0]';
%% Storage of closed loop MPC trajectories in arrays YY,UU,XX
YY=[]; UU=[]; XX=[];
%% Main Simulation Loop
for t=0:round(Tstop/ts)-1, XX=[XX,x];
% Plant Equations: Output Update
y=Cd*x;
YY=[YY,y]
% Compute MPC law
u=mpcmove(MPCobj,xmpc,y,r)
% Plant Equations: State Update
x=Ad*x+Bd*u;
UU=[UU,u];
end
%% Plot Results
close all
subplot(221) plot(0:ts:Tstop-Ts,YY(1)) grid title('Output_1')
subplot(222) plot(0:ts:Tstop-Ts,YY(2)) grid title('Output_2')
subplot(223) plot(0:ts:Tstop-Ts,UU(1)) grid title('Input_1')
subplot(224) plot(0:ts:Tstop-Ts,UU(2)) grid title('Input_2')
Problem is that it is not handling constraint on 'y'. Only constraints on 'u' are handled by the software. And how to plot two outputs in plot command or how to plot vector using plot command?

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by