Last active
May 20, 2017 17:16
-
-
Save jtremback/788101592bcf99aa7004e26a3c6347cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 1 step process | |
type route = { destination, neighbor, metric: number } | |
type destination = { pastUsage: number } | |
type neighbor = { pastAccuracy: number } | |
for each route | |
probabilities[route] = destination.pastUsage * metric * neighbor.pastAccuracy | |
selectedRoute = selectRoute(probabilities) | |
actualMetric = testRoute(selectedRoute) | |
accuracy = inverse(selectedRoute.metric - actualMetric) | |
updatePastAccuracy(selectedRoute.neighbor, accuracy) | |
*/ | |
/* 2 step process | |
// Get average of all past trials of neighbor | |
let getAvgAccuracy = (neighbor) => sum(neighbor.tests) / neighbor.tests.length | |
// Create destination probability distribution from past usage of destination | |
let pd = normalize(destinations.map(dest => dest.pastUsage)) | |
// Select destination to test | |
let d = weightedRandomSample(pd) | |
// Create neighbor probability distribution by multiplying all neighbors metric per destination by | |
// average past accuracy | |
let pn = normalize(neighbors.map(neighbor => neighbor.metrics[d] * getAvgAccuracy(neighbor))) | |
// Select neighbor to test | |
let n = weightedRandomSample(pn) | |
// Push result of test into fixed size list of test results (sliding window) | |
neighbors[n].tests.pushWindow(testNeighbor(d, n)) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So, the starting point here is that we have a table of of routes. A route is a tuple of {destination, neighbor, metric}. The size of this table is n neighbors * n nodes in network (destinations). This table is populated by the routing protocol, outside of what's shown here. In the 1 step process above, we weight by the destination's past usage, the route metric (how good the neighbor claims it is for that destination), and the neighbor's past accuracy. This is a pretty simple way to express what we need, but as written it requires iteration over all routes.
The 2 step process is actually more of an optimization (even though I came up with it first). By selecting a specific destination first, we greatly reduce the amount of iteration.