Generalized Model Predictive Algorithm for Single-Phase-Grid Connected Multilevel Inverters