% This is the M-Script to run corona_modified_SRI.slx
% IN ORDER TO FIND THE BEST ALPHA, BETA and GAMMA
% BASED ON THE AVAILABLE DATA at DAY 52 after 15/03/2020
% Simulation time is 52 days
T = 52;
REF_I = 12071;
REF_R = 2197;
REF_D = 872;
% run for 
ITERASI = 2000;
N = 0.01*270000000; % Assume: 1% of the total population is affected by the virus
Io = 96; % Initial number of people infected on 14/03/2020
Ro = 3; % Initial number of prople recovered on 14/03/2020
alpha = 0.0068; % Death Rate = 0.68% Infected
beta = 0.111; % Every 1000 persons infected 111 persons each day
gamma = 0.018; % 1.8% infected people recovered each day
ALPHA(1)=alpha;
BETA(1)=beta;
GAMMA(1)=gamma;
for I = 1:ITERASI
    iterasi(I)=I;
    alpha = ALPHA(I);
    alpha_i(I) = alpha;
    beta = BETA(I);
    beta_i(I) = beta;
    gamma = GAMMA(I);
    gamma_i(I)=gamma;
    sim('corona_modified_SRI.slx');
    M = length(infected);
    ERR_I(I)=round(infected(M)) - REF_I;
    ERR_R(I)=round(recovered(M)) - REF_R;
    ERR_D(I)=round(death(M)) - REF_D;
    % next
    ALPHA(I+1)=ALPHA(I) - (10^(-8))*ERR_D(I);
    BETA(I+1)=BETA(I) - (10^(-7))*ERR_I(I);
    GAMMA(I+1)=GAMMA(I) - (10^(-7))*ERR_R(I);
end
subplot(211), plot(iterasi, ERR_I, '*', iterasi, ERR_R, 'r', iterasi, ERR_D, 'g'), grid on, xlabel('iterasi ke I'), ylabel('ERROR D,R,I')
subplot(212), plot(iterasi, beta_i, '*', iterasi, gamma_i, 'r', iterasi, alpha_i, 'g'), grid on, xlabel('iterasi ke I'), ylabel('ALPHA, BETA, GAMMA') 
ALPHA_FINAL = alpha_i(ITERASI)
BETA_FINAL = beta_i(ITERASI)
GAMMA_FINAL = gamma_i(ITERASI)