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 and the pink obstacle points . Suppose the cost evaluated at a point is the sum of Gaussians centered at each pink obstacle point, evaluated at .
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.
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.