The traditional electric power grid is in the process of being transformed from the conventional power grid to an intelligent grid, a so-called smart grid. The operation of smart grids no longer has one-directional energy and information flow, and enables communication between utilities and consumers, which is a potential solution to motivating end users to participate in the decision-making of a demand response. The traditional solution for energy management problems is a centralized algorithm, which requires a control centre to collect and process the algorithm. However, it could lose its effectiveness due to the increasing level of distributed energy resources (DERs). The distributed method is a potential solution to the problem caused by the centralized method. The research in this thesis mainly focuses on the feasibility of improving the energy management system (EMS) of smart grids from the demand side to the supply side. First, a coordination strategy of the plug-in electric vehicle (PEV) charging process is studied by maximizing the welfare and satisfaction of PEV owners. It is a distributed algorithm and analysis shows that it solves the optimal charging problem in an initialization-free approach. Second, the resource management of renewable generators (RG) and energy storage systems (ESSs) is investigated. The objective is to minimize the curtailment of renewable energy, and at the same time, to minimize the power losses of ESSs. An optimal solution is proposed to the management problem by enhancing the communication and coordination under a multi-agent system (MAS) framework. Third, from the above research, it is found that the operation of microgrids may change frequently and without warning. A distributed finite-time algorithm is designed for EMSs in a microgrid under different operation modes. Fourth, a novel fixed-time distributed solution is introduced that both achieves a fast convergence speed and is robust to dealing with uncertain information. Finally, a novel distributed strategy for multiple BESSs is proposed for optimally coordinating them under uncertainties of wind power generation while considering the privacy of users.