Closed gzagatti closed 1 year ago
I don't think you can, because the state has to be continuous in order to have a continuous integration for the jump time. ConstantRateJump is able to do this because by the constant rate you don't need an integration process in order to choose the jump times, but for variable rate you do, and for type-stability in the definition, if it's all contained in a single state array then it needs to be floating point valued. In theory, we could maybe make a split state form, though that would increase a lot of the type information and improve a lot of extra constraints on its usage (such as not being able to use a continuous rate dependent on the state values) and thus it wasn't done because it would be a lot of work for little gain.
I agree with you. In this case, I would just fix this issue by maintaining the ExtendedJumpArray
type when converting to Float
. Would that make sense?
Oh it doesn't? Yeah that's an issue. That means that the broadcast similar needs an overload: i.e. broadcast in general is returning an Array
, so that should get fixed.
It doesn’t. That’s why I opened the issue. But I think I overcomplicated my initial explanation. Apologies for that.
https://docs.julialang.org/en/v1/manual/interfaces/#man-interfaces-broadcasting
Specifically this section:
https://docs.julialang.org/en/v1/manual/interfaces/#Selecting-an-appropriate-output-array
That must be missing from the definition of the broadcast in JumpProcesses. I'm transferring it over to JumpProcesses.jl as this is pretty contained to there.
@gzagatti seems closed by https://github.com/SciML/JumpProcesses.jl/pull/340.
Awesome! Thanks @meson800!
JumpProcess.jl does some tricks to handle
VariableJumps
. However, I might have found a small bug in the current implementation.Let's say we have the following model taken from the tutorial:
This works perfectly. However, if we modify
u0
from aFloat64
to anInt
arrayu0 = [0, 0]
. Thensolve
raises an exception which basically complains that there is no method matching(::JumpProcess)(::Vector{Float64}, ::Vector{Float64}, ...)
since it is looking for a method matching(::JumpProcess)(::ExtendedJumpArray, ::ExtendedJumpArray, ...)
. This makes total sense since JumpProcess.jl remakesoprob
to use anExtendedJumpArray
.So what's going on? After some digging around the source code, it turns out that the culprit is located in this line of
DiffEqBase.jl/src/solve.jl
.When dealing with jump processes, it is common to be interested in modelling counts so having
u₀
as an array of integers is a reasonable choice.It's probably the case that you only want to convert the extended part of the array to float. However, I'm not sure if that's possible.
In any case, you should preserve
u0
as anExtendedJumpArray
that it works even after conversion.