Skip to content

Commit a62fdb5

Browse files
authored
Merge pull request #276 from gzagatti/queue-method-ii
`Coevolve` aggregator for `VariableRateJump`
2 parents f923fad + b0d72b5 commit a62fdb5

22 files changed

+1447
-485
lines changed

HISTORY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Breaking updates and feature summaries across releases
2+
3+
## JumpProcesses unreleased (master branch)
4+
- Support for "bounded" `VariableRateJump`s that can be used with the `Coevolve`
5+
aggregator for faster simulation of jump processes with time-dependent rates.
6+
In particular, if all `VariableRateJump`s in a pure-jump system are bounded one
7+
can use `Coevolve` with `SSAStepper` for better performance. See the
8+
documentation, particularly the first and second tutorials, for details on
9+
defining and using bounded `VariableRateJump`s.

docs/make.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using Documenter, JumpProcesses
22

3-
cp("./docs/Manifest.toml", "./docs/src/assets/Manifest.toml", force = true)
4-
cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
3+
docpath = Base.source_dir()
4+
assetpath = joinpath(docpath, "src", "assets")
5+
cp(joinpath(docpath, "Manifest.toml"), joinpath(assetpath, "Manifest.toml"), force = true)
6+
cp(joinpath(docpath, "Project.toml"), joinpath(assetpath, "Project.toml"), force = true)
57

68
include("pages.jl")
79

docs/src/api.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ reset_aggregated_jumps!
1515
ConstantRateJump
1616
MassActionJump
1717
VariableRateJump
18+
RegularJump
1819
JumpSet
1920
```
2021

2122
## Aggregators
2223
Aggregators are the underlying algorithms used for sampling
23-
[`MassActionJump`](@ref)s and [`ConstantRateJump`](@ref)s.
24+
[`ConstantRateJump`](@ref)s, [`MassActionJump`](@ref)s, and
25+
[`VariableRateJump`](@ref)s.
2426
```@docs
27+
Coevolve
2528
Direct
2629
DirectCR
2730
FRM
@@ -36,4 +39,4 @@ SortingDirect
3639
```@docs
3740
ExtendedJumpArray
3841
SSAIntegrator
39-
```
42+
```

docs/src/faq.md

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
# FAQ
22

33
## My simulation is really slow and/or using a lot of memory, what can I do?
4-
To reduce memory use, use `save_positions=(false,false)` in the `JumpProblem`
5-
constructor as described [earlier](@ref save_positions_docs) to turn off saving
6-
the system state before and after every jump. Combined with use of `saveat` in
7-
the call to `solve` this can dramatically reduce memory usage.
4+
Exact methods simulate every jump, and by default save the state before and
5+
after each jump. To reduce memory use, use `save_positions = (false, false)` in
6+
the `JumpProblem` constructor as described [earlier](@ref save_positions_docs)
7+
to turn off saving the system state before and after every jump. Combined with
8+
use of `saveat` in the call to `solve`, to specify the specific times at which
9+
to save the state, this can dramatically reduce memory usage.
810

911
While `Direct` is often fastest for systems with 10 or less `ConstantRateJump`s
10-
or `MassActionJump`s, if your system has many jumps or one jump occurs most
11-
frequently, other stochastic simulation algorithms may be faster. See [Constant
12-
Rate Jump Aggregators](@ref) and the subsequent sections there for guidance on
13-
choosing different SSAs (called aggregators in JumpProcesses).
12+
and/or `MassActionJump`s, if your system has many jumps or one jump occurs most
13+
frequently, other stochastic simulation algorithms may be faster. See [Jump
14+
Aggregators for Exact Simulation](@ref) and the subsequent sections there for
15+
guidance on choosing different SSAs (called aggregators in JumpProcesses). For
16+
systems with bounded `VariableRateJump`s using `Coevolve` with `SSAStepper`
17+
instead of an ODE/SDE time stepper can give a significant performance boost.
1418

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

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

2428
We can use `JumpSet`s to collect jumps together, and then pass them into
25-
`JumpProblem`s directly. For example, using the `MassActionJump` and
26-
`ConstantRateJump` defined earlier we can write
29+
`JumpProblem`s directly. For example, using a `MassActionJump` and
30+
`ConstantRateJump` defined in the [second tutorial](@ref ssa_tutorial), we can
31+
write
2732

2833
```julia
2934
jset = JumpSet(mass_act_jump, birth_jump)
@@ -42,8 +47,8 @@ vj1 = VariableRateJump(rate3, affect3!)
4247
vj2 = VariableRateJump(rate4, affect4!)
4348
vjtuple = (vj1, vj2)
4449

45-
jset = JumpSet(; constant_jumps=cjvec, variable_jumps=vjtuple,
46-
massaction_jumps=mass_act_jump)
50+
jset = JumpSet(; constant_jumps = cjvec, variable_jumps = vjtuple,
51+
massaction_jumps = mass_act_jump)
4752
```
4853

4954
## How can I set the random number generator used in the jump process sampling algorithms (SSAs)?
@@ -66,16 +71,19 @@ default. On versions below 1.7 it uses `Xoroshiro128Star`.
6671
## What are these aggregators and aggregations in JumpProcesses?
6772

6873
JumpProcesses provides a variety of methods for sampling the time the next
69-
`ConstantRateJump` or `MassActionJump` occurs, and which jump type happens at
70-
that time. These methods are examples of stochastic simulation algorithms
71-
(SSAs), also known as Gillespie methods, Doob's method, or Kinetic Monte Carlo
72-
methods. In the JumpProcesses terminology we call such methods "aggregators", and
73-
the cache structures that hold their basic data "aggregations". See [Constant
74-
Rate Jump Aggregators](@ref) for a list of the available SSA aggregators.
74+
`ConstantRateJump`, `MassActionJump`, or `VariableRateJump` occurs, and which
75+
jump type happens at that time. These methods are examples of stochastic
76+
simulation algorithms (SSAs), also known as Gillespie methods, Doob's method, or
77+
Kinetic Monte Carlo methods. These are all names for jump (or point) processes
78+
simulation methods used across the biology, chemistry, engineering, mathematics,
79+
and physics literature. In the JumpProcesses terminology we call such methods
80+
"aggregators", and the cache structures that hold their basic data
81+
"aggregations". See [Jump Aggregators for Exact Simulation](@ref) for a list of
82+
the available SSA aggregators.
7583

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

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

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

105-
## How do I use callbacks with `ConstantRateJump` or `MassActionJump` systems?
113+
## How do I use callbacks with jump simulations?
106114

107-
Callbacks can be used with `ConstantRateJump`s and `MassActionJump`s. When
108-
solving a pure jump system with `SSAStepper`, only discrete callbacks can be
109-
used (otherwise a different time stepper is needed). When using an ODE or SDE
110-
time stepper any callback should work.
115+
Callbacks can be used with `ConstantRateJump`s, `MassActionJump`s, and
116+
`VariableRateJump`s. When solving a pure jump system with `SSAStepper`, only
117+
discrete callbacks can be used (otherwise a different time stepper is needed).
118+
When using an ODE or SDE time stepper any callback should work.
111119

112120
*Note, when modifying `u` or `p` within a callback, you must call
113121
[`reset_aggregated_jumps!`](@ref) after making updates.* This ensures that the

docs/src/index.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# JumpProcesses.jl: Stochastic Simulation Algorithms for Jump Processes, Jump-ODEs, and Jump-Diffusions
22
JumpProcesses.jl, formerly DiffEqJump.jl, provides methods for simulating jump
3-
processes, known as stochastic simulation algorithms (SSAs), Doob's method,
4-
Gillespie methods, or Kinetic Monte Carlo methods across different fields of
5-
science. It also enables the incorporation of jump processes into hybrid
6-
jump-ODE and jump-SDE models, including jump diffusions.
3+
(or point) processes. Across different fields of science such methods are also
4+
known as stochastic simulation algorithms (SSAs), Doob's method, Gillespie
5+
methods, or Kinetic Monte Carlo methods . It also enables the incorporation of
6+
jump processes into hybrid jump-ODE and jump-SDE models, including jump
7+
diffusions.
78

89
JumpProcesses is a component package in the [SciML](https://sciml.ai/) ecosystem,
910
and one of the core solver libraries included in
@@ -78,31 +79,33 @@ versioninfo() # hide
7879
```
7980
```@example
8081
using Pkg # hide
81-
Pkg.status(;mode = PKGMODE_MANIFEST) # hide
82+
Pkg.status(; mode = PKGMODE_MANIFEST) # hide
8283
```
8384
```@raw html
8485
</details>
8586
```
8687
```@raw html
87-
You can also download the
88+
You can also download the
8889
<a href="
8990
```
9091
```@eval
9192
using TOML
92-
version = TOML.parse(read("../../Project.toml",String))["version"]
93-
name = TOML.parse(read("../../Project.toml",String))["name"]
94-
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Manifest.toml"
93+
projtoml = joinpath("..", "..", "Project.toml")
94+
version = TOML.parse(read(projtoml, String))["version"]
95+
name = TOML.parse(read(projtoml, String))["name"]
96+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version * "/assets/Manifest.toml"
9597
```
9698
```@raw html
9799
">manifest</a> file and the
98100
<a href="
99101
```
100102
```@eval
101103
using TOML
102-
version = TOML.parse(read("../../Project.toml",String))["version"]
103-
name = TOML.parse(read("../../Project.toml",String))["name"]
104-
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Project.toml"
104+
projtoml = joinpath("..", "..", "Project.toml")
105+
version = TOML.parse(read(projtoml, String))["version"]
106+
name = TOML.parse(read(projtoml, String))["name"]
107+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version * "/assets/Project.toml"
105108
```
106109
```@raw html
107110
">project</a> file.
108-
```
111+
```

docs/src/jump_solve.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,37 @@ solve(prob::JumpProblem,alg;kwargs)
66

77
## Recommended Methods
88

9-
A `JumpProblem(prob,aggregator,jumps...)` comes in two forms. The first major
10-
form is if it does not have a `RegularJump`. In this case, it can be solved with
11-
any integrator on `prob`. However, in the case of a pure `JumpProblem` (a
12-
`JumpProblem` over a `DiscreteProblem`), there are special algorithms
13-
available. The `SSAStepper()` is an efficient streamlined algorithm for running
14-
the `aggregator` version of the SSA for pure `ConstantRateJump` and/or
15-
`MassActionJump` problems. However, it is not compatible with event handling. If
16-
events are necessary, then `FunctionMap` does well.
17-
18-
If there is a `RegularJump`, then specific methods must be used. The current
19-
recommended method is `TauLeaping` if you need adaptivity, events, etc. If you
20-
just need the most barebones fixed time step leaping method, then `SimpleTauLeaping`
21-
can have performance benefits.
9+
`JumpProblem`s can be solved with two classes of methods, exact and inexact.
10+
Exact algorithms currently sample realizations of the jump processes in
11+
chronological order, executing individual jumps sequentially at randomly sampled
12+
times. In contrast, inexact (τ-leaping) methods are time-step based, executing
13+
multiple occurrences of jumps during each time-step. These methods can be much
14+
faster as they only simulate the total number of jumps over each leap interval,
15+
and thus do not need to simulate the realization of every single jump. Jumps for
16+
use with exact simulation methods can be defined as `ConstantRateJump`s,
17+
`MassActionJump`s, and/or `VariableRateJump`. Jumps for use with inexact
18+
τ-leaping methods should be defined as `RegularJump`s.
19+
20+
There are special algorithms available for efficiently simulating an exact, pure
21+
`JumpProblem` (i.e. a `JumpProblem` over a `DiscreteProblem`). `SSAStepper()`
22+
is an efficient streamlined integrator for time stepping such problems from
23+
individual jump to jump. This integrator is named after Stochastic Simulation
24+
Algorithms (SSAs), commonly used naming in chemistry and biology applications
25+
for the class of exact jump process simulation algorithms. In turn, we denote by
26+
"aggregators" the algorithms that `SSAStepper` calls to calculate the next jump
27+
time and to execute a jump (i.e. change the system state appropriately). All
28+
JumpProcesses aggregators can be used with `ConstantRateJump`s and
29+
`MassActionJump`s, with a subset of aggregators also working with bounded
30+
`VariableRateJump`s (see [the first tutorial](@ref poisson_proc_tutorial) for
31+
the definition of bounded `VariableRateJump`s). Although `SSAStepper()` is
32+
usually faster, it only supports discrete events (`DiscreteCallback`s), for pure
33+
jump problems requiring continuous events (`ContinuousCallback`s) the less
34+
performant `FunctionMap` time-stepper can be used.
35+
36+
If there is a `RegularJump`, then inexact τ-leaping methods must be used. The
37+
current recommended method is `TauLeaping` if one needs adaptivity, events, etc.
38+
If ones only needs the most barebones fixed time-step leaping method, then
39+
`SimpleTauLeaping` can have performance benefits.
2240

2341
## Special Methods for Pure Jump Problems
2442

@@ -28,9 +46,10 @@ algorithms are optimized for pure jump problems.
2846

2947
### JumpProcesses.jl
3048

31-
- `SSAStepper`: a stepping algorithm for pure `ConstantRateJump` and/or
32-
`MassActionJump` `JumpProblem`s. Supports handling of `DiscreteCallback`
33-
and saving controls like `saveat`.
49+
- `SSAStepper`: a stepping integrator for `JumpProblem`s defined over
50+
`DiscreteProblem`s involving `ConstantRateJump`s, `MassActionJump`s, and/or
51+
bounded `VariableRateJump`s . Supports handling of `DiscreteCallback`s and
52+
saving controls like `saveat`.
3453

3554
## RegularJump Compatible Methods
3655

0 commit comments

Comments
 (0)