Skip to content
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
280b64b
adds working QueueMethod aggregator and ConditionalRateJump.
gzagatti Oct 25, 2022
f39abef
Incorporates conditional history to QueueMethod.
gzagatti Oct 26, 2022
724acb3
remove debugging comments.
gzagatti Oct 26, 2022
28cb924
adds marked jump to QueueMethod.
gzagatti Oct 26, 2022
e27a90b
save history.
gzagatti Oct 27, 2022
ed9c118
reorders exports.
gzagatti Oct 28, 2022
7afd21b
use VariableRateJump instead and tweaks to next_time algorithm.
gzagatti Oct 31, 2022
94dd52e
improve initialization performance by removing FunctionWrapper.
gzagatti Oct 31, 2022
dc9376d
fix bugs.
gzagatti Oct 31, 2022
fa5c0ad
needs jumptovars_map and vartojumps_map.
gzagatti Nov 1, 2022
de6f6a2
remove mark and history from the aggregator.
gzagatti Nov 1, 2022
a56eff4
adds utilities for dealing with history.
gzagatti Nov 2, 2022
2683f85
fix bugs.
gzagatti Nov 2, 2022
c6249d9
adds option for indices when computing conditional rate.
gzagatti Nov 2, 2022
ccbfee5
use Vector instead of Tuple in JumpSet.
gzagatti Nov 2, 2022
98b06fd
adds docstring to function.
gzagatti Nov 2, 2022
2108278
modifies QueueMethod requirement.
gzagatti Nov 2, 2022
ba74592
improve performance and simplify QueueMethod.
gzagatti Nov 4, 2022
6f19944
fix bugs.
gzagatti Nov 4, 2022
42568f9
adds support for MA jumps; pass all unit tests.
gzagatti Nov 25, 2022
c91b021
improves aggregator speed by using FunctionWrappers and avoid allocat…
gzagatti Nov 28, 2022
db541d9
use heap instead of priority queue for improved performance.
gzagatti Nov 28, 2022
7c973b7
fix API.
gzagatti Nov 29, 2022
9cb3770
leave from next_time loop as soon as possible.
gzagatti Nov 30, 2022
837292a
Merge remote-tracking branch 'origin/master' into queue-method-ii
gzagatti Nov 30, 2022
a9484a1
fix QueueMethod requirement.
gzagatti Dec 1, 2022
e0ba083
remove logic for pausing next time as premature optimization.
gzagatti Dec 1, 2022
a18e04f
fix zero rate.
gzagatti Dec 1, 2022
08366d9
move utilities out of the module.
gzagatti Dec 5, 2022
2b1cdd8
adds documentation for VariableRateJump.
gzagatti Dec 7, 2022
d6ac52d
fix if statement.
gzagatti Dec 7, 2022
ceb293b
adds test for VariableRateJump.
gzagatti Dec 7, 2022
c7a832c
linting.
gzagatti Dec 7, 2022
7574367
fix documentation.
gzagatti Dec 7, 2022
efdb3a3
adds source to documentation.
gzagatti Dec 7, 2022
82aff42
fix problem initialization.
gzagatti Dec 7, 2022
bd67a7f
renames QueueMethod to Coevolve; fix documentation references.
gzagatti Dec 8, 2022
6cb6881
linting and file rename.
gzagatti Dec 8, 2022
77b4cb2
adds default for lrate; fix VariableRateJump API.
gzagatti Dec 11, 2022
41b8f2a
ensure correct type inference.
gzagatti Dec 11, 2022
f0dc9a7
removes unncessary update_state! from Coevolve.
gzagatti Dec 11, 2022
a8cf1c6
corrects eltype to typeof.
gzagatti Dec 11, 2022
c1b7589
inlines get_rate in Coevolve.
gzagatti Dec 11, 2022
138b07f
adds Coevolve to more tests.
gzagatti Dec 11, 2022
b87e00e
fix update_state! call.
gzagatti Dec 11, 2022
27707e6
adds supports_variablerates trait.
gzagatti Dec 11, 2022
0b59e52
re-use random number.
gzagatti Dec 12, 2022
a4abd47
revert JumpSet changes.
gzagatti Dec 12, 2022
54ed717
avoid creating anonymous function when not needed.
gzagatti Dec 12, 2022
0ca1493
remove the VariableRateJump initializer from a ConstantRateJump.
gzagatti Dec 12, 2022
4d89b5d
fix comments.
gzagatti Dec 12, 2022
f51fc44
treat all jump types differently in Coevolve.
gzagatti Dec 12, 2022
c55691c
fix local doc builds and add some tutorial updates
isaacsas Dec 14, 2022
bf6771a
fix error message.
gzagatti Dec 14, 2022
d3ce32b
Merge remote-tracking branch 'origin/master' into queue-method-ii
gzagatti Dec 14, 2022
f513ec9
Merge remote-tracking branch 'github-desktop-gzagatti/queue-method-ii…
isaacsas Dec 14, 2022
ca46720
change L to rateinterval
isaacsas Dec 14, 2022
e271864
L -> rateinterval
isaacsas Dec 14, 2022
8c393e2
add global nullrate function
isaacsas Dec 14, 2022
a6f8889
format
isaacsas Dec 14, 2022
b0259a0
more doc updates
isaacsas Dec 22, 2022
199564f
fix typos
isaacsas Dec 22, 2022
5dda9b8
more doc updates
isaacsas Dec 28, 2022
e75c34f
finish tutorial updates
isaacsas Dec 28, 2022
6ceef8d
tutorial bug fix
isaacsas Dec 29, 2022
bba4aaf
doc tweaks
isaacsas Dec 29, 2022
72ac0a1
simplify coevolve
isaacsas Dec 30, 2022
cd7ddf5
add inbounds
isaacsas Dec 30, 2022
176ca81
make lrate optional
isaacsas Dec 31, 2022
cf0f050
fix initialization bug
isaacsas Dec 31, 2022
d5cacb3
rework JumpProblem
isaacsas Jan 1, 2023
9b41d17
format
isaacsas Jan 1, 2023
1103cd0
add tests
isaacsas Jan 2, 2023
e4556d7
Update docs/src/jump_types.md
isaacsas Jan 3, 2023
b0d72b5
Apply suggestions from code review
isaacsas Jan 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Documenter, JumpProcesses

cp("./docs/Manifest.toml", "./docs/src/assets/Manifest.toml", force = true)
cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
docpath = Base.source_dir()
assetpath = joinpath(docpath, "src", "assets")
cp(joinpath(docpath, "Manifest.toml"), joinpath(assetpath, "Manifest.toml"), force = true)
cp(joinpath(docpath, "Project.toml"), joinpath(assetpath, "Project.toml"), force = true)

include("pages.jl")

Expand Down
8 changes: 5 additions & 3 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ reset_aggregated_jumps!
## Types of Jumps
```@docs
ConstantRateJump
MassActionJump
VariableRateJump
MassActionJump
JumpSet
```

## Aggregators
Aggregators are the underlying algorithms used for sampling
[`MassActionJump`](@ref)s and [`ConstantRateJump`](@ref)s.
[`MassActionJump`](@ref)s, [`ConstantRateJump`](@ref)s and
[`VariableRateJump`](@ref)s.
```@docs
Direct
DirectCR
Expand All @@ -30,10 +31,11 @@ RDirect
RSSA
RSSACR
SortingDirect
Coevolve
```

# Private API Functions
```@docs
ExtendedJumpArray
SSAIntegrator
```
```
56 changes: 31 additions & 25 deletions docs/src/faq.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# FAQ

## My simulation is really slow and/or using a lot of memory, what can I do?
To reduce memory use, use `save_positions=(false,false)` in the `JumpProblem`
constructor as described [earlier](@ref save_positions_docs) to turn off saving
the system state before and after every jump. Combined with use of `saveat` in
the call to `solve` this can dramatically reduce memory usage.

While `Direct` is often fastest for systems with 10 or less `ConstantRateJump`s
or `MassActionJump`s, if your system has many jumps or one jump occurs most
frequently, other stochastic simulation algorithms may be faster. See [Constant
Rate Jump Aggregators](@ref) and the subsequent sections there for guidance on
choosing different SSAs (called aggregators in JumpProcesses).
Exact methods simulate each and every jump. To reduce memory use, use
`save_positions=(false,false)` in the `JumpProblem` constructor as described
[earlier](@ref save_positions_docs) to turn off saving the system state before
and after every jump. You often do not need to save all jump poisitons when you
only want to track cumulative counts. Combined with use of `saveat` in the call
to `solve` this can dramatically reduce memory usage.

While `Direct` is often fastest for systems with 10 or less `ConstantRateJump`s,
`VariableRateJump`s, and/or or `MassActionJump`s, if your system has many jumps
or one jump occurs most frequently, other stochastic simulation algorithms may
be faster. See [Jump Aggregators for Exact Simulation](@ref) and the subsequent
sections there for guidance on choosing different SSAs (called aggregators in
JumpProcesses).

## When running many consecutive simulations, for example within an `EnsembleProblem` or loop, how can I update `JumpProblem`s?

Expand All @@ -22,8 +25,8 @@ internal aggregators for each new parameter value or initial condition.
## How can I define collections of many different jumps and pass them to `JumpProblem`?

We can use `JumpSet`s to collect jumps together, and then pass them into
`JumpProblem`s directly. For example, using the `MassActionJump` and
`ConstantRateJump` defined earlier we can write
`JumpProblem`s directly. For example, using the `ConstantRateJump`,
`VariableRateJump` and `MassActionJump` defined earlier we can write

```julia
jset = JumpSet(mass_act_jump, birth_jump)
Expand Down Expand Up @@ -66,16 +69,19 @@ default. On versions below 1.7 it uses `Xoroshiro128Star`.
## What are these aggregators and aggregations in JumpProcesses?

JumpProcesses provides a variety of methods for sampling the time the next
`ConstantRateJump` or `MassActionJump` occurs, and which jump type happens at
that time. These methods are examples of stochastic simulation algorithms
(SSAs), also known as Gillespie methods, Doob's method, or Kinetic Monte Carlo
methods. In the JumpProcesses terminology we call such methods "aggregators", and
the cache structures that hold their basic data "aggregations". See [Constant
Rate Jump Aggregators](@ref) for a list of the available SSA aggregators.
`ConstantRateJump`, `VariableRateJump` or `MassActionJump` occurs, and which
jump type happens at that time. These methods are examples of stochastic
simulation algorithms (SSAs), also known as Gillespie methods, Doob's method, or
Kinetic Monte Carlo methods. These are catch-all terms for jump (or point)
processes simulation methods most commonly used in the biochemistry literature.
In the JumpProcesses terminology we call such methods "aggregators", and the
cache structures that hold their basic data "aggregations". See [Jump
Aggregators for Exact Simulation](@ref) for a list of the available SSA
aggregators.

## How should jumps be ordered in dependency graphs?
Internally, JumpProcesses SSAs (aggregators) order all `MassActionJump`s first,
then all `ConstantRateJumps`. i.e. in the example
then all `ConstantRateJumps` and/or `VariableRateJumps`. i.e. in the example

```julia
using JumpProcesses
Expand All @@ -99,15 +105,15 @@ The four jumps would be ordered by the first jump in `maj`, the second jump in
`maj`, `cj1`, and finally `cj2`. Any user-generated dependency graphs should
then follow this ordering when assigning an integer id to each jump.

See also [Constant Rate Jump Aggregators Requiring Dependency Graphs](@ref) for
See also [Jump Aggregators Requiring Dependency Graphs](@ref) for
more on dependency graphs needed for the various SSAs.

## How do I use callbacks with `ConstantRateJump` or `MassActionJump` systems?
## How do I use callbacks with `ConstantRateJump`, `VariableRateJump` or `MassActionJump` systems?

Callbacks can be used with `ConstantRateJump`s and `MassActionJump`s. When
solving a pure jump system with `SSAStepper`, only discrete callbacks can be
used (otherwise a different time stepper is needed). When using an ODE or SDE
time stepper any callback should work.
Callbacks can be used with `ConstantRateJump`s, `VariableRateJump`s and
`MassActionJump`s. When solving a pure jump system with `SSAStepper`, only
discrete callbacks can be used (otherwise a different time stepper is needed).
When using an ODE or SDE time stepper any callback should work.

*Note, when modifying `u` or `p` within a callback, you must call
[`reset_aggregated_jumps!`](@ref) after making updates.* This ensures that the
Expand Down
29 changes: 16 additions & 13 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# JumpProcesses.jl: Stochastic Simulation Algorithms for Jump Processes, Jump-ODEs, and Jump-Diffusions
JumpProcesses.jl, formerly DiffEqJump.jl, provides methods for simulating jump
processes, known as stochastic simulation algorithms (SSAs), Doob's method,
Gillespie methods, or Kinetic Monte Carlo methods across different fields of
science. It also enables the incorporation of jump processes into hybrid
jump-ODE and jump-SDE models, including jump diffusions.
(or point) processes. Across different fields of science such methods are also
known as stochastic simulation algorithms (SSAs), Doob's method, Gillespie
methods, or Kinetic Monte Carlo methods . It also enables the incorporation of
jump processes into hybrid jump-ODE and jump-SDE models, including jump
diffusions.

JumpProcesses is a component package in the [SciML](https://sciml.ai/) ecosystem,
and one of the core solver libraries included in
Expand Down Expand Up @@ -78,31 +79,33 @@ versioninfo() # hide
```
```@example
using Pkg # hide
Pkg.status(;mode = PKGMODE_MANIFEST) # hide
Pkg.status(; mode = PKGMODE_MANIFEST) # hide
```
```@raw html
</details>
```
```@raw html
You can also download the
You can also download the
<a href="
```
```@eval
using TOML
version = TOML.parse(read("../../Project.toml",String))["version"]
name = TOML.parse(read("../../Project.toml",String))["name"]
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Manifest.toml"
projtoml = joinpath("..", "..", "Project.toml")
version = TOML.parse(read(projtoml, String))["version"]
name = TOML.parse(read(projtoml, String))["name"]
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version * "/assets/Manifest.toml"
```
```@raw html
">manifest</a> file and the
<a href="
```
```@eval
using TOML
version = TOML.parse(read("../../Project.toml",String))["version"]
name = TOML.parse(read("../../Project.toml",String))["name"]
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Project.toml"
projtoml = joinpath("..", "..", "Project.toml")
version = TOML.parse(read(projtoml, String))["version"]
name = TOML.parse(read(projtoml, String))["name"]
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version * "/assets/Project.toml"
```
```@raw html
">project</a> file.
```
```
43 changes: 28 additions & 15 deletions docs/src/jump_solve.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,32 @@ solve(prob::JumpProblem,alg;kwargs)

## Recommended Methods

A `JumpProblem(prob,aggregator,jumps...)` comes in two forms. The first major
form is if it does not have a `RegularJump`. In this case, it can be solved with
any integrator on `prob`. However, in the case of a pure `JumpProblem` (a
`JumpProblem` over a `DiscreteProblem`), there are special algorithms
available. The `SSAStepper()` is an efficient streamlined algorithm for running
the `aggregator` version of the SSA for pure `ConstantRateJump` and/or
`MassActionJump` problems. However, it is not compatible with event handling. If
events are necessary, then `FunctionMap` does well.

If there is a `RegularJump`, then specific methods must be used. The current
Because `JumpProblem`s can be solved with two classes of methods, exact and
inexact, they come in two forms. Exact algorithms tend to describe the
realization of each jump chronologically. Alternatively, inexact methods tend to
take small leaps through time so they are guaranteed to terminate in finite
time. These methods can be much faster as they only simulate the total number of
points in each leap interval and thus do not need to simulate the realization of
every single jump. Jumps for exact methods can be defined with
`ConstantRateJump`, `VariableRateJump` and/or `MassActionJump` On the other
hand, jumps for inexact methods are defined with `RegularJump`.

There are special algorithms available for a pure exact `JumpProblem` (a
`JumpProblem` over a `DiscreteProblem`). The `SSAStepper()` is an efficient
streamlined integrator for running simulation algorithms of such problems. This
integrator is named after the term Stochastic Simulation Algorithm (SSA) which
is a catch-all term in biochemistry to denote algorithms for simulating jump
processes. In turn, we denote aggregators algorithms for simulating jump
processes that can use the `SSAStepper()` integrator. These algorithms can solve
problems initialized with `ConstantRateJump`, `VariableRateJump` and/or
`MassActionJump`. Although `SSAStepper()` is usually faster, it is not
compatible with event handling. If events are necessary, then `FunctionMap` does
well.

If there is a `RegularJump`, then inexact methods must be used. The current
recommended method is `TauLeaping` if you need adaptivity, events, etc. If you
just need the most barebones fixed time step leaping method, then `SimpleTauLeaping`
can have performance benefits.
just need the most barebones fixed time step leaping method, then
`SimpleTauLeaping` can have performance benefits.

## Special Methods for Pure Jump Problems

Expand All @@ -28,9 +41,9 @@ algorithms are optimized for pure jump problems.

### JumpProcesses.jl

- `SSAStepper`: a stepping algorithm for pure `ConstantRateJump` and/or
`MassActionJump` `JumpProblem`s. Supports handling of `DiscreteCallback`
and saving controls like `saveat`.
- `SSAStepper`: a stepping integrator for pure `ConstantRateJump`,
`VariableRateJump` and/or `MassActionJump` `JumpProblem`s. Supports handling
of `DiscreteCallback` and saving controls like `saveat`.

## RegularJump Compatible Methods

Expand Down
Loading