An Optimal Adaptive Control Strategy for Energy Balancing in Smart Microgrid Using Dynamic Pricing