This note accompanies the code available on github.
KrummΒ [1] has recently introduced the concept of bridgelets. In his work, he aims to use a data-driven approach to interpolate trajectories between the measured locations. The main idea is to compute probabilities for visiting certain regions in between measurements. The regions in question are the cells of a square grid that subdivides the location space. By also discretising time, Krumm arrives at the model where at each time step, the trajectory can stay in the current cell or move to one of its direct neighbours. He uses this model to compute visit probabilities of cells in a grid based on a set of real-life trajectories.
The dynamic program makes computing with bridgelets more efficient, since it avoids constructing the bridgelets explicitly. This makes it possible to use a finer grid and time steps, or to reasonably cover sparser trajectories. A bridgelet is the set of all walks between two given vertices of the grid in time steps. Krumm enumerates the walks explicitly to count the visits to the cells, which takes time exponential in , making it impractical to use for . Our dynamic programming approach computes all the relevant statistics in time instead of , making it feasible to compute the relevant statistics easily at least up to . With sufficient parallelisation and optimisation, it is possible to make the approach even faster, as we only need time when computing on computing units in parallel. Furthermore, we show how to use this information to generate random trajectories that follow a certain distribution, in time per trajectory of steps.
| Problem | DP | Explicit |
|---|---|---|
| All paths | 1 | 260331 |
| Visiting paths from to | 4 | 273017 |
We also provide closed-form expressions to compute the number of walks to a specific cell in steps, and show how to obtain a formula for the visit probabilities. Specifically, the number of walks in a bridgelet from to in steps is where .
Some simple questions stated above can be solved by means of dynamic programming. The basic idea is to count paths that reach a certain cell in steps, so we can count paths reaching this cell and its neighbours in steps. With some care and exploiting the symmetry of the problem, we can use this simple idea to also compute the visit probabilities for all cells on any possible path from to .
The simplest question is the following: given a time limit and the point , count the distinct paths in . By means of dynamic programming, we can even solve a more general question efficiently: given the time limit , count the paths in for all possible grid points and for all . This can be accomplished by creating a table on the coordinates and filling it out as follows:
Here and later we assume that out-of-bounds values in the table are . It is easy to see that after filling the entire table, a cell for some and holds the count of paths in . Furthermore, for any out of range, the value should clearly be , as those points are not reachable in steps. The dynamic program can clearly be computed in time . We show an example result for below.
Secondly, we can solve the following question: given a time limit and the point , count the paths in that go through a vertex . We can compute these counts efficiently for all possible vertices . We give further details here.
The approach is quite flexible. In particular, it can be adapted to counting paths on a grid with holes that represent obstacles.
Suppose we have some representation of a set of obstacles. Depending on the application, it may be best represented as a boundary, or directly as a set of cells; its complexity affects the running time. Then we can formulate the following DP for counting paths in for all and all : We discuss computing probabilities in the setting with obstacles here.
Computing these statistics using dynamic programming makes it easier to also sample realistic trajectories from bridgelets. The easiest way is to generate the trajectory starting from the end point, one segment at a time, by reconstructing the transition probabilities using the counts stored in the DP. The approach takes time per trajectory, assuming the DP with path counts for the time limit not smaller than is precomputed (which can be done in time). We show some trajectories from to in steps in FigureΒ 1. These are generated based on the values of , without obstacles. The trajectories appear to exhibit reasonable levels of randomness, with (discretised) wandering behaviour spread throughout the trajectory.
We have shown the expression for the path count above; we show further details here (also includes a mathematical derivation for the visit probabilities).
[1] John Krumm. 2022. Maximum Entropy Bridgelets for Trajectory Completion. To appear in Proceedings of the 30th International Conference on Advances in Geographic Information Systems (ACM SIGSPATIAL 2022).