From 438a5cf7f7c13b80637713028953db4be6a65413 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Argos=29?=
 <stepan@adjemian.eu>
Date: Thu, 19 Sep 2024 16:15:32 +0200
Subject: [PATCH] Save the weights of the particle swarm is not resampled.

---
 matlab/estimation/smc/hssmc.m | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/matlab/estimation/smc/hssmc.m b/matlab/estimation/smc/hssmc.m
index 84e0277ed..d47518744 100644
--- a/matlab/estimation/smc/hssmc.m
+++ b/matlab/estimation/smc/hssmc.m
@@ -107,8 +107,12 @@ function mdd = hssmc(TargetFun, mh_bounds, dataset_, dataset_info, options_, M_,
             iresample = kitagawa(weights);
             particles = particles(:,iresample);
         end
-        save(sprintf('%s%sparticles-%u-%u.mat', SimulationFolder, filesep(), i, smcopt.steps), 'particles', 'tlogpostkernel', 'loglikelihood')
-        resampled_particle_swarm = false;
+        if resampled_particle_swarm
+            save(sprintf('%s%sparticles-%u-%u.mat', SimulationFolder, filesep(), i, smcopt.steps), 'particles', 'tlogpostkernel', 'loglikelihood')
+            resampled_particle_swarm = false;
+        else
+            save(sprintf('%s%sparticles-%u-%u.mat', SimulationFolder, filesep(), i, smcopt.steps), 'particles', 'tlogpostkernel', 'loglikelihood', 'weights')
+        end
     end
 
 end
-- 
GitLab