JumpProcesses.jl icon indicating copy to clipboard operation
JumpProcesses.jl copied to clipboard

rate function interface

Open isaacsas opened this issue 1 year ago • 4 comments

Is there a reason that rate functions for jumps don't take integrators? One disadvantage of this design is that one can't use the new symbolic indexing options in them.

isaacsas avatar Apr 12 '23 19:04 isaacsas

They do take integrators, but the issue is that it needs to be interpolated to the right point.

ChrisRackauckas avatar Apr 13 '23 07:04 ChrisRackauckas

Ahh yes, I always mix it up with the jump rate definition. I guess I was actually thinking of the latter (which is of the form rate(u,p,t), i.e. doesn't take the integrator).

isaacsas avatar Apr 13 '23 11:04 isaacsas

@ChrisRackauckas what do you think about using SciMLBase.numargs to add support for single argument rate(integrator) functions? (Basically, we create a wrapper if passed a rate(u,p,t) function which forwards the appropriate integrator fields, letting us standardize on rate(integrator) as the real interface.)

My thought is this would ensure rate, condition, and affect functions across callbacks and jumps all have access to integrators. Users would then always have access to the symbolic indexing.

We could also then unify that rngs are stored in integrators across SciML, which fixes the issue that we store them in the JumpAggregations here, and means users would be able to use the internal rng we are using in their callback/jump functions. (It also avoids having to break/modify the definition of rate and affect functions to support an explicit rng argument.) Of course, it would then require adding this field across to most ODE/SDE integrators, which I guess could be a lot of work?

isaacsas avatar Apr 19 '23 16:04 isaacsas

Ahh, I see that this won't work for variable rates since they have to support being called without integrators via the ODE derivative interface:

https://github.com/SciML/JumpProcesses.jl/blob/fd47a8212711c85687e93b8bc9e90e82fb134d36/src/problem.jl#L272

That's unfortunate as this seemed like a clean way to pass around rngs too.

isaacsas avatar Apr 19 '23 16:04 isaacsas