optimization of delayed differential equations (dde)

6 visualizaciones (últimos 30 días)
Malgorzata Wieteska
Malgorzata Wieteska el 9 de Mayo de 2022
Comentada: Torsten el 14 de Mzo. de 2024
Hello,
I try to optimise (finding the parameter's value) in the system of dde, unfortunately I can't find any example how to do it. I used to optimization of ode using ode45 solver with lsqlin for instance. I will appreciate the help. The dde23 seems not to be working with lsqlin. I will appreciate any help.
  1 comentario
Torsten
Torsten el 9 de Mayo de 2022
Editada: Torsten el 9 de Mayo de 2022
Do you have a code for your model equations set up with dde23 ?
If yes, you should include it and tell which parameter(s) you are trying to optimize on the basis of which input data.

Iniciar sesión para comentar.

Respuesta aceptada

Torsten
Torsten el 9 de Mayo de 2022
Editada: Torsten el 9 de Mayo de 2022
Make the best of it.
pTrue = [1 1 1 1 1 1 1 1 1];
time = 0:7;
Y = ...;
Am1=[1,1.1,1.4,0.7,0.8,1.6,2,1.5];
Bm1=[1.5,1.0,0.4,1.7,0.9,1.3,1.5,1.4];
Am=@(t)interp1(time,Am1,t)
Bm=@(t)interp1(time,Bm1,t)
p = lsqnonlin(@(p) Errors(p,time,Y,Am,Bm),0.8*pTrue)
function res = Errors(p,time,Y,Am,Bm)
lags=[1,2];
[T,SOL]=dde23(@(t,y,Z)ddefunEx(t,y,Z,p,Am,Bm), lags, [1,1,1,1], time);
res = Y-SOL;
res = res(:);
end
function dydt = ddefunEx(t,y,Z,p,Am,Bm)
ylag1 = Z(:,1);
ylag2 = Z(:,2);
E1p=y(1)
E2p=y(2)
A1=y(3)
B1=y(4)
n_A=p(1);%0.6;
n_B=p(2);%0.1;
KE1=p(3);%0.2;
KE2=p(4);%0.2;
Vp_A=p(5);%1.2;
Vp_B=p(6);%1.5;
alpha_p=p(7);%0.4;
kA=p(8);%0.4;
kB=p(9);%1.2;
%Auxiliary equations
ALPHA1=n_A*E1p*A1/(KE1*(1+A1))-A1;
ALPHA2=n_B*E2p*B1/(KE2*(1+B1))-B1;
dydt= [Vp_A*Am(t)-alpha_p*ylag1(1);
Vp_B*Bm(t)-alpha_p*ylag1(2);
kA*Am(t)-ylag2(3)-ALPHA1+ALPHA2;
kB*Bm(t)-ylag2(4)+ALPHA1-ALPHA2];
end
  4 comentarios
Priya Verma
Priya Verma el 14 de Mzo. de 2024
how to plot graphs between lags and variables for dde ?...please reply ..
Torsten
Torsten el 14 de Mzo. de 2024
What do you mean by your question ? The line
[T,SOL]=dde23(@(t,y,Z)ddefunEx(t,y,Z,p,Am,Bm), lags, [1,1,1,1], time);
gives you a solution SOL at times T that you can plot. How do you think that the lags come into play ?

Iniciar sesión para comentar.

Más respuestas (1)

Malgorzata Wieteska
Malgorzata Wieteska el 9 de Mayo de 2022
% I'm embedding simplified version of the system. I run it the function ddedunEx to get simulated data (Y) and then try to optimise for the values of the parameters against obtained earlier data.
function dydt = ddefunEx(t,y,Z,p)
%global p
ylag1 = Z(:,1);
ylag2 = Z(:,2);
time=0:7;
E1p=y(1)
E2p=y(2)
A1=y(3)
B1=y(4)
Am1=[1,1.1,1.4,0.7,0.8,1.6,2,1.5];
Bm1=[1.5,1.0,0.4,1.7,0.9,1.3,1.5,1.4];
Am=interp1(time,Am1,t)
Bm=interp1(time,Bm1,t)
n_A=p(1);%0.6;
n_B=p(2);%0.1;
KE1=p(3);%0.2;
KE2=p(4);%0.2;
Vp_A=p(5);%1.2;
Vp_B=p(6);%1.5;
alpha_p=p(7);%0.4;
kA=p(8);%0.4;
kB=p(9);%1.2;
%Auxiliary equations
ALPHA1=n_A*E1p*A1/(KE1*(1+A1))-A1;
ALPHA2=n_B*E2p*B1/(KE2*(1+B1))-B1;
dydt= [Vp_A*Am-alpha_p*ylag1(1);
Vp_B*Bm-alpha_p*ylag1(2);
kA*Am-ylag2(3)-ALPHA1+ALPHA2;
kB*Bm-ylag2(4)+ALPHA1-ALPHA2;];
end
%lags=[1,2];
%tspan=0:7;
%sol = dde23(@ddefunEx, lags, [1,1,1,1], tspan);
%figure(2)
%plot(sol.x,sol.y)
%%%%%%%%%%%%% Obtaining data
%Y=sol.y+0.05*randn(size(sol.x));
function res=Errors(p,Y)
tspan=0:7;;
x0=[4;1];
lags=[1,2];
[T,X]=dde23(@ddefunEx, lags, [1,1,1,1], tspan);
res1=(X(:,1)-Y(:,1));
res2=(X(:,2)-Y(:,2));
res3=(X(:,3)-Y(:,3));
res4=(X(:,4)-Y(:,4));
res=abs(res1)+abs(res2) +abs(res3)+abs(res4);
%pTrue=[0.6;0.1;0.2;0.2];
%[pOpt,resnorm,res,exitflag,~,lambda,J]=...
% lsqnonlin(@(p) Errors(p,Y),0.8*pTrue);
  2 comentarios
Priya Verma
Priya Verma el 14 de Mzo. de 2024
these command is not running in my matlab...please share all code..
Priya Verma
Priya Verma el 14 de Mzo. de 2024
what are define Am1 and Bm1 ?

Iniciar sesión para comentar.

Categorías

Más información sobre Stochastic Differential Equation (SDE) Models en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by