Bwb Pasi 2001 Mpc Workshop

12
MPC Workshop z There exists a MPC Toolbox available through Mathworks ¾ I do not use this! z My students write all of their own MPC code z This workshop is based on MATLAB code that I have written ¾ It is definitely NOT commercially quality code z Feel free to modify my code to fit your needes B. Wayne Bequette

Transcript of Bwb Pasi 2001 Mpc Workshop

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 1/12

MPC Workshop

z There exists a MPC Toolbox available through Mathworks

¾ I do not use this!

z My students write all of their own MPC code

z This workshop is based on MATLAB code that I have

written

¾ It is definitely NOT commercially quality code

z Feel free to modify my code to fit your needes

B. Wayne Bequette

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 2/12

MPC Workshop

z Primary MPC files

¾ QSSmpcNLPlant.m (QP, State Space MPC)

isim = 1 (DMC), isim = 2 (KF-based MPC) iqp = 1 (unconstrained), iqp = 2 (QP solution)

¾ KmatQSS.m (generates several matrices)

¾ qSSmpccalc.m (calculates control moves)

¾ planteqns.m (set of plant odes)

z Driver files

¾ r_FOmpc.m (first-order example)

FOodedev.m (planteqns = ‘FOodedev’)¾ r_VDV.m (linear van de vuuse example)

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 3/12

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 4/12

% discretize the model

delt= 0.2; % sample time = 0.2

sysd_mod = c2d(sysc_mod,delt);

[phi_mod,gamma_stuff,cd_mod,dd_stuff] = ssdata(sysd_mod)

%

gamma_mod = gamma_stuff(:,1); % first input is manipulated

gammad_mod = gamma_stuff(:,2); % second input is a disturbance

kk

kd

kkk

Cxy

duxx

=

Γ+Γ+Φ=+1

Continuous plant

% ------------ plant parameters -------------------------------

planteqns = 'FOodedev'

cplant= [1]; % the only state is also the output

nstates_p = 1; % one plant state

parvec(1) = 2; % the parameter is a time constant with value =2

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 5/12

Controller Parameters% ---------------- controller parameters -------------------

p = 10; % prediction horizon

m = 1; % control horizon

ny = 1; % number of measured outputs

nu = 1; % number of manipulated inputs

nd = 1; % number of actual disturbancesnd_est = 1; % number of estimated disturbances (used by KF)

weightu = [0]; % weighting matrix for control action

weighty = [1]; % weighting matrix for outputs

% -----------------constraints ------------------------------umin = [-1000];

umax = [1000];

dumin = [-1000];

dumax = [1000];% ------ Kalman Filter matrices -----------------------------

Q = 100*eye(nd_est,nd_est); % state covariance

R = eye(ny); % measurement noise covariance

%

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 6/12

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 7/12

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 8/12

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 9/12

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 10/12

Linear Van de Vuuse Reactor (inverse response)

[ ]xy

duxx

10

117.1

7

117.1

7

2381.2833.0

04048.2

=

⎥⎦

⎤⎢⎣

−+⎥⎦

⎤⎢⎣

−+⎥⎦

⎤⎢⎣

=&

Module 5

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 11/12

r_VDV

Comparison of (P=10,M=3) with (P=25,M=1)

0 1 2 3 4 5 6-1

-0.5

0

0.5

1

time

      y

DMC: P = 25, M = 1 and P = 10, M = 3

 

0 1 2 3 4 5 60

2

4

6

8

10

      u

time

P = 10, M = 3

P = 25, M = 1

7/29/2019 Bwb Pasi 2001 Mpc Workshop

http://slidepdf.com/reader/full/bwb-pasi-2001-mpc-workshop 12/12

0 1 2 3 4 5 6-1.5

-1

-0.5

0

0.5

1

1.5

time

      y

DMC: P = 8, M = 1 and P = 7, M = 1

 

0 1 2 3 4 5 6

-6

-4

-2

0

2

      u

time

P = 8, M = 1

P = 7, M = 1

r_VDVComparison of (P=8,M=1) with (P=7,M=1)