Online Optimal Pulsewidth Modulation (OPWM): for a Multilevel Inverter