Dynamic Pricing of Electricity and Demand Response in Smart Communities