## 3 Proposed Control Methods
### Power Matching  
From the data curve that needs to be fitted in Figure 2, there are sinusoidal-like peak and valley fluctuations between the input and output data. After the neural network completes data prediction, the forecasted and actual peaks cannot be perfectly aligned, but will have a time delay, which is undesirable for frequency regulation. The next step involves matching data by adjusting each DG's forecasted power to align with the ideal power required for eliminating frequency deviation, primarily focusing on timing regularization. While previous research has employed experience-based amplitude adjustments and delay compensation, these approaches lack dynamic adaptability. This paper will instead use a dynamic timing regularization method. Dynamic timing regularization processes time series data of varying lengths [27; 28]. The core concept involves finding an alignment or regularization path that minimizes the cumulative sum of distances between corresponding points in two time series. This enables the identification and matching of similar features, such as peaks, within the time series. The first step calculates a distance matrix between two input time series. Each matrix element represents the distance between corresponding points in the sequences, typically measured using Euclidean distance. This quantifies the cost of each possible point-to-point matching between power commands and load consumption, providing a global perspective for preliminary assessment. Next, a dynamic programming algorithm is applied to determine the path with the lowest cumulative cost, i.e., the regularization path. This path shows how points in one sequence optimally correspond to points in another while minimizing the overall distance metric. The process may involve non-linear stretching or compression to compensate for slight shifts along the time axis. Constraints can be added to speed up computation or enforce local alignment. The method outputs both a cumulative distance value and the regularization path, showing which points align with each other. This is especially useful for identifying time series with similar peak patterns. The following key steps complete the process described above:  
First, construct distance matrix \(D\), where \(D_{i,j}\) represents the distance between the \(i\)th point in sequence \(X\) and the \(j\)th point in sequence \(Y\). The Euclidean distance is typically used:  
\[D_{i,j}=d(x_{i},y_{j})=\sqrt{(x_{i}-y_{j})^{2}} \tag{15}\]Next, define a cumulative distance matrix \(C\), where \(C_{ij}\) represents the minimum cumulative distance from the starting point to point (\(i\), \(j\)). Its recursive definition is as follows:  
\[C_{i,j}=D_{i,j}+\min(C_{i-1,j},C_{i,j-1},C_{i-1,j-1}) \tag{16}\]  
where \(C_{0,0}=0\), and for all cases where \(i>0\) or \(j>0\), \(C_{i,0}=\infty\) and \(C_{0,j}=\infty\) (except for \(C_{0,0}\)), thus ensuring the path starts from the origin. Finally, determine the optimal warping path \(P=\{(p_{1}\_{A}\_1), (\(p_{2}\_{A}\_2\)), \(\ldots\), (\(p_{k}\_{k}\))\(\}\) that minimizes the cumulative distance \(C_{n,m}\), where the path has a starting point at (0, 0) and an endpoint at (\(n\), \(m\)). Each step can move vertically, horizontally, or diagonally. Skipping samples or repeating signal features is not allowed, ensuring each point in the sequences is visited at least once. As shown in Figure 2, anomalies in weight updates may be created during network training when the input data is 0 but the output data is a large non-zero value. In such cases, under the influence of the activation function, gradient vanishing issues are likely to occur. Conversely, if the network attempts to quickly adjust to generate larger output values, this may lead to gradient explosion. Furthermore, input data of 0 may prevent the network from learning effective feature representations due to insufficient information to distinguish between different inputs.