A gradient algorithm for solution of the optimal control problem for hybrid switching systems. (9th September 2020)