mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-06 03:29:17 +00:00
use piecewise logic for probabilities
This commit is contained in:
parent
584ecd0b4e
commit
df17560c9f
@ -200,8 +200,26 @@ float FloodingRouter::calculateForwardProbability(const CoverageFilter &incoming
|
|||||||
coverageRatio = static_cast<float>(uncovered) / static_cast<float>(neighbors);
|
coverageRatio = static_cast<float>(uncovered) / static_cast<float>(neighbors);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate forwarding probability
|
float forwardProb = BASE_FORWARD_PROB;
|
||||||
float forwardProb = BASE_FORWARD_PROB + (coverageRatio * COVERAGE_SCALE_FACTOR);
|
|
||||||
|
/* BEGIN OPTION 1: forward probability is based on coverage ratio and scales up or down
|
||||||
|
* depending on the extent to which this node provides new coverage
|
||||||
|
* forwardProb = BASE_FORWARD_PROB + (coverageRatio * COVERAGE_SCALE_FACTOR);
|
||||||
|
*/
|
||||||
|
/* END OPTION 1 */
|
||||||
|
|
||||||
|
/* BEGIN OPTION 2: forward probability is piecewise logic:
|
||||||
|
* - Reduce to BASE_FORWARD_PROB if no new coverage is likely
|
||||||
|
* (remember false positive rate of bloom filter means a node that think its neighbor is covered when it isnt)
|
||||||
|
* - If 1 uncovered neighbor, ramp probability up significantly to 0.8
|
||||||
|
* - If more than 1 uncovered neighbor, ramp probability up to 1.0
|
||||||
|
*/
|
||||||
|
if (uncovered == 1) {
|
||||||
|
forwardProb = 0.8f;
|
||||||
|
} else if (uncovered > 1) {
|
||||||
|
forwardProb = 1.0f;
|
||||||
|
}
|
||||||
|
/* END OPTION 2 */
|
||||||
|
|
||||||
// Clamp probability between 0 and 1
|
// Clamp probability between 0 and 1
|
||||||
forwardProb = std::min(std::max(forwardProb, 0.0f), 1.0f);
|
forwardProb = std::min(std::max(forwardProb, 0.0f), 1.0f);
|
||||||
|
Loading…
Reference in New Issue
Block a user