Using Callbacks to reset parameters?

I have a parameter kon that I know decreases with time - it would be easy to say:

k_on = t -> t*θ[1].
The problem is that every-time I dose my drug again the parameter should go back to it’s original value is there a way to accomplish this? Maybe via callback?



Interesting question. I actually never tried this. Let me get back to you on this after discussing internally, perhaps after the break.

Sounds great. Thank you!
Have a great break -
An example use for this is let’s say I have an antibody based drug in the blood-stream. Sometimes aminoacids get oxidized which result in decrease of antibody binding to target k_on, as the antibody spends more time in the blood it’s k_on lowers more, but when we add a new dose of antibody. The k_on should reset to the original value if all the antibody has been cleared or to a weighted average of the two populations remaining antibody + newly injected, ie:

k_on = k_on_start # not prior AB remaining
k_on = (Cremaing*k_on_remaing + Cnewdose*k_on_start)/(Cremaing + Cnewdose)

I have done some modeling like this using the differential equations suite and callbacks, but I am not a programmer by training and I am not sure how to code populations. I work one patient at a time for sims and fits before Pumas. I'll be happy to share an example of my code by e-mail if you are interested, it's messy, specially when compared to your very nice API,  but it does work well

Take care and happy holidays again :)

Send it over. Will be an interesting example to tackle. Thanks for your efforts in testing this

On the contrary!
Thanks for all your help!


Using a DiscreteCallback won’t work right now since the dosing callback will override it, but that can be handled by setting a CallbackSet over an existing callback, grabbing it from either the prototype problem or from the kwargs of simobs et. al. Could you open an issue and just periodically remind me?

I will -
Would you like it to be named using discrete callbacks and copy the example I placed here?


Yes please. If the example is a bit more complete (i.e. copy pastable) I’ll probably be able to get to it quicker as well.

Hey Chris,

As requested a quucik reminder o deal with discrete callbacks in Pumas

Sorry, this one is falling on the backburner a bit trying to finish some of the parallelism stuff first.

just a gentle new nudge to remind you about callbacks…
Also would callbacks work if I use the functional instead of the API coding of the model?

Fixed in

1 Like

Hey Chris -

That’s aweosme. I noticed that you used solve instead of simobs command to generate your Pumas solution. Is there a reason for that are you directly calling DifferentialEquations.jl solver?
If I were to perform a fit with a Discrete callback would the Pumas fit still be indicated, or would I need to use DiffEqParamEstimator?



That’s just because I was debugging and the continuous solution of a solve just makes it easier to identify all discontinuities are correctly handled. The same will work from simobs. These callbacks will directly work with Pumas’ NLME estimation functionality as well, though if you use a continuous callback there’s a detail I plan to handle next week

1 Like