Generalized predictive control - Part I. The basic algorithm