# Fault Prediction and Reconfiguration Optimization in Smart Grids: AI-Driven Approach
## 4 Reconfiguration Algorithm and Proposed Extension  
The reconfiguration algorithm for the SG, upon which the ML and DL models were built, was DEN2 DE [10]. DEN2 DE is an algorithm designed for discovering paths in dense and heterogeneous networks, enabling the automation of the routing process from leaf nodes to the root node of the topology, while efficiently managing resource sharing. In the specific context of an SG, the root node is defined as the one having a direct connection to the electrical distribution network, whereas the leaf nodes represent the remaining nodes in the SG. To further explain the reconfiguration process followed by DEN2 DE, Figure 6 depicts a scenario of load redistribution within an SG, similar to the IEEE 5-bus topology example. In green, we can observe the nodes that have a surplus of load, which can be offered to other nodes in the network. In orange, the nodes demanding power from neighboring nodes, or ultimately, from the root node, are highlighted. However, calculating all possible load redistribution solutions can be computationally complex within a reasonable time frame. For instance, Figure 5(a) illustrates a suboptimal redistribution of resources, which occurs as neighbors decide based on local decisions, which leads to most requests directed to the node with a surplus of +100 (insufficient to meet all the demands), as represented by the arrows. On the other hand, Figure 5(b) depicts an optimal distribution scenario, which requires a more sophisticated approach. To address this issue, DEN2 DE proposes a three-phase solution. The first phase, as shown in Figure 7, involves exploring all possible routes from the root node to each leaf node in the topology. This exploration, as depicted in the figure, is carried out using labels. The exploration begins at the root node, which generates the first label (\(I\)) and transmits it to all its immediately connected neighbors, in this case to node 2. Node 2 receives the label, appends its node identifier, stores it in its learning table, and then proceeds to transmit it similarly to all its contiguous neighbors. In this way, node 3 receives the label \(1.2\), indicating that it is two hops away from the root node, and it repeats the process by assigning the label \(1.2.3\) to its neighbors, nodes 4 and 5. These nodes, in turn, perform the same process, \begin{table}
\begin{tabular}{c c c} \hline
**Field** & **Description** & **Units** \\ \hline _timestamp_ & Time of measurement & datetime \\ \hline _datetime_ & Date of the average value & datetime \\ \hline \(H\) & Hour of the average value & - \\ \hline _iid_ & Housing identifier & - \\ \hline _Diffuse Irradiance_ & Diffuse radiation index (DIF) & W/m\({}^{2}\) \\ \hline _Plane of Array Irradiance_ & Plane of array radiation index (POA) & W/m\({}^{2}\) \\ \hline _Ambient Temperature_ & Ambient temperature & C \\ \hline _Cell Temperature_ & Solar cell temperature & C \\ \hline _DC Array Output_ & DC array output power & W \\ \hline _AC System Output_ & AC system output power & W \\ \hline _Pagg_ & Consumed power & W \\ \hline _Dif_ & Net calculated load & W \\ \hline \end{tabular}
\end{table} 
Table 3: Resulting dataset (_KeyMonData_) from the processing stage. exchanging labels _1.2.3.4_ and _1.2.3.5_, which allow them to learn an alternative route to the root node. This is because they now have a direct route through node 3, as well as a longer route through the node that just assigned them the new label. Ultimately, nodes 4 and 5 will attempt to transmit the last learned labels (_1.2.3.4_ and _1.2.3.5_) back to node 3. However, DEN2 DE logic incorporates a loop prevention mechanism: if the label being offered is part of any previously learned label in the learning table, it will be discarded. This is why labels such as _1.2.3.5.4_ and _1.2.3.4.5_ are discarded by node 3, as illustrated in Figure 7.  
Once the entire labeling process across the network is finished, the first phase of the algorithm is considered complete.