ODE solver in PBPK model takes too much time

Hi!

Linas is referring to a technique wrt to the analytic Jacobians which is rather advanced and requires you to write C++ code… not quite for starters.

A few comments:

  • You tolerances are way too large! Such imprecise ODE solutions lead to a collapse of the numerical precision. In popPK problems I found that a relative tolerance of 1E-9 (or 1E-7 is also OK depending on the case) and an absolute tolerance of 1E-5 tend to work good for the problems I have come across. The odd thing is when you go to less precision of the ODE, then you render NUTS essentially blind and then NUTS will decrease the stepsize virtually to 0.

  • These large systems can easily get stiff, so try out the bdf integrator.

  • You only pass into the ODE integrator a single parameter via the theta argument - this is the way to do it! That is, avoid anything unnecessary to pass into the integrate functions via the theta argument, rather use the x_r for everything which is data only.

  • You can vectorize your likelihood easily with con4 ~ lognormal(log(con_hat[:,13]), epsilon).

  • If you can, then do decrease your ODE system as much as possible.

I hope this helps you get on track. However, I have to say that so many ODE equations are extremely difficult to handle, no matter what you do.

Sebastian

2 Likes