Optimal Control and the Calculus of Variations