Path finder

2013-11-28

This demo uses a finite approximation of calculus of variations to optimize the blue path through a set of points. Click to add some obstacle points.

If your path gets stuck in a local minimum, you can try to generate a completely new path:

generate new path

Let’s call the blue points on our path \xi_0, \xi_1, \xi_2, \cdots and the pink obstacle points p_0, p_1, p_2, \cdots. Suppose the cost evaluated at a point \xi is the sum of Gaussians centered at each pink obstacle point, evaluated at \xi.

1 \displaystyle{\begin{align}G(\xi_i) = \sum_j \operatorname{exp}\left(\frac{\|\xi_i - p_j\|^2}{\sigma^2}\right)\end{align}}

Then the overall cost is the sum of the individual costs, plus a term that penalizes the distance between every consecutive pair of path points.

2 \displaystyle{\begin{align}\operatorname{cost} = \sum_i \left(G(\xi_i) + C\|\xi_i - \xi_{i-1}\|^2\right)\end{align}}

On each iteration of the algorithm, we simply perform a gradient descent step with some small step size, by simultaneously moving each path point. In this sense, path points are repelled from the obstacle points, but attracted to their neighbouring path points.