Skip to content

Commit c796361

Browse files
committed
Bug Fix: Total particle weight becomes zero leading to infinity weights of particles during further resampling
1 parent 8c433b8 commit c796361

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/core/belief.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,16 @@ void ParticleBelief::Update(int action, OBS_TYPE obs) {
383383
for (int i = 0; i < initial_particles_.size(); i ++)
384384
particles_.push_back(model_->Copy(initial_particles_[i]));
385385
}
386+
387+
//Update total weight so that effective number of particles are computed correctly
388+
total_weight = 0;
389+
for (int i = 0; i < particles_.size(); i++) {
390+
State* particle = particles_[i];
391+
total_weight = total_weight + particle->weight;
392+
}
386393
}
387394

395+
388396
double weight_square_sum = 0;
389397
for (int i = 0; i < particles_.size(); i++) {
390398
State* particle = particles_[i];

0 commit comments

Comments
 (0)