Optimal train control via switched system dynamic optimization. (4th May 2021)