Efficient energy management of renewable resources in microgrids