Hybrid Cost Automata Applied to Energy Optimization