Skip to content

Commit 04faf23

Browse files
authored
Merge pull request #105 from mschauer/tilde
Add iterator for tilde
2 parents 94f8fa2 + 9a89d60 commit 04faf23

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/notfactiter.jl

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ function iterate(FS::NotFactSampler)
3030
t, x, θ, ∇ϕx = t0, copy(x0), copy(θ0), copy(θ0)
3131
c = FS.c
3232
rng = FS.rng
33-
Ξ = Trace(t0, x0, θ0, Flow)
3433
τref = waiting_time_ref(rng, Flow)
3534
∇ϕx, v = FS.∇ϕ!(∇ϕx, t, x, θ, FS.args...)
3635
∇ϕx = grad_correct!(∇ϕx, x, Flow)
@@ -50,3 +49,38 @@ function iterate(FS::NotFactSampler, (u, ∇ϕx, (acc, num), c, abc, (t′, ren
5049
u = t => (x, θ)
5150
return ev, (u, ∇ϕx, (acc, num), c, abc, (t′, renew), τref, v)
5251
end
52+
53+
function rawevent(t, x, θ, Z::Union{BouncyParticle,Boomerang})
54+
t, x, θ, nothing
55+
end
56+
57+
58+
function iterate(FS::NotFactSampler{<:Any, <:Tuple})
59+
t0, (x0, θ0) = FS.u0
60+
Flow = FS.F
61+
n = length(x0)
62+
t, x, θ, ∇ϕx = t0, copy(x0), copy(θ0), copy(θ0)
63+
c = FS.c
64+
rng = FS.rng
65+
τref = waiting_time_ref(rng, Flow)
66+
67+
68+
dϕ, ∇ϕ! = FS.∇ϕ![1], FS.∇ϕ![2]
69+
θdϕ, v = (t, x, θ, FS.args...)
70+
num = acc = 0
71+
abc = ab(x, θ, c, θdϕ, v, Flow)
72+
73+
t′, renew = next_time(t, abc, rand(rng))
74+
iterate(FS, ((t => (x, θ)), ∇ϕx, (acc, num), c, abc, (t′, renew), τref, v))
75+
end
76+
77+
78+
function iterate(FS::NotFactSampler{<:Any, <:Tuple}, (u, ∇ϕx, (acc, num), c, abc, (t′, renew), τref, v))
79+
t, (x, θ) = u
80+
dϕ, ∇ϕ! = FS.∇ϕ![1], FS.∇ϕ![2]
81+
t, x, θ, (acc, num), c, abc, (t′, renew), τref, v = pdmp_inner!(FS.rng, dϕ, ∇ϕ!, ∇ϕx, t, x, θ, c, abc, (t′, renew), τref, v, (acc, num), FS.F, FS.args...; FS.kargs...)
82+
83+
ev = rawevent(t, x, θ, FS.F)
84+
u = t => (x, θ)
85+
return ev, (u, ∇ϕx, (acc, num), c, abc, (t′, renew), τref, v)
86+
end

0 commit comments

Comments
 (0)