Skip to content
Merged
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
9 changes: 5 additions & 4 deletions src/container.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
struct Trace{F,U,N,V<:Random123.AbstractR123{U}}
struct Trace{F,R<:TracedRNG}
f::F
ctask::Libtask.CTask
rng::TracedRNG{U,N,V}
rng::R
end

const Particle = Trace
Expand Down Expand Up @@ -95,13 +95,13 @@ Data structure for particle filters
- normalise!(pc::ParticleContainer)
- consume(pc::ParticleContainer): return incremental likelihood
"""
mutable struct ParticleContainer{T<:Particle,U,N,V<:Random123.AbstractR123{U}}
mutable struct ParticleContainer{T<:Particle,R<:TracedRNG}
"Particles."
vals::Vector{T}
"Unnormalized logarithmic weights."
logWs::Vector{Float64}
"Traced RNG to replay the resampling step"
rng::TracedRNG{U,N,V}
rng::R
end

function ParticleContainer(particles::Vector{<:Particle})
Expand Down Expand Up @@ -207,6 +207,7 @@ function update_keys!(pc::ParticleContainer, ref::Union{Particle,Nothing}=nothin
k = split(pi.rng.rng.key)
Random.seed!(pi.rng, k[1])
end
return nothing
end

"""
Expand Down
2 changes: 1 addition & 1 deletion test/container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Create a resumable function that always returns the same log probability.
function fpc(logp)
f = let logp = logp
(rng) -> begin
rng -> begin
while true
produce(logp)
end
Expand Down