Model based predictive control