## 3 The Fruit Fly Optimization (FOA)-Based Parameter Tuning Method of VSI Output Control
### The FOA-Based Offline Parameter Optimization Tuning Method  
Offline parameter optimization and tuning of the parameters of the inverter controller requires the topological construction of the model for the controlled object as well as the identification of the optimal value through parameter optimization and tuning of the offline model. Figure 5 presents a block diagram of the control structure of FOA-based offline parameter optimization and tuning.  
Figure 4: The step–response curves of cascade PI controllers when one proportional coefficient is changed.  
The integral absolute error (IAE) index is taken as the discrimination index of the offline parameter tuning process.  
\[IAE=\int_{t_{1}}^{t_{2}}|error(t)|dt. \tag{12}\]  
The eight control parameters of the four PI controllers are divided into four categories. Take the proportionality coefficient as the \(x\) coordinate of the original location of the fruit fly, and the integral coefficient as the \(y\) coordinate of the original location of the fruit fly. Each generation of fruit fly swarm includes four types of fruit fly, and the distance from the fruit fly to the target is the smell concentration function built by using IAE as the main judgment index.  
The flow chart of the FOA-based offline parameter optimization tuning process is shown in Figure 6, and the key computation steps are as follows:  
Step 1: Initialize the location of the four types of fruit fly with the PI parameter values in the system:  
\[x_{axis}1=kp1,y_{axis}1=ki1,x_{axis}2=kp2,y_{axis}2=ki2, \tag{13}\]  
\[x_{axis}3=kp3,y_{axis}3=ki3,x_{axis}4=kp4,y_{axis}4=ki4,. \tag{14}\]  
Step 2: Use the parameter RandomValue, which is random variables, to give a random direction and distance for the search values:  
\[x_{i1}=x_{axis}1+RandomValue,y_{i1}=y_{axis}1+RandomValue, \tag{15}\]  
\[x_{i1}=x_{axis}1+RandomValue,y_{i1}=y_{axis}1+RandomValue, \tag{16}\]  
\[x_{i3}=x_{axis}3+RandomValue,y_{i3}=y_{axis}3+RandomValue, \tag{17}\]  
\[x_{i4}=x_{axis}4+RandomValue,y_{i4}=y_{axis}4+RandomValue. \tag{18}\]  
Figure 5: Offline parameter optimization diagram.  
Step 3: Use the indicators (IAE) to build the distance function (Dist) and calculate the smell function (Si):  
\[Dist1=\int_{t1}^{t2}|error1(t)|dt,Si1=1/Dist1, \tag{19}\]  
\[Dist2=\int_{t1}^{t2}|error2(t)|dt,Si2=1/Dist2, \tag{20}\]  
\[Dist3=\int_{t1}^{t2}|error3(t)|dt,Si3=1/Dist3, \tag{21}\]  
\[Dist4=\int_{t1}^{t2}|error4(t)|dt,Si4=1/Dist4. \tag{22}\]  
Step 4: Use smell function Si1, Si2, Si3, and Si4 to construct the smell concentration judgment set {Smell1}, {Smell2}, {Smell3}, and {Smell4} of the fruit fly swarm:  
\[Smell1_{j}=Si1, \tag{23}\]  
Figure 6: The offline optimization process flowchart of the fruit fly optimization algorithm (FOA).  
\[Smell2_{i} = Si2, \tag{24}\] \[Smell3_{i} = Si3,\] (25) \[Smell4_{i} = Si4. \tag{26}\]  
Step 5: Find out the maximal smell from the [Smell1], [Smell2], [Smell3], and [Smell4] values. Then, the maximal value is sent to the local optimum variable bestSmellbestIndex of the current iteration:  
\[[bestSmellbestIndex1] = \max(Smell1_{i}), \tag{27}\] \[[bestSmellbestIndex2] = \max(Smell2_{i}),\] (28) \[[bestSmellbestIndex3] = \max(Smell3_{i}),\] (29) \[[bestSmellbestIndex4] = \max(Smell4_{i}). \tag{30}\]  
Step 6: Compare bestSmellbestIndex with the global optimum value bestSmell, and update the bestSmell to keep the best smell value in all generations. Then, the fruit fly swarm will use vision to fly towards that location. This process can be expressed as the following Equations (31)-(33). The parameter bestIndex represents the global optimum flies.  
\[Smellbest=bestSmell, \tag{31}\] \[X_{axis} = X(bestIndex),\] (32) \[Y_{axis} = Y(bestIndex). \tag{33}\]  
Step 7: Find the optimal value and end the optimization process.