Design and Hardware-in-the-Loop Testing of Optimal Controllers for Hybrid Electric Powertrains