Energy Management In Microgrids: Algorithms And System