small changes so it works with yasmin

This commit is contained in:
toni
2018-07-19 10:29:51 +02:00
parent 74a424b555
commit db7c0e310e
5 changed files with 19 additions and 23 deletions

View File

@@ -73,15 +73,15 @@ namespace NM {
// is above destination reachable? // is above destination reachable?
if (dstTria) { if (dstTria) {
re.heading = params.heading; // heading was OK -> keep re.heading = params.heading; // heading was OK -> keep
re.location.pos = dstTria->toPoint3(dst); // new destination position re.location.pos = dstTria->toPoint3(dst); // new destination position
re.location.tria = dstTria; // new destination triangle re.location.tria = dstTria; // new destination triangle
++hits; ++hits;
} else { } else {
NavMeshRandom<Tria> rnd = reachable.getRandom(); // random-helper NavMeshRandom<Tria> rnd = reachable.getRandom(); // random-helper
re.location = rnd.draw(); // get a random destianation re.location = rnd.draw(); // get a random destianation
re.heading = Heading(params.start.pos.xy(), re.location.pos.xy()); // update the heading re.heading = Heading(params.start.pos.xy(), re.location.pos.xy()); // update the heading
++misses; ++misses;

View File

@@ -24,10 +24,10 @@ namespace SMC {
public: public:
/** /**
* perform resampling on the given particle-vector * perform resampling on the given particle-vector
* @param particles the vector of all particles to resample * @param particles the vector of all particles to resample
*/ */
virtual void resample(std::vector<Particle<State>>& particles) = 0; virtual void resample(std::vector<Particle<State>>& particles) = 0;
/** /**

View File

@@ -42,29 +42,25 @@ namespace SMC {
// to-be-removed region // to-be-removed region
const int start = particles.size() * (1-percent); const int start = particles.size() * (1-percent);
const int end = particles.size(); const int end = particles.size();
std::uniform_int_distribution<int> dist(0, start-1); std::uniform_int_distribution<int> dist(0, start-1);
// remove by re-drawing // remove by re-drawing
for (uint32_t i = start; i < end; ++i) { for (uint32_t i = start; i < end; ++i) {
const int rnd = dist(gen); const int rnd = dist(gen);
particles[i] = particles[rnd]; particles[i] = particles[rnd];
particles[i].weight /= 2; //particles[i].weight /= 2;
particles[rnd].weight /= 2; //particles[rnd].weight /= 2;
} }
// calculate weight-sum // calculate weight-sum
double weightSum = 0; double weightSum = 0;
for (const auto& p : particles) { double equalweight = 1.0 / (double) cnt;
for (auto& p : particles) {
weightSum += p.weight; weightSum += p.weight;
p.weight = equalweight;
} }
int i = 0;
} }
private: private:

View File

@@ -77,8 +77,8 @@ namespace SMC {
// slight chance to get a truely random particle in range X m // slight chance to get a truely random particle in range X m
if (distNewOne(gen) < 0.001) { if (distNewOne(gen) < 0.001) {
const double radius = 50.0; const double radius = 50.0;
const NM::NavMeshSub<Tria> reachable(particlesCopy[i].state.pos, radius); const NM::NavMeshSub<Tria> reachable(particlesCopy[i].state.loc, radius);
particles[i].state.pos = reachable.getRandom().drawWithin(particlesCopy[i].state.pos.pos, radius); particles[i].state.loc = reachable.getRandom().drawWithin(particlesCopy[i].state.loc.pos, radius);
particles[i].weight = equalWeight; particles[i].weight = equalWeight;
continue; continue;
} }

View File

@@ -2,7 +2,7 @@
#include <fstream> #include <fstream>
#include "../../Tests.h" #include "../../Tests.h"
#include "../../../math/dsp/FIRComplex.h" #include "../../../math/dsp/fir/Complex.h"
#include <random> #include <random>