Optimal control of dynamical systems with jump Markov perturbations