The multi-agent leader-following consensus algorithm is employed to address the EDP of microgrids in grid-connected mode, while the push-pull algorithm with a fixed step size is introduced for the isolated mode. Firstly, the control task of the microgrid power generation system is defined, which is required to meet the load demand while reducing the economic loss of the system and. Considering the interests of multiple stakeholders, such as users, power grids, renewable energy and battery, a dynamic economic dispatch model of microgrid is proposed in this paper based on time-of-use power price mechanism. Using a variant of Non-Dominated Sorting Genetic Algorithm (NSGA)-II.