Skip to content

Commit 3b0f81d

Browse files
authored
Merge pull request #99 from mschauer/newversion
Newversion
2 parents ba3e25d + ef73b25 commit 3b0f81d

14 files changed

+1072
-437
lines changed

scripts/diffbridge_bis.jl

-108
This file was deleted.

src/dynamics.jl

+7-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ end
1818
# This one could work for Boomerang 1d as well
1919
"""
2020
move_forward!(τ, t, x, θ, B::Boomerang)
21+
2122
Updates the position `x`, velocity `θ` and time `t` of the
2223
process after a time step equal to `τ` according to the deterministic
2324
dynamics of the `Boomerang` sampler which are the Hamiltonian
@@ -35,11 +36,12 @@ function move_forward!(τ, t, x, θ, B::Union{Boomerang, FactBoomerang})
3536
end
3637

3738
"""
38-
reflect!(i, x, θ, F)
39+
reflect!(i, ∇ϕx, x, θ, F)
3940
40-
Reflection rule of sampler `F` at reflection time.
41+
Reflection rule of sampler `F` at reflection time, `∇ϕx`: inner product
42+
of `∇ϕ` and `x``.
4143
`i`: coordinate which flips sign, `x`: position, `θ`: velocity (position
42-
not used for the `ZigZag` and `FactBoomerang`.)
44+
and inner product not used for the `ZigZag` and `FactBoomerang`.)
4345
"""
4446
function reflect!(i, ∇ϕx::Number, x, θ, F::Union{ZigZag, FactBoomerang})
4547
θ[i] = -θ[i]
@@ -80,10 +82,10 @@ function move_forward(τ, t, x, θ, B::Boomerang1d)
8082
end
8183

8284
"""
83-
reflect!(∇ϕx, θ, F::BouncyParticle, Boomerang)
85+
reflect!(∇ϕx, x, θ, F::BouncyParticle, Boomerang)
8486
8587
Reflection rule of sampler `F` at reflection time.
86-
x`: position, `θ`: velocity
88+
`x`: position, `θ`: velocity
8789
"""
8890
function reflect!(∇ϕx, x, θ, F::BouncyParticle)
8991
θ .-= (2*dot(∇ϕx, θ)/normsq(F.L\∇ϕx))*(F.L'\(F.L\∇ϕx))

src/fact_samplers.jl

+1-9
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ end
3131

3232

3333
"""
34-
λ(∇ϕ, i, x, θ, Z::FactBoomerang)
34+
λ(∇ϕi, i, x, θ, Z::FactBoomerang)
3535
`i`th Poisson rate of the `FactBoomerang` sampler
3636
"""
3737
function λ(∇ϕi, i, x, θ, B::FactBoomerang)
@@ -69,14 +69,6 @@ function adapt!(c, i, factor)
6969
c
7070
end
7171

72-
"""
73-
λ_bar(G, i, x, θ, c, Z)
74-
75-
Computes the bounding rate `λ_bar` at position `x` and velocity `θ`.
76-
"""
77-
#λ_bar(G, i, x, θ, c, Z::ZigZag) = pos(ab(G, i, x, θ, c, Z)[1])
78-
#λ_bar(G, i, x, θ, c, Z::FactBoomerang) = pos(ab(G, i, x, θ, c, Z)[1])
79-
8072

8173
function event(i, t, x, θ, Z::Union{ZigZag,FactBoomerang,JointFlow})
8274
t, i, x[i], θ[i]

src/local.jl

-18
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,7 @@ function ab(G, i, x, θ, C::LocalBound, ∇ϕi, vi, Z::ZigZag, args...)
66
end
77
#(idot(Z.Γ, i, x) - idot(Z.Γ, i, Z.μ))'*θ[i]), θ[i]'*idot(Z.Γ, i, θ)
88

9-
"""
10-
spdmp_inner!(rng, G, G1, G2, ∇ϕ, t, x, θ, Q, c, b, t_old, (acc, num),
11-
F::Union{ZigZag,FactBoomerang}, args...; factor=1.5, adapt=false, adaptscale=false)
12-
13-
[Outdated]
14-
Inner loop of the factorised samplers: the factorised Boomerang algorithm and
15-
the Zig-Zag sampler. Given a dependency graph `G`, gradient `∇ϕ`,
16-
current position `x`, velocity `θ`, Queue of events `Q`, time `t`, tuning parameter `c`,
17-
terms of the affine bounds `a`,`b` and time when the upper bounds were computed `t_old`
189

19-
The sampler 1) extracts from the queue the first event time. 2) moves deterministically
20-
according to its dynamics until event time. 3) Evaluates whether the event
21-
time is a accepted reflection or refreshment time or shadow time. 4) If it is a
22-
reflection time, the velocity reflects according its reflection rule, if it is a
23-
refreshment time, the sampler updates the velocity from its prior distribution (Gaussian).
24-
In both cases, updates `Q` according to the dependency graph `G`. The sampler proceeds
25-
until the next accepted reflection time or refreshment time. `(num, acc)`
26-
incrementally counts how many event times occour and how many of those are real reflection times.
27-
"""
2810
function spdmp_inner!(rng, G, G2, ∇ϕ, t, x, θ, Q, c::LocalBound, (b, renew), t_old, (acc, num),
2911
F::Union{ZigZag,FactBoomerang,JointFlow}, args...; factor=1.5, adapt=false, adaptscale=false)
3012
n = length(x)

src/sfact.jl

-19
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,6 @@ sλ(∇ϕi, i, x, θ, Z::Union{ZigZag,FactBoomerang,JointFlow}) = λ(∇ϕi, i,
7070
sλ̄(abc, Δt) = pos(abc[1] + abc[2]*Δt)
7171

7272

73-
"""
74-
spdmp_inner!(rng, G, G1, G2, ∇ϕ, t, x, θ, Q, c, b, t_old, (acc, num),
75-
F::Union{ZigZag,FactBoomerang}, args...; factor=1.5, adapt=false, adaptscale=false)
76-
77-
[Outdated]
78-
Inner loop of the factorised samplers: the factorised Boomerang algorithm and
79-
the Zig-Zag sampler. Given a dependency graph `G`, gradient `∇ϕ`,
80-
current position `x`, velocity `θ`, Queue of events `Q`, time `t`, tuning parameter `c`,
81-
terms of the affine bounds `a`,`b` and time when the upper bounds were computed `t_old`
82-
83-
The sampler 1) extracts from the queue the first event time. 2) moves deterministically
84-
according to its dynamics until event time. 3) Evaluates whether the event
85-
time is a accepted reflection or refreshment time or shadow time. 4) If it is a
86-
reflection time, the velocity reflects according its reflection rule, if it is a
87-
refreshment time, the sampler updates the velocity from its prior distribution (Gaussian).
88-
In both cases, updates `Q` according to the dependency graph `G`. The sampler proceeds
89-
until the next accepted reflection time or refreshment time. `(num, acc)`
90-
incrementally counts how many event times occour and how many of those are real reflection times.
91-
"""
9273
function spdmp_inner!(rng, G, G1, G2, ∇ϕ, t, x, θ, Q, c, b, t_old, (acc, num),
9374
F::Union{ZigZag,FactBoomerang}, args...; factor=1.5, adapt=false, adaptscale=false)
9475
n = length(x)

src/trace.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct FactTrace{FT,T,S,S2,R} <: Trace
1313
end
1414

1515
"""
16-
FactTrace
16+
PDMPTrace
1717
1818
See [`Trace`](@ref).
1919
"""

src/types.jl

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct Boomerang{U, T, S, LT} <: ContinuousDynamics
5757
L::LT
5858
end
5959
Boomerang(Γ, μ, λ; ρ=0.0) = Boomerang(Γ, μ, λ, ρ, (cholesky(Symmetric(Γ)).L))
60+
6061
"""
6162
FactBoomerang(Γ, μ, λ) <: ContinuousDynamics
6263

0 commit comments

Comments
 (0)