## 4 Simulation and Results Analysis
### Comparison of Online Optimization
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Dynamic Performance Indicators** & **Initial** & **Offline** & **Online** \\ \hline Step value (I\({}_{\text{d}}\), A) & 10 & 10 & 10 \\ Step value (P, kW) & 2 & 2 & 2 \\ Rise time (I\({}_{\text{d}}\), s) & 0.01 & 0.01 & 0.01 \\ Rise time (P, s) & 0.032 & 0.022 & 0.023 \\ Overshoot (I\({}_{\text{d}}\), \%) & 143\% & 105\% & 120\% \\ Overshoot (P, \%) & 38.5\% & 26\% & 28\% \\ Peak time (I\({}_{\text{d}}\), s) & 0.04 & 0.03 & 0.031 \\ Peak time (P, s) & 0.0085 & 0.042 & 0.047 \\ Settling time (I\({}_{\text{d}}\), s) & 0.146 & 0.078 & 0.082 \\ Settling time (P, s) & 0.157 & 0.087 & 0.092 \\ Average steady-state error (I\({}_{\text{d}}\), \%) & 19.3\% & 10.1\% & 9.8\% \\ Average steady-state error (P, \%) & 11.1\% & 4.9\% & 5.1\% \\ \hline \hline \end{tabular}
\end{table} 
Table 6: The key parameters comparison table of the step–response. Figure 18: The active power output curves and \(d\)-axis current output curves. (**a**) The active power output comparison curves. (**b**) The \(d\)-axis current output comparison curves. Due to the strong load randomness characteristics, high intermittent characteristics of the power supplies, low inertia characteristics, and the effect of random noise disturbances and delays, the oscillations and fluctuations cannot be avoided during the normal operation process of a micro-grid (as Figure 18 shows). To verify the anti-shock performance of the system caused by the strong randomness of the load, the impulse response of VSI was compared in this paper (as Figure 20 shows). The load mutation appeared when the operation time was 15.4 s, and disappeared at 15.6 s. Since the target-setting values of VSI output were changed, the control system experienced two impulse response processes as the power changed, caused by load mutations. The main dynamic comparison indicators are listed in Table 7. Compared with the initial parameter curve, the active power output curve with optimized parameters had smaller spike amplitudes in the process of the impulse response and a quicker recovery of the stable state. The IAE comparison results of this process are shown in Figure 21. The improvement of IAEs in active power control loops and the \(d\)-axis control loop was clear, while the improvement effect in other control loops was relatively small. Although the performance improvement of reactive power output was limited, the comprehensive performance of the control system improved by optimizing control parameters without changing the overall control structure, method, and usage of energy storage. Figure 19: Comparison variable load process IAEs of the original controller, online optimization controller, and offline optimization controller. The IAE1-P represents active power, the IAE2-Q represents reactive power, the IAE3-d axis represents the \(d\)-axis component, and the IAE4-q axis represents the \(q\)-axis component under the IAE index. Figure 20: \(Cont\). \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Dynamic Performance Indicators** & **Initial** & **Offline** & **Online** \\ \hline Peak1 (P, kW) & 1.09 & 0.38 & 0.51 \\ Peak1 (Q, kVar) & 0.53 & 0.54 & 0.53 \\ Peak2 (P, kW) & 0.74 & 0.43 & 0.45 \\ Peak2 (Q, kVar) & 0.66 & 0.83 & 0.82 \\ Settling time1 (P, s) & 0.092 & 0.072 & 0.057 \\ Settling time1 (Q, s) & 0.077 & 0.054 & 0.054 \\ Settling time2 (P, s) & 0.073 & 0.05 & 0.046 \\ Settling time2 (Q, s) & 0.089 & 0.053 & 0.053 \\ \hline \hline \end{tabular}
\end{table} 
Table 7: The key parameters comparison table during the load mutation process. Figure 20: Load mutation comparison curves. (**a**) The active and reactive power comparison curves. (**b**) The output current curves of online optimization. (**c**) The current comparison curves of Phase A.