Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function NoiseProcess{iip}(
reset = true, reseed = true, continuous = true,
cache = nothing
) where {iip}
rng = rng isa Random.TaskLocalRNG ? copy(rng) : rng
rng = rng isa Random.TaskLocalRNG ? Xoshiro(rand(rng, UInt64)) : rng
S₁ = ResettableStacks.ResettableStack{iip}(
Tuple{
typeof(t0), typeof(W0), typeof(Z0),
Expand Down Expand Up @@ -417,7 +417,7 @@ mutable struct SimpleNoiseProcess{
rng = Random.default_rng(),
reset = true, reseed = true
) where {iip}
rng = rng isa Random.TaskLocalRNG ? copy(rng) : rng
rng = rng isa Random.TaskLocalRNG ? Xoshiro(rand(rng, UInt64)) : rng
if Z0 == nothing
Z = nothing
curZ = nothing
Expand Down Expand Up @@ -915,7 +915,7 @@ mutable struct NoiseTransport{T, N, wType, zType, Tt, T2, T3, TRV, Trv, RNGType,
reset = true, reseed = true,
noise_prototype = W(nothing, nothing, t0, rv)
) where {iip}
rng = rng isa Random.TaskLocalRNG ? copy(rng) : rng
rng = rng isa Random.TaskLocalRNG ? Xoshiro(rand(rng, UInt64)) : rng
curt = t0
dt = t0
curW = copy(noise_prototype)
Expand Down Expand Up @@ -1544,7 +1544,7 @@ function BoxWedgeTail{iip}(
rng = Random.default_rng(),
reset = true, reseed = true
) where {iip}
rng = rng isa Random.TaskLocalRNG ? copy(rng) : rng
rng = rng isa Random.TaskLocalRNG ? Xoshiro(rand(rng, UInt64)) : rng
if Z0 === nothing
Z = nothing
curZ = nothing
Expand Down
15 changes: 15 additions & 0 deletions test/two_processes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,18 @@ Random.seed!(seed);
@test norm(soloop.Z - sol.Z) == 0.0
end
end

# https://github.com/SciML/DiffEqNoiseProcess.jl/issues/258
@testset "Default rng gives each process its own stream" begin
W1 = WienerProcess(0.0, 0.0, 0.0; reseed = false)
W2 = WienerProcess(0.0, 0.0, 0.0; reseed = false)
sol1 = solve(NoiseProblem(W1, (0.0, 1.0)); dt = 0.1)
sol2 = solve(NoiseProblem(W2, (0.0, 1.0)); dt = 0.1)
@test sol1.W != sol2.W

W3 = WienerProcess(0.0, 0.0, 0.0; rng = Xoshiro(7), reseed = false)
W4 = WienerProcess(0.0, 0.0, 0.0; rng = Xoshiro(7), reseed = false)
sol3 = solve(NoiseProblem(W3, (0.0, 1.0)); dt = 0.1)
sol4 = solve(NoiseProblem(W4, (0.0, 1.0)); dt = 0.1)
@test sol3.W == sol4.W
end