statistic helper classes

test-cases
modified grid importance for better trap-detection
This commit is contained in:
2016-10-01 13:17:14 +02:00
parent 729340031d
commit 51c0945e12
15 changed files with 343 additions and 64 deletions

View File

@@ -6,6 +6,7 @@
#include "../../../math/DrawList.h"
#include "modules/WalkModule.h"
#include "../../../math/Distributions.h"
#include "../../../math/Stats.h"
/**
* modular grid-walker that takes various sub-components to determine
@@ -28,6 +29,16 @@ public:
}
/** perform the walk based on the configured setup */
WalkState getDestination(Grid<Node>& grid, const WalkState& _startState, const float _dist_m) {
double tmp; // ignored
return getDestination(grid, _startState, _dist_m, tmp);
}
/**
* perform the walk based on the configured setup
* returns the walks overall probability using the out-parameter
*/
WalkState getDestination(Grid<Node>& grid, const WalkState& _startState, const float _dist_m, double& probability) {
Assert::isTrue(_dist_m >= 0, "walk distance must not be negative!");
@@ -53,8 +64,7 @@ public:
// add the previous walked-distance-error to the desired distance (is usually negative, thus dist_m is reduced)
float dist_m = _dist_m + _startState.distance.error_m;
probability = 1.0;
int cnt = 0;
Stats::Maximum<double> maxEdgeProb;
// until distance is reached
while (dist_m > 0) {
@@ -71,12 +81,13 @@ public:
for (const Node& neighbor : grid.neighbors(*curNode)) {
const double prob = getProbability(currentState, *startNode, *curNode, neighbor);
drawer.add(&neighbor, prob);
maxEdgeProb.add(prob);
}
// pick a neighbor and get its probability
double nodeProbability;
const Node* nextNode = drawer.get(nodeProbability);
if ( nodeProbability < probability ) {probability = nodeProbability;} // keep the smallest one
//double nodeProbability;
const Node* nextNode = drawer.get();
//if ( nodeProbability < probability ) {probability = nodeProbability;} // keep the smallest one
//probability += nodeProbability;
//++cnt;
@@ -91,7 +102,10 @@ public:
}
//if (cnt != 0) {probability /= cnt;} else {probability = 1.0;}
probability *= curNode->getWalkImportance() < 0.4f ? (1e-5) : (1.0); // "kill" particles that walk near walls (most probably trapped ones)
probability = 1.0;
//probability = (maxEdgeProb.isValid()) ? (maxEdgeProb.get()) : (1.0); // dist_m might be zero -> no edges -> no maximum
probability *= curNode->getWalkImportance();// < 0.4f ? (0.1) : (1.0); // "kill" particles that walk near walls (most probably trapped ones)
//probability = std::pow(probability, 5);
// update after
updateAfter(currentState, *startNode, *curNode);