## 4 Simulation and Results Analysis
### Comparison of Online Optimization  
Unlike the offline optimization process, the FOA-based online optimization process refers to the online self-tuning optimization of the parameters on the basis of calculating the time sequence sampling data during the step-response in the practical operation of the controllers. In other words, the offline process involves a step-response simulation for each fruit fly via the object model, while online optimization refers to the self-tuning optimization of real-time parameters in the manner of time sequence optimizing for all the fruit fly populations in the same step-response process. Figure 14 shows the optimization result curve of the parameter self-tuning process with a population size of 10, and a total number of iterations of 100.The curves in Figure 14a-c demonstrate a process of decline before rebound, which was because the main discrimination index of the online optimization consisted of the slope IE of the sampling point curve in the step-response. According to the above-mentioned rules for online optimization, we should first solve the maximum of the IE value and then the minimum in the step-response process of the system. Therefore, regarding the discrimination rules of the overall smell function (Si), we should first solve the minimum and then the maximum, so as to be consistent with the tendencies of the curves in Figure 14a,b. Table 4 shows the comparisons of the major parameters in the self-tuning process. Figure 14: The bestSmellbestIndex values of the online FOA optimization simulation (the population is 100 and the iteration generation is 100). (**a**) The bestSmellbestIndex1 optimal values curves. (**b**) The bestSmellbestIndex2 optimal values curves. (**c**) The bestSmellbestIndex3 optimal values curves. (**d**) The bestSmellbestIndex4 optimal values curves. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Dynamic Performance Indicators** & **Initial** & **Offline** \\ \hline Settling time (P, s) & 1.146 & 0.353 \\ Settling time (Q, s) & 0.405 & 0.346 \\ Average steady-state error (Id, \%) & 6.3\% & 0.37\% \\ Average steady-state error (Iq, \%) & 1.27\% & 1.02\% \\ Average steady-state error (P, \%) & 5.83\% & 0.96\% \\ Average steady-state error (Q, \%) & 5.87\% & 1.1\% \\ \hline \hline \end{tabular}
\end{table} 
Table 3: _Cont._Table 4 shows the major parameter indexes at the initial moment and the end moment of parameter self-tuning in the optimization process. In order to fully compare the performance of the online self-tuning controller, the offline optimization controller, and the original controller, a comparison experiment was undertaken on an experimental verification platform (as Figure 15 shows). The experimental platform was a representative family photovoltaic micro-grid project in Binhai District, Tianjin, China. The micro-grid system had two photovoltaic arrays, two photovoltaic grid inverters as VSIs, and a monitoring software platform with a communication and control parameter adjustment function. Throughout the whole experimental process, the controller parameters at each sampling time were self-tuned. The complete power step-responses of the online optimization parameters, the offline optimization parameters, and the initial parameters during the startup process were compared (as Figure 16 shows). Figure 16a shows the contrast curves of the original controller, the self-tuning parameter controller, and the offline optimized controller with the active and reactive power response in the practical operation process of the system. Figure 16b presents the curves with the reactive power response. A comparison between the curves before optimization and after optimization indicated that the oscillation amplitude of the curve increased, but its frequency declined, in the process of the step-response.