Model predictive control for Max-Plus-Linear and piecewise affine systems