# Can we find a DDe's canstant from a table  for finding a,b,c the most compatible with the model

Is this for a class? We cannot help you with homework questions on this forum.

nope i just wanna use julia but i don’t know how

Okay.

‘’'julia
using DifferentialEquations
using Pkg
#using Plots

using Plots
function f(du, u, h, p, t)

``````a, b,c, τ = p
⌛ = h(p, t - τ, idxs = 1)
du = u * (1 - u - (a * ⌛ + b)*exp(-c*⌛))
``````

end

u0 = [0.008]
τ = 7
h(p, t; idxs = 1) = 0.008
a = 0.517;
b = 0.988;
c=0.173;
p = [a, b,c,τ]
tspan = (8.0, 23.0)

prob = DDEProblem(f, u0, h, tspan, p, canstant_lag = [τ])
sol = solve(prob,saveat=1)
temps=[8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]
verus=[5.011,0.199,0.01,0.0063,1.0056,0.008,0.0056,0.003,0.005,0.01,0.016,0.02,0.039,0.015,0.0001,0.0001]
L=[temps,verus]
scatter!(temps,verus)
vir=Array(L)
temp_prob=remake(prob,p=[10,5,40,6])
temp_sol=solve(temp_prob,saveat=1)

using DiffEqFlux,Optim
function loss(p)
temp_prob=remake(prob,p=p)
temp_sol=solve(temp_prob,saveat=1)
c=sum(abs2,Array(temp_sol)-vir)

end

loss([1,2,4,5])
pinit=[1,2,3,4]
res=DiffEqFlux.sciml_train(loss,pinit,BFGS())
‘’’

I wanna transform vir to the same dimension of temp_sol

Post quoted code by enclosing code blocks in triple-backticks :

`````````julia
function f(x, y)
x + y
end
```
``````

This will highlight syntax and use a monospace font.

Just transpose it and set `saveat` to the right time points? (saveat = 16:23 if I’m not mistaken?)

1 Like