SciML / DiffEqCallbacks.jl

A library of useful callbacks for hybrid scientific machine learning (SciML) with augmented differential equation solvers
https://docs.sciml.ai/DiffEqCallbacks/stable/
Other
85 stars 44 forks source link

Allow tstops in PresetTimeCallback to depend on model parameters #178

Open sebapersson opened 8 months ago

sebapersson commented 8 months ago

Is your feature request related to a problem? Please describe.

Sometimes when parameter estimating ODE-models, or when importing a model in the SBML format, event time-points are dependent on model parameters. As I understood PresetTimeCallback accepts a vector of event-times, so it cannot be used (without rebuilding the callback for each parameter vector) when event-times are model parameter dependent.

Describe the solution you’d like

I would like PresetTimeCallback to also accept a function like:

function get_tstops(integrator) ... end

And that a preset callback then can be created with

PresetTimeCallback(get_tstops, user_affect!; ...)

Describe alternatives you’ve considered

Currently in PEtab.jl and SBMLImporter if we have events we provide a function for computing tstops:

sys, specie_map, parameter_map, cb, get_tstops = SBML_to_ODESystem(path_SBML)

It works, but the interface would be cleaner and more easy to use if we did not have to return the get_tstops function.

ChrisRackauckas commented 7 months ago

Yeah this could be added to the interface.