Automatic Differentiation and Spectral Projected Gradient Methods for Optimal Control Problems