I look forward to that day, Chris. But if the user is not setting the value, you must be doing this in the code. In a SIR model doesn’t this parameter of the exponential distribution relate to the average infection length? So you explicitly allow setting the model contact rate, but not the infection rate, which could also,depend on time. Why was this decision made? What source code could I examine to develop some intuition? There is a lot I still do not understand.
This is a whole new world for me.
I found the following callback.jl function in DiffEqJump.jl .
@inline function time_to_next_jump(u,p,t,rate)
randexp()/rate(u,p,t)
#rand(Exponential(1/rate(u,p,t)))
end
ConstantRateJumpCallback(next_jump,c::ConstantRateJump,end_time) = ConstantRateJumpCallback(next_jump,end_time,c.rate,c.affect!,c.save_positions)
DiscreteCallback(c::ConstantRateJumpCallback) = DiscreteCallback(c,c,c.save_positions)
function DiscreteCallback(u,p,t,c::ConstantRateJump,end_time)
next_jump = time_to_next_jump(u,p,t,c.rate)
DiscreteCallback(ConstantRateJumpCallback(next_jump,c,end_time))
end
Looking more carefully at DiffEqJump.jl, I noticed
@inline function (p::ConstantRateJumpCallback)(integrator) # affect!
p.affect!(integrator)
p.next_jump = integrator.t + time_to_next_jump(integrator.t,integrator.u,p.rate)
if p.next_jump < p.end_time
add_tstop!(integrator,p.next_jump)
end
end
I do not understand how the call to time_to_next_jump() can only have three arguments. It definition has four with no default arguments.