Indeed, I was following that page already. But I got a totally lost with all the different options available to modify ODE problems.
Apologies, I modified the code while you were typing a reply, i hope you caught that?
I implemented it like this:
# ordered symbols
syms = [sys.lC_i, sys.lC_e, sys.lC_h, sys.lR_ie, sys.lR_ea, sys.lR_ih, sys.lA_w, sys.lA_e]
@model function LGDS(x::AbstractArray, prob, params::Dict, t_int)
# cache for remake(prob, p=newp)
lbc = GeneralLazyBufferCache(function (p)
remake_buffer(sys, prob.p, Dict(zip(syms, p)))
end)
# prior distributions
σ ~ InverseGamma(2, 3)
lC ~ MvNormal(params[:μ_C], params[:Σ_C])
lR ~ MvNormal(params[:μ_R], params[:Σ_R])
lA ~ MvNormal(params[:μ_A], params[:Σ_A])
# remake the problem with the sampled parameter values and enforce order
newp = lbc[[lC; lR; lA]]
new_prob = remake(prob, p=newp)
# solve the ODE
T_ode = solve(new_prob, Tsit5(); save_idxs=1, verbose=false)
if !(SciMLBase.successful_retcode(T_ode.retcode))
return
end
# time points corresponding to observations `x`
x_est = T_ode(time)
x ~ MvNormal(x_est.u, σ^2 * I)
return nothing
end
Is that appropriate?
I am bit skeptical of how much performance benefits it will actually yield, since each sample p
would have to be cached and I don’t know enough about HMC or the NUTS sampler implementation to say whether they would be reused at all. Is there a way to check cache usage?