I have been trying to estimate the parameters of the model included in the code below. When I run the code below, it solves for random parameters it generates. However, sometimes I get this: ERROR: DomainError with -0.11794106990249296: Exponentiation yielding a complex result requires a complex argument. Replace x^y with (x+0im)^y, Complex(x)^y, or similar.
From what I understand G_b/G̃
might yield a negative number during integration, the problem might be caused by that. On the other hand, optimization run is interrupted by this error while trying to estimate the parameters. How can I avoid this error while trying to estimate the parameters?
function simo(du,u,p,t)
S, J, R, L, G, I, G_prod = u
k_js, k_gj, k_rj, k_lr, k_gl,
k_xg, k_xgi, η, I_b, G_b, f_gi, β, γ, k_xi, k_λ = p
du[1] = dS = -k_js*S
du[2] = dJ = k_js*S - k_gj*J - k_rj*J
du[3] = dR = -k_lr*R + k_rj*J
du[4] = dL = k_lr*R - k_gl*L
G0_prod = (k_xg + k_xgi*I_b)*G_b
G_prod = k_λ/((k_λ/G0_prod) + (G - G_b))
du[5] = dG = -k_xg*G - k_xgi*I*G + G_prod + η*(k_gj*J + k_gl*L)
G̃ = G + f_gi*(k_gj*J + k_gl*L)
ins_rhs = (β.^γ + 1)/((β.^γ)*((G_b/G̃).^γ) + 1) - I/I_b
du[6] = dI = k_xi*I_b*ins_rhs
end
time_points = [0.0,30.0,60.0,90.0,120.0]
tspan = (0.0,120.0)
u0 = [
416.31;
0.;
0.;
0.;
G0;
I0;
0.01;
]
p0 = rand(15)
p0[9] = I0
p0[10] = G0
prob = ODEProblem(simo, u0, tspan, p0)
sol = solve(prob,Tsit5(),saveat=time_points)
plot(sol)