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

[v14 ready] RDME and graph SSAs

Open TorkelE opened this issue 1 year ago • 6 comments

To avoid rebasing hell this is simply a new version of https://github.com/SciML/Catalyst.jl/pull/663. You might have some input on simpler ways to compute the (non-spatial) mass action Jumps @isaacsas, but otherwise, this is good to go. Currently vertex parameters must be uniform across the grid (and this is enforced). Once @Vilin97 have his PRs merged over at JumpProcesses, this requirement can be lightened.

I have added support for spatial jumps. Creating and solving a problem is relatively easy:

using Catalyst, Graphs, JumpProcesses

# Make model.
SIR_system = @reaction_network begin
    α, S + I --> 2I
    β, I --> R
end
trS = @transport_reaction dS S
trI = @transport_reaction dI I
lattice = Graphs.grid([2, 2])
lrs = LatticeReactionSystem(SIR_system, [trS, trI], lattice)

# Parameter values and initial conditions.
u0 = [:S => [999, 1000, 1000, 1000], :I => [1, 0, 0, 0], :R => 0]
pV = [:α => 0.1 / 1000, :β => 0.01]
pE = [:dS => [0.1, 0.1, 0.1, 0.2], :dI => [0.01, 0.01, 0.01, 0.02]]

# Create the problem.
dprob = DiscreteProblem(lrs, u0, (0.0,100.0), (pV,pE))
jprob = JumpProblem(lrs, dprob, NSM())
sol = solve(jprob, SSAStepper())

Current limitations:

  • Cartesian grids are not supported, only Graphs.
  • Of the 5 forms of the hopping rates, we now convert to the most general one (D_{s,i,j}). Once this is merged, I will introduce a routine which detects which is the most compact form that can be provided, and uses that one. To keep this PR short, I am currently holding of on uploading those changes,
  • Currently, the constant rate jumps in each compartment must have the same parameter values. Once this is supported in JumpProcesses I will add support for it here as well.

TorkelE avatar Dec 02 '23 17:12 TorkelE

This one shoudl also have better formatting and comments as compared to the previous PR.

TorkelE avatar Dec 02 '23 18:12 TorkelE

I thought spatially varying mass action jump rates are already supported? That is what a SpatialMassActionJump encodes.

isaacsas avatar Dec 02 '23 19:12 isaacsas

I thought spatially varying mass action jump rates are already supported? That is what a SpatialMassActionJump encodes.

Ahh, didn't know that that was supported already.

TorkelE avatar Dec 02 '23 19:12 TorkelE

I have renamed the "Correctness Tests" header. Good point of the coverage, the file wasn't being run but added now, thanks!

TorkelE avatar Dec 30 '23 10:12 TorkelE

Won’t that run CI on the branch for all PRs and merges forever now?

isaacsas avatar Jan 26 '24 19:01 isaacsas

It will until we remove it, which we will do with the v14 release. And all PRs until then will be for the v14 branch anyway.

This is what we want right, and it is not like there is another way?

TorkelE avatar Jan 26 '24 23:01 TorkelE