removed heading::rnd (not seedable)

fixed grid-walker issues when conducting multiple runs
new helper methods for the interpolatorr
This commit is contained in:
2016-04-26 11:49:12 +02:00
parent 6d3d2eeb55
commit 8f6bfa917f
4 changed files with 32 additions and 16 deletions

View File

@@ -64,13 +64,13 @@ public:
float getRAD() const {return rad;}
/** get a random heading */
static Heading rnd() {
static std::minstd_rand gen(1234);
static std::uniform_real_distribution<float> dist(0, _2PI);
const float rnd = dist(gen);
return Heading(rnd);
}
// /** get a random heading */
// static Heading rnd() {
// static std::minstd_rand gen(1234);
// static std::uniform_real_distribution<float> dist(0, _2PI);
// const float rnd = dist(gen);
// return Heading(rnd);
// }
#undef _2PI

View File

@@ -61,18 +61,22 @@ public:
}
Distribution::Normal<float> dHead = Distribution::Normal<float>(1, 0.01);
Distribution::Normal<float> dWalk = Distribution::Normal<float>(1, 0.10);
Distribution::Normal<float> sWalk = Distribution::Normal<float>(0, 0.15);
GridWalkState<T> getDestination(Grid<T>& grid, const GridWalkState<T>& start, float distance_m, float headChange_rad, Activity act) {
// proportional change of the heading
static Distribution::Normal<float> dHead(1, 0.01);
//static Distribution::Normal<float> dHead(1, 0.01);
// proportional change of the to-be-walked distance
static Distribution::Normal<float> dWalk(1, 0.10);
//static Distribution::Normal<float> dWalk(1, 0.10);
distance_m = distance_m*dWalk.draw()*1.4; // TODO: why *2?
headChange_rad = headChange_rad*dHead.draw();
static Distribution::Normal<float> sWalk(0, 0.15);
//static Distribution::Normal<float> sWalk(0, 0.15);
if (distance_m == 0) { distance_m = std::abs( sWalk.draw() ); }
return walk(grid, start, distance_m, headChange_rad, act);
@@ -114,12 +118,14 @@ private:
}
Distribution::Uniform<float> dChange = Distribution::Uniform<float>(Angle::degToRad(0), +Angle::degToRad(359));
GridWalkState<T> walk(Grid<T>& grid, const GridWalkState<T>& start, const float distance_m, const float headChange_rad, Activity act) {
// try-again distribution
//static Distribution::Normal<float> dHead(0, Angle::degToRad(10));
//static Distribution::Normal<float> dUpdate(0, Angle::degToRad(3));
static Distribution::Uniform<float> dChange(Angle::degToRad(0), +Angle::degToRad(359));
// static Distribution::Uniform<float> dChange(Angle::degToRad(0), +Angle::degToRad(359));
int retries = 5;
float walked_m = 0;

View File

@@ -39,20 +39,22 @@ public:
gen.seed(1234);
}
Distribution::Normal<float> dHead = Distribution::Normal<float>(1, 0.01);
Distribution::Normal<float> dWalk = Distribution::Normal<float>(1, 0.10);
Distribution::Normal<float> sWalk = Distribution::Normal<float>(0, 0.10);
GridWalkState<T> getDestination(Grid<T>& grid, const GridWalkState<T>& start, float distance_m, float headChange_rad, Activity act) {
// proportional change of the heading
static Distribution::Normal<float> dHead(1, 0.01);
// proportional change of the to-be-walked distance
static Distribution::Normal<float> dWalk(1, 0.10);
//static Distribution::Normal<float> dWalk(1, 0.10);
distance_m = distance_m*dWalk.draw()*1.4; // TODO: why * X?
headChange_rad = headChange_rad*dHead.draw();
static Distribution::Normal<float> sWalk(0, 0.10);
//static Distribution::Normal<float> sWalk(0, 0.10);
if (distance_m == 0) { distance_m = std::abs( sWalk.draw() ); }
return walk(grid, start, distance_m, headChange_rad);
@@ -90,12 +92,14 @@ private:
}
Distribution::Uniform<float> dChange = Distribution::Uniform<float>(Angle::degToRad(0), +Angle::degToRad(359));
GridWalkState<T> walk(Grid<T>& grid, const GridWalkState<T>& start, const float distance_m, const float headChange_rad) {
// try-again distribution
//static Distribution::Normal<float> dHead(0, Angle::degToRad(10));
//static Distribution::Normal<float> dUpdate(0, Angle::degToRad(3));
static Distribution::Uniform<float> dChange(Angle::degToRad(0), +Angle::degToRad(359));
// static Distribution::Uniform<float> dChange(Angle::degToRad(0), +Angle::degToRad(359));
int retries = 5;
float walked_m = 0;

View File

@@ -34,6 +34,12 @@ public:
entries.push_back(InterpolatorEntry(key, value));
}
/** get the smallest added key */
Key getMinKey() const {return entries.front().key;}
/** get the largest added key */
Key getMaxKey() const {return entries.back().key;}
/** get the interpolated value for the given key */
Value get(const Key key) const {