Open Vilin97 opened 3 years ago
Additional features to plan for:
ConstantRateJump
s? Assume they take a site index too as input?Optimizations to try after benchmarking:
@inbounds
throughout.Some more stuff:
I am starting to think about SpatialConstantRateJump
, analogous to SpatialMassActionJump
. We need rate
and affect!
from each user. I have some questions:
affect!
be allowed to affect other cells? Or only the cell where the reaction happened. I guess there is no real way to stop the user from passing a function that modifies other cells, because affect!
takes an integrator as input, and I don't think we should change that interface.rate
take the full state vector as input or only the state at the current cell? I am thinking the latter. In that case the function signature is the same rate(u,p,t)
, where u
is the vector of species in the current cell. If we go with the former, than the signature would be rate(u,p,t,i)
, where u
is now the species-site matrix, and i
is the site index.@isaacsas , what do you think?
We need to provide the location or there would be no way to have a rate that is spatially varying. For example, zero at some sites and non zero at others.
This summer I am working on implementing spatial SSAs. There are currently two issues open about it: https://github.com/SciML/DiffEqJump.jl/issues/107 and https://github.com/SciML/DiffEqJump.jl/issues/130. The first PR https://github.com/SciML/DiffEqJump.jl/pull/183 implements the NSM, adds two tests and some utility functions, essentially setting up the interface for spatial SSAs.
LightGraphs
are supported as well. There are a few TODOs that should not be forgotten:CartesianGrid
struct needs to be optimized -- probably by storing the number of neighbors for each site sonum_neighbors
is O(1) and makingneighbors
return an iterator instead of allocating an array.CartesianGrid
useCartesianIndices
instead of doing all the calculations redundantly.nsm.jl
.CartesianGrid
needs to be supported. This can be done with a special sink site: it neighbors all boundary sites and does not get updated if it is the target site of a hop. This change will require tweaking the code innsm.jl
.nsm.jl
.HopRatesGeneral
: switch to using cumulative sums to sample neighbor.DirectCRRSSA
). Can also do it for non-spatial solvers.DiffEqJump
stack up.CartesianGrid
. It should be faster than aGraph
.Dsi
. The quantityhop_rates.hopping_constants[species,site]*outdegree(spatial_system, site)
is always the same for any given site. If we precompute this quantity we won't need to store the number of neighbors for each site in the CartesianGrid struct resulting in less memory used. And we would also avoid one multiplication and one pointer access for each update of hopping rates. [EDIT]: maybe store the outdegrees as a dict, where all the interior sites do not appear. This would make the nums_neighbors array O(n^2) instead of O(n^3) where n is linear dimension of the grid.@isaacsas and @ChrisRackauckas might have more TODOs to add to this list.