**An Optimal Energy Management System for Real-Time Operation of Multiagent-Based Microgrids Using a T-Cell Algorithm**

**Fatima Zahra Harmouch 1,2, Ahmed F. Ebrahim 2, Mohammad Mahmoudian Esfahani 2, Nissrine Krami 1, Nabil Hmina <sup>1</sup> and Osama A. Mohammed 2,\***


Received: 25 June 2019; Accepted: 30 July 2019; Published: 3 August 2019

**Abstract:** The real-time operation of the energy management system (RT-EMS) is one of the vital functions of Microgrids (MG). In this context, the reliability and smooth operation should be maintained in real time regardless of load and generation variations and without losing the optimum operation cost. This paper presents a design and implementation of a RT-EMS based on Multiagent system (MAS) and the fast converging T-Cell algorithm to minimize the MG operational cost and maximize the real-time response in grid-connected MG. The RT-EMS has the main function to ensure the energy dispatch between the distributed generation (DG) units that consist in this work on a wind generator, solar energy, energy storage units, controllable loads and the main grid. A modular multi-agent platform is proposed to implement the RT-EMS. The MAS has features such as peer-to-peer communication capability, a fault-tolerance structure, and high flexibility, which make it convenient for MG context. Each component of the MG has its own managing agent. While, the MG optimizer (MGO) is the agent responsible for running the optimization and ensuring the seamless operation of the MG in real time, the MG supervisor (MGS) is the agent that intercepts sudden high load variations and computes the new optimum operating point. In addition, the proposed RT-EMS develops an integration of the MAS platform with the Data Distribution Service (DDS) as a middleware to communicate with the physical units. In this work, the proposed algorithm minimizes the cost function of the MG as well as maximizes the use of renewable energy generation; Then, it assigns the power reference to each DG of the MG. The total time delay of the optimization and the communication between the EMS components were reduced. To verify the performance of our proposed system, an experimental validation in a MG testbed were conducted. Results show the reliability and the effectiveness of the proposed multiagent based RT-EMS. Various scenarios were tested such as normal operation as well as sudden load variation. The optimum values were obtained faster in terms of computation time as compared to existing techniques. The latency from the proposed system was 43% faster than other heuristic or deterministic methods in the literature. This significant improvement makes this proposed system more competitive for RT applications.

**Keywords:** smart microgrid; energy management system; multi-agent system; real-time optimization; immune system algorithm; economic dispatch
