Closed ChrisRackauckas closed 1 year ago
@variables t
D = Differential(t)
sts = @variables S(t) E(t) I(t) R(t) D1(t) D2(t) β(t) logβ(t)
ps = @parameters σ ρ γ λ N
@brownian α
eqs = Equation[
β ~ logβ #exp(logβ)
D(logβ) ~ sqrt(0.2) * α
D(S) ~ -β * S * I / N
E ~ N - (S + I + R + D1 + D2)
D(I) ~ σ * E - γ * I
D(R) ~ (1 - ρ) * γ * I
D(D1) ~ ρ * γ * I - λ * D1
D(D2) ~ λ * D1]
@named mecha_bayes = System(eqs, t)
mecha_bayes = structural_simplify(mecha_bayes)
dE = 0.4
dI = 2.0
Rh = 3.0
NN = 1
using Random
Random.seed!(1)
E0 = rand(Uniform(0, 0.02NN))
I0 = rand(Uniform(0, 0.02NN))
R0 = rand(Uniform(0, 0.02NN))
D10 = rand(Uniform(0, 0.02NN))
D20 = rand(Uniform(0, 0.02NN))
S0 = 1 - (E0 + I0 + R0 + D10 + D20)
u0 = [
S => S0
E => E0
I => I0
R => R0
D1 => D10
D2 => D20
β => 0.0
logβ => log(rand(Gamma(1, dI / Rh)))
]
p = [N => NN,
σ => rand(Gamma(100, 100dE)),
ρ => rand(Beta(1, 99)),
γ => rand(Gamma(100, 100dI)),
λ => rand(Gamma(10, 10*25))]
prob = SDEProblem(mecha_bayes, u0, (0.0, 10.0), p)
@test_nowarn sol = solve(prob, SRIW1(), reltol=1e-3, abstol=1e-3, seed = 1);
eqs = Equation[
β ~ 2.6
D(S) ~ -β * S * I / N
E ~ N - (S + I + R + D1 + D2)
D(I) ~ σ * E - γ * I
D(R) ~ (1 - ρ) * γ * I
D(D1) ~ ρ * γ * I - λ * D1
D(D2) ~ λ * D1]
@named mecha_bayes = System(eqs, t)
mecha_bayes = structural_simplify(mecha_bayes)
prob = ODEProblem(mecha_bayes, u0, (0.0, 1e5), p)
sol = solve(prob, Tsit5())
The ODE is needed for a test case too: