# JumpProcesses.jl
[![Join the chat at https://julialang.zulipchat.com #sciml-bridged](https://img.shields.io/static/v1?label=Zulip&message=chat&color=9558b2&labelColor=389826)](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
[![Stable Release Docs](https://img.shields.io/badge/Stable%20Release%20Docs-SciML-blue)](https://docs.sciml.ai/JumpProcesses/stable/)
[![Master Branch Docs](https://img.shields.io/badge/Master%20Branch%20Docs-SciML-blue)](https://docs.sciml.ai/JumpProcesses/dev/)
[![Coverage Status](https://coveralls.io/repos/github/SciML/JumpProcesses.jl/badge.svg?branch=master)](https://coveralls.io/github/SciML/JumpProcesses.jl?branch=master)
[![codecov](https://codecov.io/gh/SciML/JumpProcesses.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/SciML/JumpProcesses.jl)
[![Build Status](https://github.com/SciML/JumpProcesses.jl/workflows/CI/badge.svg)](https://github.com/SciML/JumpProcesses.jl/actions?query=workflow%3ACI)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)
*Note, JumpProcesses.jl is a renaming of DiffEqJump.jl, providing the current version of the latter.*
JumpProcesses.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.
JumpProcesses is a component package in the [SciML](https://sciml.ai/) ecosystem,
and one of the core solver libraries included in
[DifferentialEquations.jl](https://github.com/JuliaDiffEq/DifferentialEquations.jl).
For information on using the package,
[see the stable documentation](https://docs.sciml.ai/JumpProcesses/stable/). Use the
[in-development documentation](https://docs.sciml.ai/JumpProcesses/dev/) for the version of
the documentation which contains unreleased features.
The documentation includes
- [a tutorial on simulating basic Poisson processes](https://docs.sciml.ai/JumpProcesses/stable/tutorials/simple_poisson_process/)
- [a tutorial and details on using JumpProcesses to simulate jump processes via SSAs (i.e. Gillespie methods)](https://docs.sciml.ai/JumpProcesses/stable/tutorials/discrete_stochastic_example/),
- [a tutorial on simulating jump-diffusion processes](https://docs.sciml.ai/JumpProcesses/stable/tutorials/jump_diffusion/),
- [a reference on the types of jumps and available simulation methods](https://docs.sciml.ai/JumpProcesses/stable/jump_types/),
- [a reference on jump time stepping methods](https://docs.sciml.ai/JumpProcesses/stable/jump_solve/),
- [a FAQ](https://docs.sciml.ai/JumpProcesses/stable/faq) with information on changing parameters between simulations and using callbacks,
- [the JumpProcesses.jl API documentation](https://docs.sciml.ai/JumpProcesses/stable/api/).
## Installation
There are two ways to install `JumpProcesses.jl`. First, users may install the meta
`DifferentialEquations.jl` package, which installs and wraps `OrdinaryDiffEq.jl`
for solving ODEs, `StochasticDiffEq.jl` for solving SDEs, and `JumpProcesses.jl`,
along with a number of other useful packages for solving models involving ODEs,
SDEs and/or jump process. This single install will provide the user with all of
the facilities for developing and solving Jump problems.
To install the `DifferentialEquations.jl` package, refer to the following link
for complete [installation
details](https://docs.sciml.ai/DiffEqDocs/stable/).
If the user wishes to separately install the `JumpProcesses.jl` library, which is a
lighter dependency than `DifferentialEquations.jl`, then the following code will
install `JumpProcesses.jl` using the Julia package manager:
```julia
using Pkg
Pkg.add("JumpProcesses")
```
## Examples
### Stochastic Chemical Kinetics SIR Model
Here we consider the stochastic chemical kinetics jump process model for the
basic SIR model, involving three species, $(S,I,R)$, that can undergo the
reactions $S + I \to 2I$ and $I \to R$ (each represented as a jump process)
```julia
using JumpProcesses, Plots
# here we order S = 1, I = 2, and R = 3
# substrate stoichiometry:
substoich = [[1 => 1, 2 => 1], # 1*S + 1*I
[2 => 1]] # 1*I
# net change by each jump type
netstoich = [[1 => -1, 2 => 1], # S -> S-1, I -> I+1
[2 => -1, 3 => 1]] # I -> I-1, R -> R+1
# rate constants for each jump
p = (0.1 / 1000, 0.01)
# p[1] is rate for S+I --> 2I, p[2] for I --> R
pidxs = [1, 2]
maj = MassActionJump(substoich, netstoich; param_idxs = pidxs)
u₀ = [999, 1, 0] #[S(0),I(0),R(0)]
tspan = (0.0, 250.0)
dprob = DiscreteProblem(u₀, tspan, p)
# use the Direct method to simulate
jprob = JumpProblem(dprob, Direct(), maj)
# solve as a pure jump process, i.e. using SSAStepper
sol = solve(jprob, SSAStepper())
plot(sol)
```
![SIR Model](docs/src/assets/SIR.png)
Instead of `MassActionJump`, we could have used the less efficient, but more
flexible, `ConstantRateJump` type
```julia
rate1(u, p, t) = p[1] * u[1] * u[2] # p[1]*S*I
function affect1!(integrator)
integrator.u[1] -= 1 # S -> S - 1
integrator.u[2] += 1 # I -> I + 1
end
jump = ConstantRateJump(rate1, affect1!)
rate2(u, p, t) = p[2] * u[2] # p[2]*I
function affect2!(integrator)
integrator.u[2] -= 1 # I -> I - 1
integrator.u[3] += 1 # R -> R + 1
end
jump2 = ConstantRateJump(rate2, affect2!)
jprob = JumpProblem(dprob, Direct(), jump, jump2)
sol = solve(jprob, SSAStepper())
```
### Jump-ODE Example
Let's solve an ODE for exponential growth, but coupled to a constant rate jump
(Poisson) process that halves the solution each time it fires
```julia
using DifferentialEquations, Plots
# du/dt = u is the ODE part
function f(du, u, p, t)
du[1] = u[1]
end
u₀ = [0.2]
tspan = (0.0, 10.0)
prob = ODEProblem(f, u₀, tspan)
# jump part
# fires with a constant intensity of 2
rate(u, p, t) = 2
# halve the solution when firing
affect!(integrator) = (integrator.u[1] = integrator.u[1] / 2)
jump = ConstantRateJump(rate, affect!)
# use the Direct method to handle simulating the jumps
jump_prob = JumpProblem(prob, Direct(), jump)
# now couple to the ODE, solving the ODE with the Tsit5 method
sol = solve(jump_prob, Tsit5())
plot(sol)
```
![constant_rate_jump](docs/src/assets/constant_rate_jump.png)
## Contributing and Getting Help
- Please refer to the
[SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://github.com/SciML/ColPrac/blob/master/README.md)
for guidance on PRs, issues, and other matters relating to contributing to SciML.
- See the [SciML Style Guide](https://github.com/SciML/SciMLStyle) for common coding practices and other style decisions.
- There are a few community forums for getting help and asking questions:
+ The #diffeq-bridged and #sciml-bridged channels in the
[Julia Slack](https://julialang.org/slack/)
+ The #diffeq-bridged and #sciml-bridged channels in the
[Julia Zulip](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
+ The [Julia Discourse forums](https://discourse.julialang.org)
+ See also the [SciML Community page](https://sciml.ai/community/)
没有合适的资源?快使用搜索试试~ 我知道了~
构建和模拟跳跃方程,如Gillespie模拟和具有恒定和状态相关速率的跳跃扩散,并与微分方程和科学机器学习(SciML).zip
共105个文件
jl:65个
md:13个
png:12个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 18 浏览量
2023-04-26
11:14:27
上传
评论
收藏 461KB ZIP 举报
温馨提示
构建和模拟跳跃方程,如Gillespie模拟和具有恒定和状态相关速率的跳跃扩散,并与微分方程和科学机器学习(SciML).zip
资源推荐
资源详情
资源评论
收起资源包目录
构建和模拟跳跃方程,如Gillespie模拟和具有恒定和状态相关速率的跳跃扩散,并与微分方程和科学机器学习(SciML).zip (105个子文件)
CITATION.bib 617B
.gitignore 52B
.gitignore 13B
favicon.ico 1KB
jumps.jl 29KB
hop_rates.jl 20KB
problem.jl 18KB
linearreaction_test.jl 11KB
SSA_stepper.jl 11KB
ssajump.jl 10KB
prioritytable.jl 9KB
coevolve.jl 9KB
directcrdirect.jl 8KB
aggregators.jl 8KB
extended_jump_array.jl 8KB
rssacr.jl 8KB
coupling.jl 7KB
nsm.jl 7KB
rssa.jl 7KB
hop_rates.jl 7KB
spatial_massaction_jump.jl 6KB
diffusion.jl 6KB
spatial_majump.jl 6KB
flatten.jl 6KB
ssa_callback_test.jl 5KB
directcr.jl 5KB
nrm.jl 5KB
variable_rate.jl 5KB
hawkes_test.jl 5KB
massaction_rates.jl 5KB
direct.jl 5KB
rdirect.jl 5KB
frm.jl 4KB
degenerate_rx_cases.jl 4KB
topology.jl 4KB
sortingdirect.jl 4KB
bimolerx_test.jl 4KB
bracketing.jl 4KB
splitcoupled.jl 4KB
allocations.jl 4KB
geneexpr_test.jl 3KB
utils.jl 3KB
ABC.jl 3KB
JumpProcesses.jl 3KB
solve.jl 3KB
runtests.jl 3KB
reaction_rates.jl 3KB
aggregated_api.jl 2KB
coupled_array.jl 2KB
extinction_test.jl 2KB
simple_regular_solve.jl 2KB
remake_test.jl 2KB
table_test.jl 2KB
reaction_rates.jl 2KB
make.jl 1KB
reversible_binding.jl 1KB
constant_rate.jl 1KB
ssa_tests.jl 1KB
topology.jl 1KB
saveat_regression.jl 1KB
monte_carlo_test.jl 993B
regular_jumps.jl 964B
sir_model.jl 959B
ensemble_uniqueness.jl 789B
jprob_symbol_indexing.jl 665B
longtimes_test.jl 563B
thread_safety.jl 529B
run_spatial_tests.jl 523B
pages.jl 509B
discrete_stochastic_example.md 37KB
jump_types.md 24KB
simple_poisson_process.md 15KB
spatial.md 10KB
README.md 7KB
faq.md 7KB
jump_diffusion.md 5KB
index.md 4KB
jump_solve.md 4KB
cut.md 3KB
LICENSE.md 1KB
HISTORY.md 564B
api.md 563B
sde_gillespie.png 38KB
gillespie_ode.png 31KB
variable_rate_gillespie.png 31KB
gillespie_solution.png 30KB
gillespie_hybrid_jumps.png 29KB
SIR.png 27KB
jump_diffusion.png 27KB
logo.png 26KB
constant_rate_jump.png 25KB
variable_rate_jump.png 23KB
splitcoupling.png 18KB
callback_gillespie.png 17KB
Project.toml 2KB
Project.toml 553B
.JuliaFormatter.toml 38B
Invalidations.yml 1KB
FormatCheck.yml 1KB
CI.yml 1KB
共 105 条
- 1
- 2
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功