small changes so it works with yasmin
This commit is contained in:
@@ -24,10 +24,10 @@ namespace SMC {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* perform resampling on the given particle-vector
|
||||
* @param particles the vector of all particles to resample
|
||||
*/
|
||||
/**
|
||||
* perform resampling on the given particle-vector
|
||||
* @param particles the vector of all particles to resample
|
||||
*/
|
||||
virtual void resample(std::vector<Particle<State>>& particles) = 0;
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,29 +42,25 @@ namespace SMC {
|
||||
|
||||
|
||||
// to-be-removed region
|
||||
const int start = particles.size() * (1-percent);
|
||||
const int end = particles.size();
|
||||
const int start = particles.size() * (1-percent);
|
||||
const int end = particles.size();
|
||||
std::uniform_int_distribution<int> dist(0, start-1);
|
||||
|
||||
// remove by re-drawing
|
||||
for (uint32_t i = start; i < end; ++i) {
|
||||
const int rnd = dist(gen);
|
||||
particles[i] = particles[rnd];
|
||||
particles[i].weight /= 2;
|
||||
particles[rnd].weight /= 2;
|
||||
//particles[i].weight /= 2;
|
||||
//particles[rnd].weight /= 2;
|
||||
}
|
||||
|
||||
// calculate weight-sum
|
||||
double weightSum = 0;
|
||||
for (const auto& p : particles) {
|
||||
double equalweight = 1.0 / (double) cnt;
|
||||
for (auto& p : particles) {
|
||||
weightSum += p.weight;
|
||||
p.weight = equalweight;
|
||||
}
|
||||
|
||||
|
||||
int i = 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -77,8 +77,8 @@ namespace SMC {
|
||||
// slight chance to get a truely random particle in range X m
|
||||
if (distNewOne(gen) < 0.001) {
|
||||
const double radius = 50.0;
|
||||
const NM::NavMeshSub<Tria> reachable(particlesCopy[i].state.pos, radius);
|
||||
particles[i].state.pos = reachable.getRandom().drawWithin(particlesCopy[i].state.pos.pos, radius);
|
||||
const NM::NavMeshSub<Tria> reachable(particlesCopy[i].state.loc, radius);
|
||||
particles[i].state.loc = reachable.getRandom().drawWithin(particlesCopy[i].state.loc.pos, radius);
|
||||
particles[i].weight = equalWeight;
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user