How to enter multiple parameter estimations in a single genetic algorithm (GA)
Show older comments
Hello,
I have this code that estimates 2 variables (kd and Kla) from an ODE by using a genetic algorithm. The code predicts these two variables for a given data (time05 and C05). However, I have 3 data sets, 05, 20, and 35, and I want to find a kd and Kla that satisfy these 3 data sets.
There are 4 values in the ode. kd and KLa, which are the unknown values and that I want to find with the GA. O3_x which is a known value and is different for each data set as it is related to pressure. Finally, there is the initial condition, O3o which is always zero.
Does anyone know how I can integrate these 3 data sets into a single GA to get only one kd and one Kla that satisfy these 3 data sets?
% DATA
% set 1
time05 = [0; 50; 200; 300; 400; 600; 850; 1190; 1770; 2400];
C05 = [0;0.05e-04;0.25e-04;0.45e-04;0.55e-04;0.6e-04;0.75e-04;0.80e-04;0.89e-04;0.92e-04];
% set 2
time20 = [0;50;125;250;480;625;780;1000;1450;1700;2350];
C20 = [0e-03;0.0200e-03;0.0750e-03;0.1300e-03;0.1880e-03;0.2200e-03;0.2400e-03;0.2650e-03;0.3000e-03;0.3200e-03;0.3400e-03];
% set 3
time35 = [0;100;150;210;270;310;400;600;750;900;1220;1800;1910];
C35 = [0e-03;0.0600e-03;0.1300e-03;0.1600e-03;0.2200e-03;0.2500e-03;0.3000e-03;0.3400e-03;0.3750e-03;0.4250e-03;0.4600e-03;0.4850e-03;0.5050e-03];
% Optimoptions - Reproducibility
options = optimoptions('ga','ConstraintTolerance',1e-6,'PlotFcn', @gaplotbestf);
rng default % For reproducibility
% Genetic Algorithm
x = ga(@(par) sys_id2(par,time05,C05),3,[],[],[],[],[1e-4;0.0002;0],[0.0009;15;0],[],options);
% Parameters:
kla=x(1); kd=x(2);
% O3_x calculation by pressure
H = 5.22E+05; %
Pa05 = 500; % Pa
O3_x = Pa05/H;
Pa20 = 2000; % Pa
O3_x20 = Pa20/H;
Pa35 = 3500; % Pa
O3_x35 = Pa35/H;
% Initial condition
O3o=x(3);
% Definition of f(x,t)
fvdp = @(t,O3) -kd*O3^2+kla*(O3_x-O3);
% Solution
[t_05,y_05] = ode45(fvdp,time05, O3o);
% Plotting
plot(time05,C05,'-o','MarkerSize',6, ...
'MarkerEdgeColor','red', ...
'LineWidth',1, ...
'MarkerFaceColor','red', ...
'Color','red')
hold on
plot(t_05,y_05,'b--','LineWidth',2)
txt05 = {['KLa = ' num2str(x(1)) ' s-1'],['k = ' num2str(x(2)) ' M–1 s–1'],['O3* = ' num2str(O3_x) ' mol/L'],['P = ' num2str(Pa05) ' Pa']};
xt05 = [2000];
yt05 = [0.9e-4];
text(xt05,yt05,txt05)
set(gcf,'color','w');
title('Ozone absorption')
legend('Sotelo et al., 1989 0.5KPa','estimated 0.5 KPa')
xlabel('t (s)','Interpreter','Latex','FontSize', 12)
ylabel('$[O_3] (mol L-1)$','Interpreter','Latex','FontSize', 12)
hold off
1 Comment
Star Strider
on 15 Jun 2023
Edited: Star Strider
on 16 Jun 2023
I doubt that one set of kinetic parameters could estimate all three data sets, since they seem to be completely different —
% set 1
time05 = [0; 50; 200; 300; 400; 600; 850; 1190; 1770; 2400];
C05 = [0;0.05e-04;0.25e-04;0.45e-04;0.55e-04;0.6e-04;0.75e-04;0.80e-04;0.89e-04;0.92e-04];
% set 2
time20 = [0;50;125;250;480;625;780;1000;1450;1700;2350];
C20 = [0e-03;0.0200e-03;0.0750e-03;0.1300e-03;0.1880e-03;0.2200e-03;0.2400e-03;0.2650e-03;0.3000e-03;0.3200e-03;0.3400e-03];
% set 3
time35 = [0;100;150;210;270;310;400;600;750;900;1220;1800;1910];
C35 = [0e-03;0.0600e-03;0.1300e-03;0.1600e-03;0.2200e-03;0.2500e-03;0.3000e-03;0.3400e-03;0.3750e-03;0.4250e-03;0.4600e-03;0.4850e-03;0.5050e-03];
figure
plot(time05, C05, '.-', 'DisplayName','500 Pa')
hold on
plot(time20, C20, '.-', 'DisplayName','2000 Pa')
plot(time35, C35, '.-', 'DisplayName','3500 Pa')
hold off
grid
xlabel('Time')
ylabel('Concentration')
legend('Location','best')
title('Original Data')
C05i = interp1(time05, C05, time35, 'linear');
C20i = interp1(time20, C20, time35, 'linear');
t = time35;
Cmtx = [C05i C20i, C35];
figure
plot(t, Cmtx(:,1), '.-', 'DisplayName','500 Pa')
hold on
plot(t, Cmtx(:,2), '.-', 'DisplayName','2000 Pa')
plot(t, Cmtx(:,3), '.-', 'DisplayName','3500 Pa')
hold off
grid
xlabel('Time')
ylabel('Concentration')
legend('Location','best')
title('Interpolated Vectors')
The different pressures would need to be part of the kinetic equations (one for each pressure, I leave that to you), and they would all have to be interpolated to the same (shortest) time vector, with all original or interpolated concentrations at each of those times. Then, that would probably be possible. See: Estimate Parameters for System of ODEs with given Data using a Genetic Algorithm (COVID-19-Model) - MATLAB Answers - MATLAB Central for an example.
EDIT — (16 Jun 2023 at 17:42)
Added vector interpolations and plot.
.
Accepted Answer
More Answers (0)
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




