routing: apply capacity factor
We multiply the apriori probability with a factor to take capacity into account: P *= 1 - 1 / [1 + exp(-(amount - cutoff)/smearing)] The factor is a function value between 1 (small amount) and 0 (high amount). The zero limit may not be reached exactly depending on the smearing and cutoff combination. The function is a logistic function mirrored about the y-axis. The cutoff determines the amount at which a significant reduction in probability takes place and the smearing parameter defines how smooth the transition from 1 to 0 is. Both, the cutoff and smearing parameters are defined in terms of fixed fractions of the capacity.
This commit is contained in:
4 files changed
+189
-10
No files matched your search
@@ -113,9 +113,12 @@ func (ctx *mcTestContext) expectP(amt lnwire.MilliSatoshi, expected float64) {
|
||||
ctx.t.Helper()
|
||||
|
||||
p := ctx.mc.GetProbability(mcTestNode1, mcTestNode2, amt, testCapacity)
|
||||
if p != expected {
|
||||
ctx.t.Fatalf("expected probability %v but got %v", expected, p)
|
||||
}
|
||||
|
||||
// We relax the accuracy for the probability check because of the
|
||||
// capacity cutoff factor.
|
||||
require.InDelta(
|
||||
ctx.t, expected, p, 0.001, "probability does not match",
|
||||
)
|
||||
}
|
||||
|
||||
// reportFailure reports a failure by using a test route.
|
||||
|
||||
Reference in new issue
Block a user