## 1 Introduction  
With the rapid development of micro-grid technologies in recent years, modern smart power grids, characterized by diversified energy types [1; 2], an individualized energy supply [3; 4], a multilayer control system [5; 6], multi-type network structures [7; 8], and flexible working modes [9; 10] have gradually come into being. Since micro-grids have characteristics such as strong intermittency, low damping of output power, and high generation-demand sensitivity [11], the core goal of research on micro-grid control methods is to realize a stable, rapid, and reliable control system. As Figure 1 shows, in a modern micro-grid, primary control-level research has mainly focused on inverter output control, power sharing control [9], and coordinated control of inverters [12]. Secondary control mainly includes the control of the frequency and voltage error, and superior control mainly involves energy management and dispatch control. In secondary control of a micro-grid, primary power dispatch control and voltage/current source inverter (VSI/CSI) internal output control jointly comprise a complicated, closed-loop control network consisting of multiple proportional integral (PI) controllers in serial and parallel structures. Since secondary control requires cascade control over multiple underlying inverters via bus communication, its control network structure is more complicated and changeable. Although different control levels have different control time domains [13], the uncertainty and time delay in control network communications will seriously influence the control performance of the entire system [14]. In the field of control science, tuning and optimization of the controller parameters are often carried out to improve the performance of a complicated PI-based control system [15]. However, in the process of parameter tuning, the control objects of different parameters vary in their damping coefficients, which leads to different overshoots, oscillations, durations of rise, and durations of adjustment [16]. Therefore, it is of great significance to explore the application of parameter tuning methods of PI controllers in improving the performance of the underlying control system of a micro-grid [17]. Research on PI controller parameter tuning can be divided into two major categories: offline tuning [18; 19] and online tuning [20; 21]. In [PERSON]'s work [22], online optimization tuning is conducted for PI controller parameters of micro-grid inverters by the particle swarm optimization algorithm (PSO) and error performance index methods. However, as the update calculation process of an individual particle is relatively complex, the overall calculation time is long, which makes it more suitable for offline tuning [23; 24]. Compared with PSO, the fruit fly optimization algorithm (FOA) [25] requires less in terms of the calculation process and a simpler structure, with the advantage of shorter calculation time for parameter tuning. Research works [26; 27; 28] have discussed the feasibility of optimizing PI controller parameter tuning in an industrial process by using FOA, and they have provided guidance for this paper. In this paper, by taking the typical active and reactive power (PQ) control structure of the power controller, the voltage, and the current double closed-loop control structure in the internal output controller of the inverter in the micro-grid as the object of tuning, FOA is employed to study the methods of offline and online parameter tuning. Finally, simulation experiments for online PI parameter self-tuning optimization and offline PI parameter tuning in the same model environment are carried out to demonstrate the effectiveness of FOA in the tuning and optimization of the PI controller parameters of the inverter in the micro-grid. The rest of this paper is organized as follows.