Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
vyudu committed Oct 16, 2024
1 parent 1bece86 commit babd281
Show file tree
Hide file tree
Showing 68 changed files with 822 additions and 815 deletions.
34 changes: 17 additions & 17 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ cp(joinpath(docpath, "Project.toml"), joinpath(assetpath, "Project.toml"), force
include("pages.jl")

mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]),
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
"packages" => [
"base",
"ams",
"autoload",
"mathtools",
"require"
])))
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
"packages" => [
"base",
"ams",
"autoload",
"mathtools",
"require",
])))

makedocs(sitename = "JumpProcesses.jl",
authors = "Chris Rackauckas",
modules = [JumpProcesses],
clean = true, doctest = false, linkcheck = true, warnonly = [:missing_docs],
format = Documenter.HTML(; assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/JumpProcesses/",
prettyurls = (get(ENV, "CI", nothing) == "true"),
mathengine),
pages = pages)
authors = "Chris Rackauckas",
modules = [JumpProcesses],
clean = true, doctest = false, linkcheck = true, warnonly = [:missing_docs],
format = Documenter.HTML(; assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/JumpProcesses/",
prettyurls = (get(ENV, "CI", nothing) == "true"),
mathengine),
pages = pages)

deploydocs(repo = "github.com/SciML/JumpProcesses.jl.git";
push_preview = true)
push_preview = true)
2 changes: 1 addition & 1 deletion docs/old/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sol = solve(jprob, SSAStepper())
using Plots
plot(sol, title = "Sample path from a jump process with constant rate",
label = "N(t)", xlabel = "t", legend = :bottomright)
label = "N(t)", xlabel = "t", legend = :bottomright)
```

## Step 1: Defining a problem
Expand Down
12 changes: 6 additions & 6 deletions docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

pages = ["index.md",
"Tutorials" => Any["tutorials/simple_poisson_process.md",
"tutorials/discrete_stochastic_example.md",
"tutorials/point_process_simulation.md",
"tutorials/jump_diffusion.md",
"tutorials/spatial.md"],
"tutorials/discrete_stochastic_example.md",
"tutorials/point_process_simulation.md",
"tutorials/jump_diffusion.md",
"tutorials/spatial.md"],
"Applications" => Any["applications/advanced_point_process.md"],
"Type Documentation" => Any["Jumps, JumpProblem, and Aggregators" => "jump_types.md",
"Jump solvers" => "jump_solve.md"],
"Jump solvers" => "jump_solve.md"],
"FAQ" => "faq.md",
"API" => "api.md"
"API" => "api.md",
]
112 changes: 56 additions & 56 deletions docs/src/applications/advanced_point_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ end
function Base.show(io::IO, pp::SciMLPointProcess)
println(io,
"SciMLPointProcess with $(length(pp.jumps)) processes on the interval [$(pp.tmin), $(pp.tmax)).")
"SciMLPointProcess with $(length(pp.jumps)) processes on the interval [$(pp.tmin), $(pp.tmax)).")
end
```

Expand Down Expand Up @@ -294,12 +294,12 @@ function hawkes_p(pp::SciMLPointProcess{M, J, G, D, T}) where {M, J, G, D, T}
tmax = pp.tmax
h = History(; times = T[], marks = Tuple{Int, M}[], tmin = tmin, tmax = tmax)
return (λ = 0.5,
α = 0.1,
β = 2.0,
ϕ = zeros(T, length(g)),
M = map(d -> tuple(mean(d)...), pp.mark_dist),
T = zeros(T, length(g)),
h = h)
α = 0.1,
β = 2.0,
ϕ = zeros(T, length(g)),
M = map(d -> tuple(mean(d)...), pp.mark_dist),
T = zeros(T, length(g)),
h = h)
end
function hawkes_p(pp::SciMLPointProcess{M, J, G, D, T}, p) where {M, J, G, D, T}
Expand All @@ -324,17 +324,17 @@ mark_dist = [MvNormal(rand(2), [0.2, 0.2]) for i in 1:nv(G)]
jumps = [hawkes_jump(i, g, mark_dist) for i in 1:nv(G)]
tspan = (0.0, 50.0)
hawkes = SciMLPointProcess{
Vector{Real},
eltype(jumps),
typeof(g),
eltype(mark_dist),
eltype(tspan)
}(jumps,
mark_dist,
g,
hawkes_p,
tspan[1],
tspan[2])
Vector{Real},
eltype(jumps),
typeof(g),
eltype(mark_dist),
eltype(tspan)
}(jumps,
mark_dist,
g,
hawkes_p,
tspan[1],
tspan[2])
```

## [Sampling](@id tpp_sampling)
Expand Down Expand Up @@ -378,10 +378,10 @@ function Base.rand(pp::SciMLPointProcess, n::Int)
end
function Base.rand(rng::AbstractRNG,
pp::SciMLPointProcess{M, J, G, D, T},
tmin::T,
tmax::T,
n::Int) where {M, J, G, D, T <: Real}
pp::SciMLPointProcess{M, J, G, D, T},
tmin::T,
tmax::T,
n::Int) where {M, J, G, D, T <: Real}
tspan = (tmin, tmax)
save_positions = (false, false)
out = Array{History, 1}(undef, n)
Expand Down Expand Up @@ -487,7 +487,7 @@ function intensity(pp::SciMLPointProcess, t, h; saveat = [], save_positions = (t
end
callback = DiscreteCallback(condition, affect!; save_positions)
dprob = DiscreteProblem(rates, rates(nothing, p, tmin), (tmin, tmax), p; callback,
tstops, saveat)
tstops, saveat)
sol = solve(dprob, FunctionMap())
return sol
end
Expand Down Expand Up @@ -573,11 +573,11 @@ conditional intensity using an ODEProblem.

```@example tpp-advanced
function integrated_intensity(pp::SciMLPointProcess,
t,
h;
alg = nothing,
saveat = [],
save_positions = (true, true))
t,
h;
alg = nothing,
saveat = [],
save_positions = (true, true))
p = params(pp)
times = event_times(h)
marks = event_marks(h)
Expand All @@ -593,12 +593,12 @@ function integrated_intensity(pp::SciMLPointProcess,
end
callback = DiscreteCallback(condition, affect!; save_positions)
prob = ODEProblem(rates,
zeros(eltype(times), length(pp.jumps)),
tspan,
p;
tstops = times,
callback,
saveat)
zeros(eltype(times), length(pp.jumps)),
tspan,
p;
tstops = times,
callback,
saveat)
sol = solve(prob, alg)
return sol
end
Expand All @@ -613,11 +613,11 @@ the next section when we compute the log-likelihood.
```@example tpp-advanced
function integrated_ground_intensity(pp::SciMLPointProcess, h, a, b)
Λ = integrated_intensity(pp,
b,
h;
alg = Rodas4P(),
saveat = [a, b],
save_positions = (false, false))
b,
h;
alg = Rodas4P(),
saveat = [a, b],
save_positions = (false, false))
return sum(Λ(b)) - sum(Λ(a))
end
Expand All @@ -631,10 +631,10 @@ solver that can deal with stiff problems like `Rodas4P()`.

```@example tpp-advanced
Λ = integrated_intensity(hawkes,
max_time(hawkes),
h;
saveat = event_times(h),
alg = Rodas4P())
max_time(hawkes),
h;
saveat = event_times(h),
alg = Rodas4P())
plot(Λ)
```

Expand Down Expand Up @@ -662,7 +662,7 @@ function hawkes_integrated_intensity(pp::SciMLPointProcess, t, h; saveat = [])
return u
end
dprob = DiscreteProblem(compensator, zeros(eltype(event_times(h)), length(pp.jumps)),
(min_time(h), t), p; tstops, saveat)
(min_time(h), t), p; tstops, saveat)
sol = solve(dprob, FunctionMap())
return sol
end
Expand Down Expand Up @@ -693,10 +693,10 @@ function Base.filter(f, h::History)
end
end
return History(;
times = filtered_times,
marks = filtered_marks,
tmin = min_time(h),
tmax = max_time(h))
times = filtered_times,
marks = filtered_marks,
tmin = min_time(h),
tmax = max_time(h))
end
```

Expand Down Expand Up @@ -744,10 +744,10 @@ itself to produce the QQ-plot for the ground process.
for _ in 1:250
_h = rand(hawkes)
_Λ = integrated_intensity(hawkes,
max_time(hawkes),
_h;
saveat = event_times(_h),
alg = Rodas4P())
max_time(hawkes),
_h;
saveat = event_times(_h),
alg = Rodas4P())
_h̃ = time_change(_h, (t) -> sum(_Λ(t)))
append!(Δt̃, diff(event_times(_h̃)))
end
Expand All @@ -763,10 +763,10 @@ Likewise, we can produce the QQ-plot for each sub-TPP.
for _ in 1:250
_h = rand(hawkes)
_Λ = integrated_intensity(hawkes,
max_time(hawkes),
_h;
saveat = event_times(_h),
alg = Rodas4P())
max_time(hawkes),
_h;
saveat = event_times(_h),
alg = Rodas4P())
for i in 1:nv(G)
_h̃ = time_change(filter((t, mark) -> mark[1] == i, _h), (t) -> Λ(t; idxs = i))
append!(Δt̃[i], diff(event_times(_h̃)))
Expand Down
6 changes: 3 additions & 3 deletions docs/src/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ vj2 = VariableRateJump(rate4, affect4!)
vjtuple = (vj1, vj2)

jset = JumpSet(; constant_jumps = cjvec, variable_jumps = vjtuple,
massaction_jumps = mass_act_jump)
massaction_jumps = mass_act_jump)
```

## How can I set the random number generator used in the jump process sampling algorithms (SSAs)?
Expand All @@ -62,7 +62,7 @@ argument. Continuing the previous example:
#] add RandomNumbers
using RandomNumbers
jprob = JumpProblem(dprob, Direct(), maj,
rng = Xorshifts.Xoroshiro128Star(rand(UInt64)))
rng = Xorshifts.Xoroshiro128Star(rand(UInt64)))
```

uses the `Xoroshiro128Star` generator from
Expand Down Expand Up @@ -148,7 +148,7 @@ function paffect!(integrator)
nothing
end
sol = solve(jprob, SSAStepper(), tstops = [20.0],
callback = DiscreteCallback(pcondit, paffect!))
callback = DiscreteCallback(pcondit, paffect!))
```

Here at time `20.0` we turn off production of `u[2]` while activating production
Expand Down
10 changes: 5 additions & 5 deletions docs/src/jump_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ The constructor for a [`VariableRateJump`](@ref) is:

```julia
VariableRateJump(rate, affect!;
lrate = nothing, urate = nothing, rateinterval = nothing,
idxs = nothing, rootfind = true, save_positions = (true, true),
interp_points = 10, abstol = 1e-12, reltol = 0)
lrate = nothing, urate = nothing, rateinterval = nothing,
idxs = nothing, rootfind = true, save_positions = (true, true),
interp_points = 10, abstol = 1e-12, reltol = 0)
```

- `rate(u, p, t)` is a function which calculates the rate given the current
Expand Down Expand Up @@ -241,8 +241,8 @@ is:

```julia
JumpProblem(prob, aggregator, jumps::JumpSet;
save_positions = prob isa AbstractDiscreteProblem ? (false, true) :
(true, true))
save_positions = prob isa AbstractDiscreteProblem ? (false, true) :
(true, true))
```

The aggregator is the method for simulating `ConstantRateJump`s,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/tutorials/discrete_stochastic_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,11 @@ latter determining the affect function.
rateidxs = [1, 2] # i.e., [β, ν]
reactant_stoich = [
[1 => 1, 2 => 1], # 1*S and 1*I
[2 => 1] # 1*I
[2 => 1], # 1*I
]
net_stoich = [
[1 => -1, 2 => 1], # -1*S and 1*I
[2 => -1, 3 => 1] # -1*I and 1*R
[2 => -1, 3 => 1], # -1*I and 1*R
]
mass_act_jump = MassActionJump(reactant_stoich, net_stoich; param_idxs = rateidxs)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorials/point_process_simulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Now, we can declare the seasonal process as a `VariableRateJump`.

```@example tpp-tutorial
seasonal_process = VariableRateJump(seasonal_rate, seasonal_affect!;
urate, rateinterval, lrate)
urate, rateinterval, lrate)
```

We initialize a new base problem with a different simulation
Expand Down
6 changes: 3 additions & 3 deletions docs/src/tutorials/spatial.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ We are now ready to set up the `JumpProblem` with the Next Subvolume Method.
```@example spatial
alg = NSM()
jump_prob = JumpProblem(prob, alg, majumps, hopping_constants = hopping_constants,
spatial_system = grid, save_positions = (true, false))
spatial_system = grid, save_positions = (true, false))
```

The `save_positions` keyword tells the solver to save the positions just before the jumps. To solve the jump problem do
Expand Down Expand Up @@ -124,7 +124,7 @@ function get_frame(k, sol, linear_size, labels, title)
end
for species in 1:num_species
scatter!(plt, species_seriess_x[species], species_seriess_y[species],
label = labels[species], marker = 6)
label = labels[species], marker = 6)
end
xticks!(plt, range(xlim..., length = linear_size + 1))
yticks!(plt, range(ylim..., length = linear_size + 1))
Expand All @@ -146,7 +146,7 @@ function animate_2d(sol, linear_size; species_labels, title, verbose = true)
end
# animate
anim = animate_2d(solution, 5, species_labels = ["A", "B", "C"], title = "A + B <--> C",
verbose = false)
verbose = false)
fps = 5
gif(anim, fps = fps)
```
Expand Down
Loading

0 comments on commit babd281

Please sign in to comment.