Optimal soaring via Hamilton–Jacobi–Bellman equations