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

View File

@@ -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;
/**

View File

@@ -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:

View File

@@ -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;
}

View File

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