SEIR model for ebola
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
%% SEIR model function
function dydt = seir_model(t, y, params, N, fixed_gamma, fixed_delta)
beta = params(1);
q = params(2);
alpha = params(3); % Now alpha is part of the parameters to be estimated
S = y(1);
E = y(2);
I = y(3);
R = y(4);
dS = -beta * S * (q * E + I) / N;
dE = beta * S * (q * E + I) / N - fixed_delta * E;
dI = fixed_delta * E - fixed_gamma * I;
dR = fixed_gamma * I;
dydt = [dS; dE; dI; dR];
end
%% GMMP scheme to solve FDEs
function y = gmmp_scheme(f, y0, t, params, N, fixed_gamma, fixed_delta)
n = length(t);
m = length(y0);
y = zeros(m, n);
y(:, 1) = y0;
% Initial values
for i = 2:n
ti = t(i);
yi = y(:, i-1);
% Fractional derivative approximation using GMMP
yi_next = yi + (ti^(params(3)-1) - (i-1)^(params(3)-1)) * f(ti, yi, params, N, fixed_gamma, fixed_delta);
y(:, i) = yi_next;
end
end
%% Objective function for MGAM
function error = objective_function(params, f, y0, t, data, N, fixed_gamma, fixed_delta)
beta = params(1);
q = params(2);
alpha = params(3); % Now alpha is part of the parameters to be estimated
y = gmmp_scheme(f, y0, t, params, N, fixed_gamma, fixed_delta);
infected_model = y(3, :);
error = sum((infected_model - data).^2);
end
%% MGAM function for parameter estimation
function estimated_params = mgam(f, y0, t, data, N, fixed_gamma, fixed_delta)
param_guess = [0.5, 0.5, 0.5]; % Guess for beta, q, and alpha
obj_func = @(params) objective_function(params, f, y0, t, data, N, fixed_gamma, fixed_delta); % Pass data here
options = optimoptions('ga', 'Display', 'iter', 'PopulationSize', 50);
[estimated_params, ~] = ga(obj_func, 3, [], [], [], [], [0, 0, 0], [1, 1, 1], [], options);
end
%% Main script
N = 18805278;
m = 1; % <-- User input value
S0 = N * m/100;
E0 = 0;
I0 = 15;
R0 = 0;
y0 = [S0; E0; I0; R0];
t0 = 0;
tf = 250;
h = 0.1;
t = t0:h:tf;
data = y0(3) * exp(0.05 * (t - t0));
%% Define fixed gamma and delta here (replace with your desired values)
fixed_gamma = 1/7;
fixed_delta = 1/12;
estimated_params = mgam(@seir_model, y0, t, data, N, fixed_gamma, fixed_delta);
beta = estimated_params(1);
q = estimated_params(2);
alpha = estimated_params(3);
fprintf('Estimated Parameters:\n');
fprintf('Beta: %.2f\n', beta);
fprintf('Alpha: %.2f\n', alpha);
fprintf('Q: %.2f\n', q);
fprintf('\n');
y = gmmp_scheme(@seir_model, y0, t, [beta, q, alpha], N, fixed_gamma, fixed_delta);
figure;
plot(t, y(3, :), 'r-', 'LineWidth', 2);
hold on;
% Set the plot limits
xlim([0 250]); % X-axis limit from 0 to 250
ylim([0 12000]); % Y-axis limit from 0 to 12000
% Optionally, add labels and title for better visualization
xlabel('Time');
ylabel('Infections');
title('SEIR Model Simulation');
hold off;
this is the code which i used for plotting. but while estimating the parameters, each time I run the code i get different parameter values also the parameter values estimated are wrong. what would possibly be the problem?
0 Kommentare
Antworten (1)
Kautuk Raj
am 27 Jun. 2024
It looks like you are encountering issues with parameter estimation in your SEIR model using a genetic algorithm (GA). Here are a few suggestions which you can try:
1. Initial Guess and Bounds:
Expand the bounds to realistic ranges. For example:
lower_bounds = [0, 0, 0];
upper_bounds = [5, 5, 2];
2. Objective Function Scaling:
Normalize the error in your objective_function to improve optimization:
error = sum(((infected_model - data) ./ data).^2);
3. Optimization Options:
Adjust GA options to improve convergence:
options = optimoptions('ga', 'PopulationSize', 100, 'MaxGenerations', 200, 'FunctionTolerance', 1e-6);
4. Stochastic Nature of GA:
Set a random seed for reproducibility:
rng(1);
I hope these adjustments help improve the parameter estimation process in your SEIR model.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!