Microgrid intelligent control with optimized power-energy management