Numerical solution of optimal control problems with explicit and implicit switches. (4th May 2018)