SciML / DiffEqNoiseProcess.jl

A library of noise processes for stochastic systems like stochastic differential equations (SDEs) and other systems that are present in scientific machine learning (SciML)
https://docs.sciml.ai/DiffEqNoiseProcess/stable/
Other
63 stars 29 forks source link

Speed up NoiseGrid/NoiseWrapper #140

Closed frankschae closed 1 year ago

frankschae commented 1 year ago

Perhaps surprisingly, NoiseGrid is pretty slow when a long time series is used.

dt = 0.001

W = WienerProcess!(0.0, rand(2))
prob = NoiseProblem(W, (0.0, 1000.0))
sol = @btime solve(prob; dt=dt) #  92.881 ms

NG = NoiseGrid(sol.t, sol.u)
_prob = NoiseProblem(NG, (0.0, 1000.0))
_sol = @btime solve(_prob; dt=dt) #  677.373 ms 

@test _sol.u ≈ sol.u

Would it be worth introducing a ref pointer to "guess" the next grid point? This avoids the need to search the entire time grid for each interpolation step: https://github.com/SciML/DiffEqNoiseProcess.jl/blob/master/src/noise_interfaces/noise_grid_interface.jl#L27-L31 and instead only do a full search if it's not the point one to the right/left of the previous point.

ChrisRackauckas commented 1 year ago

Agreed, interpolations like that are generally slow because of the search.