├── DMC_MIMO_DATA_Gen.m ├── DMC_SISO_DATA_Gen.m ├── DMC_simulink_trial_1_MIMO.slx ├── DMC_simulink_trial_2_SISO.slx └── README.md /DMC_MIMO_DATA_Gen.m: -------------------------------------------------------------------------------- 1 | % DMC MIMO Data Generator 2 | clear 3 | clc 4 | 5 | T_sampling = 0.1; 6 | Ts = 0.01; 7 | u_old_1 = 0; 8 | u_old_2 = 0; 9 | 10 | %% Definition of transfer functions 11 | s = tf('s'); 12 | K11 = (12.8*exp(-s))/(16.7*s+1); 13 | K12 = (-18.9*exp(-3*s))/(21*s+1); 14 | K21 = (6.6*exp(-7*s))/(10.9*s+1); 15 | K22 = (-19.4*exp(-3*s))/(14.4*s+1); 16 | 17 | t_vec = 0:T_sampling:199.9; 18 | 19 | g11 = step(K11,t_vec); 20 | g12 = step(K12,t_vec); 21 | g21 = step(K21,t_vec); 22 | g22 = step(K22,t_vec); 23 | 24 | 25 | lambda=100; %Tuning Factor 26 | N = 1000; % Past control moves; 27 | P=900; %Prediction Horizon 28 | M=600; %Control Horizon 29 | u1 = zeros(N,1); %Past control moves 30 | u2 = zeros(N,1); 31 | 32 | g11 = [g11;g11(end)*ones(P,1)]; 33 | g12 = [g12;g12(end)*ones(P,1)]; 34 | g21 = [g21;g21(end)*ones(P,1)]; 35 | g22 = [g22;g22(end)*ones(P,1)]; 36 | 37 | G11=zeros(P,M+1); 38 | G12=zeros(P,M+1); 39 | G21=zeros(P,M+1); 40 | G22=zeros(P,M+1); 41 | 42 | for k=1:M+1 43 | for i = k:P 44 | j = k; 45 | G11(i,j)= g11(i-k+1); 46 | G12(i,j)= g12(i-k+1); 47 | G21(i,j)= g21(i-k+1); 48 | G22(i,j)= g22(i-k+1); 49 | end 50 | end 51 | 52 | G = [G11 G12;G21 G22]; 53 | 54 | Fac=(inv(G'*G+lambda*eye(2*(M+1))))*(G'); % 2(M+1)x 2P 55 | 56 | temp_g2_g11 = repmat(g11(1:N)',P,1); 57 | temp_g2_g12 = repmat(g12(1:N)',P,1); 58 | temp_g2_g21 = repmat(g21(1:N)',P,1); 59 | temp_g2_g22 = repmat(g22(1:N)',P,1); 60 | 61 | temp_g1_g11 = g11(2:P+1); 62 | temp_g1_g12 = g12(2:P+1); 63 | temp_g1_g21 = g21(2:P+1); 64 | temp_g1_g22 = g22(2:P+1); 65 | 66 | 67 | for i = 1:N-1 68 | temp_g1_g11 = [temp_g1_g11 g11(2+i:P+1+i)]; 69 | temp_g1_g12 = [temp_g1_g12 g12(2+i:P+1+i)]; 70 | temp_g1_g21 = [temp_g1_g21 g21(2+i:P+1+i)]; 71 | temp_g1_g22 = [temp_g1_g22 g22(2+i:P+1+i)]; 72 | end 73 | 74 | temp_f_11 = temp_g1_g11 - temp_g2_g11; 75 | temp_f_12 = temp_g1_g12 - temp_g2_g12; 76 | temp_f_21 = temp_g1_g21 - temp_g2_g21; 77 | temp_f_22 = temp_g1_g22 - temp_g2_g22; 78 | 79 | temp_f = [temp_f_11 temp_f_12;temp_f_21 temp_f_22]; 80 | 81 | u = [u1;u2]; 82 | save('dmc_mimo_data'); -------------------------------------------------------------------------------- /DMC_SISO_DATA_Gen.m: -------------------------------------------------------------------------------- 1 | %DMC SISO Data Generator 2 | 3 | clear; 4 | close all; 5 | clc; 6 | 7 | 8 | N = 1700; %no. of past control moves 9 | Ts = 0.01; %Integration Rate for plant 10 | T_sampling = 0.1; %Sample rate for collection of step response coefficents 11 | 12 | 13 | u_old = 0; %This is the control which was implemented at previous 14 | s = tf('s'); %instant 15 | K11 = (12.8*exp(-s))/(16.7*s+1); %Transfer Function 16 | t_vec = 0:T_sampling:100; % 17 | g11 = step(K11,t_vec); %step response coefficients are being 18 | %collected in y11 19 | 20 | g11 = [g11;g11(end)*ones(N-length(g11),1)]; 21 | 22 | 23 | P=600; %Prediction Horizon 24 | M=200; %Control Horizon 25 | lambda=50; %Tuning Factor 26 | u = zeros(N,1); %Past control moves 27 | y_meas = 0; 28 | G=zeros(P,M+1); 29 | g=g11; %Step response coefficients for the plant has 30 | 31 | 32 | for k=1:M+1 33 | for i = k:P 34 | j = k; 35 | G(i,j)= g(i-k+1); 36 | end 37 | end 38 | Fac=(inv(G'*G+lambda*eye(M+1)))*(G'); 39 | 40 | g_1 = [g;g(N)*ones(P,1)]; 41 | 42 | temp_g2 = repmat(g_1(1:N)',P,1); 43 | temp_g1 = g_1(2:P+1); 44 | for i = 1:N-1 45 | temp_g1 = [temp_g1 g_1(2+i:P+1+i)]; 46 | end 47 | temp_f = temp_g1 - temp_g2; -------------------------------------------------------------------------------- /DMC_simulink_trial_1_MIMO.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-Horizon-Controller/a365a7f2d81d32b491f4e076569e545a764d4952/DMC_simulink_trial_1_MIMO.slx -------------------------------------------------------------------------------- /DMC_simulink_trial_2_SISO.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ronakj91/Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-Horizon-Controller/a365a7f2d81d32b491f4e076569e545a764d4952/DMC_simulink_trial_2_SISO.slx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Model-Predictive-Control-Dynamic-Matrix-Controller-DMC-Receding-Horizon-Controller 2 | 3 | A Report on Implementation is at 4 | https://www.scribd.com/document/378683616/Model-Predictive-Control-Report-by-Ronak-Jain 5 | 6 | Following Files are present: 7 | ----------------------------------------------------------------------------------------------------------- 8 | 9 | DMC_MIMO_DATA_Gen 10 | 11 | DMC_simulink_trial_1_MIMO.slx 12 | 13 | DMC_SISO_DATA_Gen 14 | 15 | DMC_simulink_trial_2_SISO.slx 16 | 17 | ------------------------------------------------------------------------------------------------------------ 18 | 19 | Generate Data for SISO system by running DMC_SISO_DATA_Gen.m the run the simulation file DMC_simulink_trial_2_SISO.slx 20 | 21 | similarly do it for MIMO system. 22 | --------------------------------------------------------------------------------