Text this: Optimization of operating cost and energy consumption in a smart grid