## 1 Introduction
### Related Work  
There is a wide range of studies covering the issue of energy management for DN with microgrids (MGs) [9; 10; 11; 12; 13; 14; 15; 16; 17]. Most of the work is focused on economic scheduling for different entities.The operating cost of microgrids in the DN is minimized through effective energy management considering the real-time electricity price in [11]. In [14], energy management considering the demand response for a microgrid, is achieved for the economic operation of the microgrid, and also for peak shaving of the distribution grid. Multi-agent approaches and game theories have been widely applied to the decision-making and energy management of AC and DC MGs [15; 16; 17].  
Artificial Intelligence (AI) based techniques are being developed and deployed worldwide in various areas. With regards to AI being applied to grid services, there are also several studies on solving the problem of decision-making optimization. The intelligent algorithms are used to obtain energy demand response and change the behavior of electricity consumption in [18]. In [19], an optimal power dispatch on a 24h basis for distribution systems, including large-scale controllable loads, is presented with a swarm particles optimization algorithm. The genetic algorithm (GA), as a heuristic algorithm, does not depend on the specific domain of the problem and is robust enough to be used in complex and difficult optimization problems in power systems [20; 21; 22]. Most of the previous work have focused on formulating the optimization problem to achieve economic efficiency in a conventional centralized way, without considering how the architecture of this energy management might improve operational preformation with emerging information and communications technology.  
On the other hand, the application of IoT devices and smart meters in distribution grids generates a large amount of data, and the expansion of IoT and knowledge discovery will drive changes in current MG planning [23]. Moreover, the sources of this data are different, the format is diversified, and the processing of cloud-intensive data alone, might risk overloading the cloud computation capability. Fog computing is therefore proposed to addressing the massive amounts of data from these devices [24; 25]. A three-layer energy management architecture based on the IoT and fog computing is proposed in [26]. The first layer is for users to communicate and interconnect with the system through the networked gateway and smart meter. The second layer realizes the operations of the user and retail market. Moreover, the third layer is for the calculating the stability of the system and data storage. In [27], an IoT-based smart home energy management system was designed and implemented in reality. Also, with regards to laboratory practice, there are a few pioneering cases. For example,Aalborg University set up an IoT-Oriented microgrid living lab, where major smart devices and a DC/AC microgrid can interconnect and communicate [28].  
From the previous work, the combination of scheduling prosumers' generation and larger-scale IoT devices in DN opens new doors for the operation of the next-generation DN. Additionally, the development of AI technologies is also contributing to energy management of grids. Previous works have rarely included a layered interaction to solve the energy management problems related to the next-generation distribution network. This paper will address the need for efficient decision-making and real-time management of DN by establishing models based on a novel architecture incorporating and harnessing these aspects.