Skip to content

Commit ffe84e2

Browse files
Merge pull request #634 from vyudu/change_rng
change RNG to Xoshiro, drop RandomNumbers
2 parents 0ddad8b + 0f90b5d commit ffe84e2

13 files changed

+49
-52
lines changed

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
2424
OrdinaryDiffEqDifferentiation = "4302a76b-040a-498a-8c04-15b101fed76b"
2525
OrdinaryDiffEqNonlinearSolve = "127b3ac7-2247-4354-8eb6-78cf4e7c58e8"
2626
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
27-
RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143"
2827
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
2928
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
3029
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
@@ -56,7 +55,6 @@ OrdinaryDiffEqCore = "1.32.0"
5655
OrdinaryDiffEqDifferentiation = "1.9"
5756
OrdinaryDiffEqNonlinearSolve = "1"
5857
Random = "1.6"
59-
RandomNumbers = "1.5.3"
6058
RecursiveArrayTools = "2, 3"
6159
Reexport = "0.2, 1.0"
6260
SciMLBase = "2.115"

src/StochasticDiffEq.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ $(DocStringExtensions.README)
44
module StochasticDiffEq
55

66
using DocStringExtensions
7-
import RandomNumbers: Xorshifts
87

98
using Reexport
109
@reexport using DiffEqBase

src/perform_step/low_order.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ end
242242
@unpack t, dt, uprev, u, W, p, f = integrator
243243
integrator.f(du1, uprev, p, t)
244244
integrator.g(L, uprev, p, t)
245+
245246
@.. K = uprev + dt * du1
246247
@.. du2 = zero(eltype(u)) # This makes it safe to re-use the array
247248
if SciMLBase.alg_interpretation(integrator.alg) == SciMLBase.AlgorithmInterpretation.Ito

src/solve.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ function DiffEqBase.__init(
411411
rand_prototype2 .= false
412412
W = WienerProcess!(t, rand_prototype, rand_prototype2,
413413
save_everystep = save_noise,
414-
rng = Xorshifts.Xoroshiro128Plus(_seed))
414+
rng = Random.Xoshiro(_seed))
415415
elseif alg isa RKMilGeneral
416416
m = length(rand_prototype)
417417
if alg.p != nothing
@@ -422,33 +422,33 @@ function DiffEqBase.__init(
422422
end
423423
W = WienerProcess!(t, rand_prototype, rand_prototype2,
424424
save_everystep = save_noise,
425-
rng = Xorshifts.Xoroshiro128Plus(_seed))
425+
rng = Random.Xoshiro(_seed))
426426
elseif alg isa W2Ito1
427427
m = 2
428428
rand_prototype2 = zeros(eltype(rand_prototype), Int(m))
429429
W = WienerProcess!(t, rand_prototype, rand_prototype2,
430430
save_everystep = save_noise,
431-
rng = Xorshifts.Xoroshiro128Plus(_seed))
431+
rng = Random.Xoshiro(_seed))
432432
else
433433
W = WienerProcess!(t, rand_prototype, rand_prototype,
434434
save_everystep = save_noise,
435-
rng = Xorshifts.Xoroshiro128Plus(_seed))
435+
rng = Random.Xoshiro(_seed))
436436
end
437437
else
438438
W = WienerProcess!(t, rand_prototype,
439439
save_everystep = save_noise,
440-
rng = Xorshifts.Xoroshiro128Plus(_seed))
440+
rng = Random.Xoshiro(_seed))
441441
end
442442
#=
443443
else
444444
if alg_needs_extra_process(alg)
445445
W = SimpleWienerProcess!(t,rand_prototype,rand_prototype,
446446
save_everystep=save_noise,
447-
rng = Xorshifts.Xoroshiro128Plus(_seed))
447+
rng = Random.Xoshiro(_seed))
448448
else
449449
W = SimpleWienerProcess!(t,rand_prototype,
450450
save_everystep=save_noise,
451-
rng = Xorshifts.Xoroshiro128Plus(_seed))
451+
rng = Random.Xoshiro(_seed))
452452
end
453453
end
454454
=#
@@ -465,7 +465,7 @@ function DiffEqBase.__init(
465465
end
466466
W = WienerProcess(t, rand_prototype, rand_prototype2,
467467
save_everystep = save_noise,
468-
rng = Xorshifts.Xoroshiro128Plus(_seed))
468+
rng = Random.Xoshiro(_seed))
469469
elseif alg isa RKMilGeneral
470470
m = length(rand_prototype)
471471
if rand_prototype isa Number || alg.p === nothing
@@ -476,33 +476,33 @@ function DiffEqBase.__init(
476476
end
477477
W = WienerProcess(t, rand_prototype, rand_prototype2,
478478
save_everystep = save_noise,
479-
rng = Xorshifts.Xoroshiro128Plus(_seed))
479+
rng = Random.Xoshiro(_seed))
480480
elseif alg isa W2Ito1
481481
m = 2
482482
rand_prototype2 = zeros(eltype(rand_prototype), Int(m))
483483
W = WienerProcess(t, rand_prototype, rand_prototype2,
484484
save_everystep = save_noise,
485-
rng = Xorshifts.Xoroshiro128Plus(_seed))
485+
rng = Random.Xoshiro(_seed))
486486
else
487487
W = WienerProcess(t, rand_prototype, rand_prototype,
488488
save_everystep = save_noise,
489-
rng = Xorshifts.Xoroshiro128Plus(_seed))
489+
rng = Random.Xoshiro(_seed))
490490
end
491491
else
492492
W = WienerProcess(t, rand_prototype,
493493
save_everystep = save_noise,
494-
rng = Xorshifts.Xoroshiro128Plus(_seed))
494+
rng = Random.Xoshiro(_seed))
495495
end
496496
#=
497497
else
498498
if alg_needs_extra_process(alg)
499499
W = SimpleWienerProcess(t,rand_prototype,rand_prototype,
500500
save_everystep=save_noise,
501-
rng = Xorshifts.Xoroshiro128Plus(_seed))
501+
rng = Random.Xoshiro(_seed))
502502
else
503503
W = SimpleWienerProcess(t,rand_prototype,
504504
save_everystep=save_noise,
505-
rng = Xorshifts.Xoroshiro128Plus(_seed))
505+
rng = Random.Xoshiro(_seed))
506506
end
507507
end
508508
=#
@@ -546,15 +546,15 @@ function DiffEqBase.__init(
546546
P = CompoundPoissonProcess!(_prob.regular_jump.rate, t, jump_prototype,
547547
computerates = !alg_control_rate(alg) || !adaptive,
548548
save_everystep = save_noise,
549-
rng = Xorshifts.Xoroshiro128Plus(_seed))
549+
rng = Random.Xoshiro(_seed))
550550
alg_control_rate(alg) && adaptive &&
551551
P.cache.rate(P.cache.currate, u, p, tspan[1])
552552
else
553553
rate_constants = _prob.regular_jump.rate(u ./ u, prob.p, tspan[1])
554554
P = CompoundPoissonProcess(_prob.regular_jump.rate, t, jump_prototype,
555555
save_everystep = save_noise,
556556
computerates = !alg_control_rate(alg) || !adaptive,
557-
rng = Xorshifts.Xoroshiro128Plus(_seed))
557+
rng = Random.Xoshiro(_seed))
558558
alg_control_rate(alg) && adaptive &&
559559
(P.cache.currate = P.cache.rate(u, p, tspan[1]))
560560
end

test/gpu/sde_weak_adaptive_gpu.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ftrue = Vector{}(undef, 2)
9898
ftrue[1] = f_true1
9999
ftrue[2] = f_true2
100100

101-
numtraj = Int(1e5)
101+
numtraj = Int(1e6)
102102
seed = 100
103103
Random.seed!(seed)
104104
seeds = rand(UInt, numtraj)

test/reversal_tests.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using StochasticDiffEq, DiffEqNoiseProcess, Test, Random
2-
using Random
32
using SDEProblemLibrary
43
# automatically construct SDE transformation for Ito reversal
54
using ModelingToolkit
@@ -118,7 +117,6 @@ end
118117
@testset "Ito Solver Reversal Tests ($(["out-of-place", "in-place"][i]))" for i in 1:2
119118
prob = (SDEProblemLibrary.prob_sde_linear,
120119
SDEProblemLibrary.prob_sde_2Dlinear)[i]
121-
122120
if i == 1
123121
prob_forward = remake(prob, noise = W_forward)
124122
else

test/weak_convergence/SIE_SME.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ end
2121
@info "Scalar oop noise"
2222

2323
# PC exercise 14.2.2
24-
numtraj = Int(7e3)
24+
numtraj = Int(1e5)
2525
u₀ = 0.1
2626
f(u, p, t) = p[1]*u
2727
g(u, p, t) = p[2]*u
@@ -93,7 +93,7 @@ ensemble_prob = EnsembleProblem(prob;
9393
prob_func = prob_func
9494
)
9595

96-
numtraj = Int(7e3)
96+
numtraj = Int(1e5)
9797
seed = 100
9898
Random.seed!(seed)
9999
seeds = rand(UInt, numtraj)
@@ -156,7 +156,7 @@ ensemble_prob = EnsembleProblem(prob;
156156
prob_func = prob_func
157157
)
158158

159-
numtraj = Int(5e4)
159+
numtraj = Int(1e6)
160160
seed = 100
161161
Random.seed!(seed)
162162
seeds = rand(UInt, numtraj)

test/weak_convergence/W2Ito1.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ end
2121

2222
@info "Scalar noise"
2323

24-
numtraj = Int(1e6) # in the paper they use 1e9
24+
numtraj = Int(2e6) # in the paper they use 1e9
2525
u₀ = 0.0
2626
f(u, p, t) = 1 // 2 * u + sqrt(u^2 + 1)
2727
g(u, p, t) = sqrt(u^2 + 1)
@@ -102,7 +102,7 @@ ensemble_prob = EnsembleProblem(prob;
102102
prob_func = prob_func
103103
)
104104

105-
numtraj = Int(1e5)
105+
numtraj = Int(1e6)
106106
seed = 100
107107
Random.seed!(seed)
108108
seeds = rand(UInt, numtraj)
@@ -206,7 +206,7 @@ ensemble_prob = EnsembleProblem(prob;
206206
prob_func = prob_func
207207
)
208208

209-
numtraj = Int(1e5)
209+
numtraj = Int(1e6)
210210
seed = 100
211211
Random.seed!(seed)
212212
seeds = rand(UInt, numtraj)

test/weak_convergence/multidim_iip_weak.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ sim = test_convergence(
7575
#@test abs(sim.𝒪est[:weak_l∞]-1) < 0.3
7676
println("SROCKC2")
7777
sim = test_convergence(
78-
dts, prob, SROCKC2(), save_everystep = false, trajectories = Int(4e4),
78+
dts, prob, SROCKC2(), save_everystep = false, trajectories = Int(5e4),
7979
weak_timeseries_errors = false)
8080
@test abs(sim.𝒪est[:weak_final]-1) < 0.3
8181
#@test abs(sim.𝒪est[:weak_l2]-2) < 0.3

test/weak_convergence/srk_weak_diagonal_final.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ sim = test_convergence(dts, ensemble_prob, RI5(),
8989
@test abs(sim.𝒪est[:weak_final]-2) < 0.45
9090
println("RI5:", sim.𝒪est[:weak_final])
9191

92-
numtraj = Int(6e6)
92+
numtraj = Int(3e7)
9393
Random.seed!(seed)
9494
seeds = rand(UInt, numtraj)
9595

@@ -98,10 +98,10 @@ sim = test_convergence(dts, ensemble_prob, RI6(),
9898
weak_timeseries_errors = false, weak_dense_errors = false,
9999
expected_value = 1//100*exp(301//100)
100100
)
101-
@test abs(sim.𝒪est[:weak_final]-2) < 0.5 # order is 1.55
101+
@test abs(sim.𝒪est[:weak_final]-1.5) < 0.5 # order is 1.55
102102
println("R6:", sim.𝒪est[:weak_final])
103103

104-
numtraj = Int(4e6)
104+
numtraj = Int(1e7)
105105
Random.seed!(seed)
106106
seeds = rand(UInt, numtraj)
107107

@@ -113,7 +113,7 @@ sim = test_convergence(dts, ensemble_prob, RDI1WM(),
113113
@test abs(sim.𝒪est[:weak_final]-1) < 0.5 # order is 1.44
114114
println("RDI1WM:", sim.𝒪est[:weak_final])
115115

116-
numtraj = Int(6e6)
116+
numtraj = Int(3e7)
117117
Random.seed!(seed)
118118
seeds = rand(UInt, numtraj)
119119

@@ -122,7 +122,7 @@ sim = test_convergence(dts, ensemble_prob, RDI2WM(),
122122
weak_timeseries_errors = false, weak_dense_errors = false,
123123
expected_value = 1//100*exp(301//100)
124124
)
125-
@test abs(sim.𝒪est[:weak_final]-2) < 0.5 # order is 1.55
125+
@test abs(sim.𝒪est[:weak_final]-1.5) < 0.5 # order is 1.55
126126
println("RDI2WM:", sim.𝒪est[:weak_final])
127127

128128
numtraj = Int(5e4)

0 commit comments

Comments
 (0)