Optimal control of hybrid systems and renewable energies