|
1 | | -function cpp_bridge(dW,cpp,W,W0,Wh,q,h,u,p,t,rng) |
2 | | - rand.(rng,Distributions.Binomial.(Int.(Wh),float.(q))) |
3 | | -end |
4 | | -function cpp_bridge!(rand_vec,cpp,W,W0,Wh,q,h,u,p,t,rng) |
5 | | - rand_vec .= rand.(rng,Distributions.Binomial.(Int.(Wh),float.(q))) |
6 | | -end |
7 | | - |
8 | | -""" |
9 | | -https://www.math.wisc.edu/~anderson/papers/AndPostleap.pdf |
10 | | -Incorporating postleap checks in tau-leaping |
11 | | -J. Chem. Phys. 128, 054103 (2008); https://doi.org/10.1063/1.2819665 |
12 | | -""" |
13 | | -mutable struct CompoundPoissonProcess{R,CR} |
14 | | - rate::R |
15 | | - currate::CR |
16 | | - computerates::Bool |
17 | | - function CompoundPoissonProcess(rate,t0,W0;computerates=true,kwargs...) |
18 | | - cpp = new{typeof(rate),typeof(W0)}(rate,W0,computerates) |
19 | | - NoiseProcess{false}(t0,W0,nothing,cpp,(dW,W,W0,Wh,q,h,u,p,t,rng)->cpp_bridge(dW,cpp,W,W0,Wh,q,h,u,p,t,rng);continuous=false,cache=cpp,kwargs...) |
20 | | - end |
21 | | -end |
22 | | -function (P::CompoundPoissonProcess)(dW,W,dt,u,p,t,rng) |
23 | | - P.computerates && (P.currate = P.rate(u,p,t)) |
24 | | - PoissonRandom.pois_rand.(rng,dt.*P.currate) |
25 | | -end |
26 | | - |
27 | | -""" |
28 | | -https://www.math.wisc.edu/~anderson/papers/AndPostleap.pdf |
29 | | -Incorporating postleap checks in tau-leaping |
30 | | -J. Chem. Phys. 128, 054103 (2008); https://doi.org/10.1063/1.2819665 |
31 | | -""" |
32 | | -struct CompoundPoissonProcess!{R,CR} |
33 | | - rate::R |
34 | | - currate::CR |
35 | | - computerates::Bool |
36 | | - function CompoundPoissonProcess!(rate,t0,W0;computerates=true,kwargs...) |
37 | | - cpp = new{typeof(rate),typeof(W0)}(rate,copy(W0),computerates) |
38 | | - NoiseProcess{true}(t0,W0,nothing,cpp,(rand_vec,W,W0,Wh,q,h,u,p,t,rng)->cpp_bridge!(rand_vec,cpp,W,W0,Wh,q,h,u,p,t,rng);continuous=false,cache=cpp,kwargs...) |
39 | | - end |
40 | | -end |
41 | | -function (P::CompoundPoissonProcess!)(rand_vec,W,dt,u,p,t,rng) |
42 | | - P.computerates && P.rate(P.currate,u,p,t) |
43 | | - @. rand_vec = PoissonRandom.pois_rand(rng,dt*P.currate) |
44 | | -end |
| 1 | +function cpp_bridge(dW, cpp, W, W0, Wh, q, h, u, p, t, rng) |
| 2 | + rand.(rng, Distributions.Binomial.(Int.(Wh), float.(q))) |
| 3 | +end |
| 4 | +function cpp_bridge!(rand_vec, cpp, W, W0, Wh, q, h, u, p, t, rng) |
| 5 | + rand_vec .= rand.(rng, Distributions.Binomial.(Int.(Wh), float.(q))) |
| 6 | +end |
| 7 | + |
| 8 | +""" |
| 9 | +https://www.math.wisc.edu/~anderson/papers/AndPostleap.pdf |
| 10 | +Incorporating postleap checks in tau-leaping |
| 11 | +J. Chem. Phys. 128, 054103 (2008); https://doi.org/10.1063/1.2819665 |
| 12 | +""" |
| 13 | +mutable struct CompoundPoissonProcess{R, CR} |
| 14 | + rate::R |
| 15 | + currate::CR |
| 16 | + computerates::Bool |
| 17 | + function CompoundPoissonProcess(rate, t0, W0; computerates = true, kwargs...) |
| 18 | + cpp = new{typeof(rate), typeof(W0)}(rate, W0, computerates) |
| 19 | + NoiseProcess{false}(t0, W0, nothing, cpp, |
| 20 | + (dW, W, W0, Wh, q, h, u, p, t, rng) -> cpp_bridge(dW, cpp, W, |
| 21 | + W0, Wh, q, h, |
| 22 | + u, p, t, rng); |
| 23 | + continuous = false, cache = cpp, kwargs...) |
| 24 | + end |
| 25 | +end |
| 26 | +function (P::CompoundPoissonProcess)(dW, W, dt, u, p, t, rng) |
| 27 | + P.computerates && (P.currate = P.rate(u, p, t)) |
| 28 | + PoissonRandom.pois_rand.(rng, dt .* P.currate) |
| 29 | +end |
| 30 | + |
| 31 | +""" |
| 32 | +https://www.math.wisc.edu/~anderson/papers/AndPostleap.pdf |
| 33 | +Incorporating postleap checks in tau-leaping |
| 34 | +J. Chem. Phys. 128, 054103 (2008); https://doi.org/10.1063/1.2819665 |
| 35 | +""" |
| 36 | +struct CompoundPoissonProcess!{R, CR} |
| 37 | + rate::R |
| 38 | + currate::CR |
| 39 | + computerates::Bool |
| 40 | + function CompoundPoissonProcess!(rate, t0, W0; computerates = true, kwargs...) |
| 41 | + cpp = new{typeof(rate), typeof(W0)}(rate, copy(W0), computerates) |
| 42 | + NoiseProcess{true}(t0, W0, nothing, cpp, |
| 43 | + (rand_vec, W, W0, Wh, q, h, u, p, t, rng) -> cpp_bridge!(rand_vec, |
| 44 | + cpp, W, |
| 45 | + W0, Wh, |
| 46 | + q, h, u, |
| 47 | + p, t, |
| 48 | + rng); |
| 49 | + continuous = false, cache = cpp, kwargs...) |
| 50 | + end |
| 51 | +end |
| 52 | +function (P::CompoundPoissonProcess!)(rand_vec, W, dt, u, p, t, rng) |
| 53 | + P.computerates && P.rate(P.currate, u, p, t) |
| 54 | + @. rand_vec = PoissonRandom.pois_rand(rng, dt * P.currate) |
| 55 | +end |
0 commit comments