Online Learning and Optimization of Markov Jump Affine Models