Algorithms And Simulation Framework For Residential Demand Response