22
22
23
23
function instantiate (:: HierarchicalSSM{T} , filter:: RBPF , initial; kwargs... ) where {T}
24
24
N = filter. N
25
- return ParticleIntermediate (initial, deepcopy ( initial) , Vector {Int} (undef, N))
25
+ return ParticleIntermediate (initial, initial, Vector {Int} (undef, N))
26
26
end
27
27
28
28
function initialise (
@@ -56,7 +56,8 @@ function predict(
56
56
new_particles = map (
57
57
x -> marginal_predict (rng, model, algo, t, x; kwargs... ), filtered. particles
58
58
)
59
- proposed = ParticleDistribution (new_particles, deepcopy (filtered. log_weights))
59
+ # Don't need to deepcopy weights as filtered will be overwritten in the update step
60
+ proposed = ParticleDistribution (new_particles, filtered. log_weights)
60
61
61
62
return update_ref! (proposed, ref_state, t)
62
63
end
156
157
157
158
function instantiate (model:: HierarchicalSSM , algo:: BatchRBPF , initial; kwargs... )
158
159
N = algo. N
159
- return ParticleIntermediate (initial, deepcopy ( initial) , CuArray {Int} (undef, N))
160
+ return ParticleIntermediate (initial, initial, CuArray {Int} (undef, N))
160
161
end
161
162
162
163
function initialise (
@@ -205,8 +206,9 @@ function predict(
205
206
new_outer= new_xs,
206
207
kwargs... ,
207
208
)
209
+ # Don't need to deepcopy weights as filtered will be overwritten in the update step
208
210
proposed = RaoBlackwellisedParticleDistribution (
209
- BatchRaoBlackwellisedParticles (new_xs, new_zs), deepcopy ( filtered. log_weights)
211
+ BatchRaoBlackwellisedParticles (new_xs, new_zs), filtered. log_weights
210
212
)
211
213
212
214
# return states
@@ -232,8 +234,9 @@ function update(
232
234
)
233
235
234
236
new_weights = proposed. log_weights + inner_lls
237
+ # Don't need to deepcopy particles as update will be overwritten in the next step
235
238
filtered = RaoBlackwellisedParticleDistribution (
236
- BatchRaoBlackwellisedParticles (deepcopy ( proposed. particles. xs) , new_zs), new_weights
239
+ BatchRaoBlackwellisedParticles (proposed. particles. xs, new_zs), new_weights
237
240
)
238
241
239
242
step_ll = logsumexp (filtered. log_weights) - logsumexp (proposed. log_weights)
0 commit comments