Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI TRIGGER #184

Closed
wants to merge 6 commits into from
Closed
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
12 changes: 6 additions & 6 deletions ext/DiffEqNoiseProcessReverseDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ using DiffEqNoiseProcess, DiffEqBase, Random
isdefined(Base, :get_extension) ? (import ReverseDiff) : (import ..ReverseDiff)

@inline function DiffEqNoiseProcess.wiener_randn(rng::Random.AbstractRNG,
proto::ReverseDiff.TrackedArray)
proto::ReverseDiff.TrackedArray)
ReverseDiff.track(convert.(eltype(proto.value), randn(rng, size(proto))))
end
@inline function DiffEqNoiseProcess.wiener_randn!(rng::AbstractRNG,
rand_vec::Array{<:ReverseDiff.TrackedReal
})
rand_vec::Array{<:ReverseDiff.TrackedReal
})
rand_vec .= ReverseDiff.track.(randn.((rng,), typeof.(DiffEqBase.value.(rand_vec))))
end
@inline function DiffEqNoiseProcess.wiener_randn!(rng::AbstractRNG,
rand_vec::AbstractArray{
<:ReverseDiff.TrackedReal,
})
rand_vec::AbstractArray{
<:ReverseDiff.TrackedReal,
})
rand_vec .= ReverseDiff.track.(randn.((rng,), typeof.(DiffEqBase.value.(rand_vec))))
end

Expand Down
4 changes: 2 additions & 2 deletions src/bridges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function BrownianBridge!(t0, tend, W0, Wh, Z0 = nothing, Zh = nothing; kwargs...
end

function GeometricBrownianBridge(μ, σ, t0, tend, W0, Wend, Z0 = nothing, Zend = nothing;
kwargs...)
kwargs...)
W = GeometricBrownianMotionProcess(μ, σ, t0, W0, Z0; kwargs...)
h = tend - t0
Wh = Wend - W0
Expand All @@ -66,7 +66,7 @@ function GeometricBrownianBridge(μ, σ, t0, tend, W0, Wend, Z0 = nothing, Zend
end

function GeometricBrownianBridge!(μ, σ, t0, tend, W0, Wh, Z0 = nothing, Zh = nothing;
kwargs...)
kwargs...)
W = GeometricBrownianMotionProcess!(μ, σ, t0, W0, Z0; kwargs...)
h = tend - t0
Wh .-= W0
Expand Down
2 changes: 1 addition & 1 deletion src/copy_noise_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Base.copy(W::SimpleNoiseProcess)
end

function Base.copy(W::Union{NoiseWrapper, NoiseGrid, NoiseApproximation,
VirtualBrownianTree, BoxWedgeTail})
VirtualBrownianTree, BoxWedgeTail})
Wnew = typeof(W)((getfield(W, x) for x in fieldnames(typeof(W)))...)
copy!(Wnew, W)
end
Expand Down
4 changes: 2 additions & 2 deletions src/correlated_noisefunc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CorrelatedWienerProcess!(Γ,t0,W0,Z0=nothing;kwargs...)
where `Γ` is the constant covariance matrix.
"""
function CorrelatedWienerProcess(Γ, t0, W0, Z0 = nothing;
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)))
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)))
NoiseProcess{false}(t0, W0, Z0, construct_correlated_noisefunc(Γ)..., rswm = RSWM(),
rng = rng)
end
Expand Down Expand Up @@ -58,7 +58,7 @@ CorrelatedWienerProcess!(Γ,t0,W0,Z0=nothing;kwargs...)
where `Γ` is the constant covariance matrix.
"""
function CorrelatedWienerProcess!(Γ, t0, W0, Z0 = nothing;
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)))
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)))
NoiseProcess{true}(t0, W0, Z0, construct_correlated_noisefunc!(Γ)...,
rswm = RSWM(), rng = rng)
end
4 changes: 2 additions & 2 deletions src/geometric_bm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
rand_val = wiener_randn(rng, typeof(dW))
end
new_val = @.. exp(drift * dt + X.σ * sqrt(dt) * rand_val)
return W[end] * (new_val - 1)
return W.u[end] * (new_val - 1)

Check warning on line 14 in src/geometric_bm.jl

View check run for this annotation

Codecov / codecov/patch

src/geometric_bm.jl#L14

Added line #L14 was not covered by tests
end

#=
Expand Down Expand Up @@ -69,7 +69,7 @@
end
function (X::GeometricBrownianMotion!)(rand_vec, W, dt, u, p, t, rng) #dist!
wiener_randn!(rng, rand_vec)
@.. rand_vec = W[end] * expm1(X.μ - (1 / 2) * X.σ * dt + X.σ * sqrt(dt) * rand_vec)
@.. rand_vec = W.u[end] * expm1(X.μ - (1 / 2) * X.σ * dt + X.σ * sqrt(dt) * rand_vec)

Check warning on line 72 in src/geometric_bm.jl

View check run for this annotation

Codecov / codecov/patch

src/geometric_bm.jl#L72

Added line #L72 was not covered by tests
end

@doc doc"""
Expand Down
2 changes: 1 addition & 1 deletion src/noise_interfaces/box_wedge_tail_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function generate_boxes1(densf, Δr, Δa, Δz, rM, aM, offset = nothing, scale =
end

function generate_boxes2(densf, Δrmin, Δamin, Δzmin, Δrmax, Δamax, Δzmax, rM, aM,
offset = nothing)
offset = nothing)
boxes = Array{typeof(Δrmin), 1}[]
probability = Vector{typeof(Δrmin)}(undef, 0)
# start with largest possible size, then subsequently decrease size and fill remaining space
Expand Down
42 changes: 21 additions & 21 deletions src/noise_interfaces/common.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
DiffEqBase.has_reinit(i::AbstractNoiseProcess) = true
function DiffEqBase.reinit!(W::Union{NoiseProcess, NoiseApproximation}, dt;
t0 = W.t[1],
erase_sol = true,
setup_next = false)
t0 = W.t[1],
erase_sol = true,
setup_next = false)
if erase_sol
resize!(W.t, 1)
resize!(W.W, 1)
Expand Down Expand Up @@ -55,9 +55,9 @@ function DiffEqBase.reinit!(W::Union{NoiseProcess, NoiseApproximation}, dt;
end

function DiffEqBase.reinit!(W::VirtualBrownianTree, dt;
t0 = W.t[1],
erase_sol = false,
setup_next = true)
t0 = W.t[1],
erase_sol = false,
setup_next = true)

# Back to noise's starting state
W.curt = first(W.t)
Expand Down Expand Up @@ -88,9 +88,9 @@ function DiffEqBase.reinit!(W::VirtualBrownianTree, dt;
end

function DiffEqBase.reinit!(W::NoiseGrid, dt;
t0 = W.t[1],
erase_sol = true,
setup_next = false)
t0 = W.t[1],
erase_sol = true,
setup_next = false)
W.curt = t0
W.dt = dt
if t0 == W.t[1]
Expand Down Expand Up @@ -119,9 +119,9 @@ function DiffEqBase.reinit!(W::NoiseGrid, dt;
end

function DiffEqBase.reinit!(W::AbstractNoiseProcess, dt;
t0 = W.t[1],
erase_sol = true,
setup_next = false)
t0 = W.t[1],
erase_sol = true,
setup_next = false)
W.curt = t0
W.dt = dt

Expand All @@ -130,9 +130,9 @@ function DiffEqBase.reinit!(W::AbstractNoiseProcess, dt;
end

function DiffEqBase.reinit!(W::NoiseFunction, dt;
t0 = W.t0,
erase_sol = true,
setup_next = false)
t0 = W.t0,
erase_sol = true,
setup_next = false)
W.curt = t0
W.dt = dt

Expand All @@ -156,9 +156,9 @@ function DiffEqBase.reinit!(W::NoiseFunction, dt;
end

function DiffEqBase.reinit!(W::NoiseTransport, dt;
t0 = W.t0,
erase_sol = true,
setup_next = false)
t0 = W.t0,
erase_sol = true,
setup_next = false)
W.curt = t0
W.dt = dt

Expand Down Expand Up @@ -188,9 +188,9 @@ function DiffEqBase.reinit!(W::NoiseTransport, dt;
end

function DiffEqBase.reinit!(W::NoiseWrapper, dt;
t0 = W.t[1],
erase_sol = true,
setup_next = false)
t0 = W.t[1],
erase_sol = true,
setup_next = false)
W.curt = t0
W.dt = dt

Expand Down
6 changes: 3 additions & 3 deletions src/noise_interfaces/virtual_brownian_tree_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ end

# create the cache of the VBT with depth tree_depth
function create_VBT_cache(bridge, t0, W0, Z0, tend, Wend, Zend, rng::Random123.AbstractR123,
tree_depth, search_depth)
tree_depth, search_depth)
# total number of cached time steps and W values
Nt = Int(2^search_depth + 1)

Expand Down Expand Up @@ -230,7 +230,7 @@ function create_VBT_cache(bridge, t0, W0, Z0, tend, Wend, Zend, rng::Random123.A
end

function search_VBT(t, seed, t0, t1, W0, W1, Z0, Z1, W::VirtualBrownianTree,
rng::Random123.AbstractR123)
rng::Random123.AbstractR123)
Nt = Int(2^W.search_depth + 1)
depth = Int(W.tree_depth + 1)
seed_l, seed_r, seed_v = split_VBT_seed(rng, seed, depth, Nt)
Expand Down Expand Up @@ -286,7 +286,7 @@ function search_VBT(t, seed, t0, t1, W0, W1, Z0, Z1, W::VirtualBrownianTree,
end

function search_VBT!(out1, out2, t, seed, t0, t1, W0, W1, Z0, Z1, W::VirtualBrownianTree,
rng::Random123.AbstractR123)
rng::Random123.AbstractR123)
Nt = Int(2^W.search_depth + 1)
depth = Int(W.tree_depth + 1)
seed_l, seed_r, seed_v = split_VBT_seed(rng, seed, depth, Nt)
Expand Down
6 changes: 3 additions & 3 deletions src/pCN.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ External links
* [Preconditioned Crank–Nicolson algorithm on Wikipedia](https://en.wikipedia.org/wiki/Preconditioned_Crank–Nicolson_algorithm)
"""
function pCN!(source::AbstractNoiseProcess{T, N, Vector{T2}, inplace}, ρ;
reset = true, reverse = false, indx = nothing) where {T, N, T2, inplace}
reset = true, reverse = false, indx = nothing) where {T, N, T2, inplace}

# generate new Wiener process similar to the one in source
Wnew = generate_innovation(source.W[1], source.t, source.rng)
Expand All @@ -40,7 +40,7 @@ end
Create a new, but correlated noise process from `noise` and additional entropy with correlation ρ.
"""
function pCN(source::AbstractNoiseProcess{T, N, Vector{T2}, inplace}, ρ;
reset = true, reverse = false, indx = nothing) where {T, N, T2, inplace}
reset = true, reverse = false, indx = nothing) where {T, N, T2, inplace}
source′ = deepcopy(source)

# generate new Wiener process similar to the one in source
Expand All @@ -62,7 +62,7 @@ External links
- [Preconditioned Crank–Nicolson algorithm on Wikipedia](https://en.wikipedia.org/wiki/Preconditioned_Crank%E2%80%93Nicolson_algorithm)
"""
function pCN(source::NoiseGrid, ρ; reset = true,
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)))
rng = Xorshifts.Xoroshiro128Plus(rand(UInt64)))

# generate new Wiener process similar to the one in source
t = source.t
Expand Down
4 changes: 2 additions & 2 deletions src/rswm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ mutable struct RSWM{T}
end

Base.@pure function RSWM(;
discard_length = 1e-15,
adaptivealg::Symbol = :RSwM3)
discard_length = 1e-15,
adaptivealg::Symbol = :RSwM3)
RSWM{typeof(discard_length)}(discard_length, adaptivealg)
end

Expand Down
4 changes: 2 additions & 2 deletions src/solve.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function DiffEqBase.__solve(prob::AbstractNoiseProblem,
args::Union{Nothing, SciMLBase.DEAlgorithm}...; dt = 0.0,
kwargs...)
args::Union{Nothing, SciMLBase.DEAlgorithm}...; dt = 0.0,
kwargs...)
if dt == 0.0 || dt == nothing
error("dt must be provided to simulate a noise process. Please pass dt=...")
end
Expand Down
Loading
Loading