Optimization of energy consumption schedule of residential loads and electric vehicles