Optimal control of discrete hybrid stochastic automata