Constrained optimization in the calculus of variations and optimal control theory. (2018)