The MFO algorithm depends on the route strategy of moths in nature [40]. Those fly in night by keeping up an adjusted edge with respect to the moon, a particularly convincing instrument for going in a straight line for long separations. The moths fly in spiral route and follow the light, when the light source is very near. The moth in the long run centers toward the light. If moths are to be considered as search agents and flames to be the solution, then the solution can be reached very quickly through this algorithm. The details of the algorithm are given in [40, 41]. The controller parameters to be tuned by proposed algorithm are the search agents. Keeping in view minimum objective function in Eq. (26), the initial solution matrix for controller parameters is formed. The objective function is minimized by MFO algorithm by optimizing the controller parameters. The inputs to the MFO program are the errors (\(\left| {\Delta \omega } \right|\,\,{\text{and}}\,\,\left| {\Delta V_{\text{t}} } \right|\) or \(\left| {\Delta F_{1} } \right|,\left| {\Delta F_{2} } \right|,\left| {\Delta P_{\text{tie}} } \right|,\left| {\Delta V_{{{\text{t}}1}} } \right|\,\,\,{\text{and}}\,\,\,\left| {\Delta V_{{{\text{t}}2}} } \right|\)), and outputs are the controller parameters values (*K*_{P}, *K*_{I}, *K*_{D}, λ and *µ*). The objective value is calculated in the Simulink model file and transferred to .mfile through workspace. The objective function values are used to access the populations. The best agent is chosen in each iteration with minimum objective function value, and over the course of iterations the best position is evaluated and ranking of agents are done. The optimal variables (gains) of the controller are found from the best agents at the end of the iterations.

The following steps are involved in the proposed algorithm:

The arrangement of moths spoke to in a lattice frame is as given below:

$$M = \left[ {\begin{array}{*{20}c} {m{}_{1,1}} &\quad {m_{1,2} } &\quad \cdots &\quad \cdots &\quad {m_{1,d} } \\ {m_{2,1} } &\quad {m_{2,2} } &\quad \cdots &\quad \cdots &\quad {m_{2,d} } \\ \vdots &\quad \vdots &\quad \vdots &\quad \vdots &\quad \vdots \\ {m_{n,1} } &\quad {m_{n,2} } &\quad \cdots &\quad \cdots &\quad {m_{n,d} } \\ \end{array} } \right]$$

(28)

where the number of moths and the number of variables (dimensions) are denoted by \(n\) and \(d\), respectively.

For all the moths, the corresponding fitness values can be sorted in an array form as follows:

$${\text{OM}} = \left[ {\begin{array}{*{20}c} {{\text{OM}}_{1} } \\ {{\text{OM}}_{2} } \\ \vdots \\ {{\text{OM}}_{n} } \\ \end{array} } \right]$$

(29)

A framework like the moth matrix and flame matrix is considered as:

$$F = \left[ {\begin{array}{*{20}c} {F{}_{1,1}} &\quad {F_{1,2} } &\quad \cdots &\quad \cdots &\quad {F_{1,d} } \\ {F_{2,1} } &\quad {F_{2,2} } &\quad \cdots &\quad \cdots &\quad {F_{2,d} } \\ \vdots &\quad \vdots & \quad \vdots & \quad \vdots & \quad \vdots \\ {F_{n,1} } & \quad {F_{n,2} } & \quad \cdots & \quad \cdots & \quad {F_{n,d} } \\ \end{array} } \right]$$

(30)

The dimensions of \(M\) and \(F\) arrays are equal. For the flames, the corresponding fitness values can be sorted in an array form as follows:

$${\text{OF}} = \left[ {\begin{array}{*{20}c} {{\text{OF}}_{1} } \\ {{\text{OF}}_{2} } \\ \vdots \\ {{\text{OF}}_{n} } \\ \end{array} } \right]$$

(31)

It ought to be noted here that moths and flames are both potential solutions. The moths are real pursuit operators that navigate around the search space, whereas flames are the best position for moths that gets so far. In this way, every moth seeks around a flag (flame) and updates it if there should arise an occurrence of finding a superior solution.

The MFO algorithm has three fundamental parts that gauge the arrangement and might be expressed as follows:

$${\text{MFO}} = \left( {I,\,P,\,T} \right)$$

(32)

The \(I\) generates a random population of moths and corresponding fitness value. It may be expressed as follows:

$$I:\varphi \to \left\{ {M,\,{\text{OM}}} \right\}$$

(33)

The \(P\) function is the function that decides the movement of the moths around the search space. This function eventually returns to its updated form of the matrix of \(M\) after receiving it.

The \(T\) function returns true if the termination criterion is satisfied and otherwise false.

$$T:M \to \left\{ {{\text{true}},\,{\text{false}}} \right\}$$

(35)

Then, the function \(I\) has to compute the objective function values after generating initial solutions.

There are two other arrays that define the upper and the lower bounds of the variables (\({\text{ub}}\) and \({\text{lb}}\)). The matrixes may be stated as follows:

$${\text{ub}} = \left[ {{\text{ub}}_{1} ,\,{\text{ub}}_{2} ,\,{\text{ub}}_{3} , \ldots {\text{ub}}_{n - 1} ,\,{\text{ub}}_{n} } \right]$$

(36)

where \({\text{ub}}_{i}\) represents the upper bound of the \(i{\text{th}}\) variable.

$${\text{lb}} = \left[ {{\text{lb}}_{1} ,\,{\text{lb}}_{2} ,\,{\text{lb}}_{3} ,\, \ldots {\text{lb}}_{n - 1} ,\,{\text{lb}}_{n} } \right]$$

(37)

where \({\text{lb}}_{i}\) represents the lower bound of the \(i{\text{th}}\) variable.

The position of each of the moths is updated with respect to a flame using the equation stated below:

$$M = S\left( {M_{i} ,\,F_{j} } \right) \to M$$

(38)

where \(M_{i}\) indicates the \(i{\text{th}}\) moth, \(F_{j}\) indicates the \(j{\text{th}}\) flame and \(S\) is the spiral function.

Keeping in mind the starting point, end point and boundary condition, a logarithmic spiral is defined for the MFO algorithm as presented in Eq. (19). It defines the next position of a moth with respect to a flame:

$$S\left( {M_{i} ,\,F_{j} } \right) = D_{i} \cdot e^{\text{bt}} \cdot \cos \left( {2\pi t} \right) + F_{j}$$

(39)

where \(D_{i}\) shows the distance of the \(i{\text{th}}\) moth for the \(j{\text{th}}\) flame, \(b\) is a constant for representing the shape of the logarithmic spiral and \(t\) is a random number in \(\left[ { - 1,\,\,1} \right]\). The variable \(D_{i}\) may be calculated as follows:

$$D_{i} = \left| {F_{j} - M_{i} } \right|$$

(40)

The best solutions acquired so far are considered as the flames and stored in \(F\) matrix. The number of flames is diminished adaptively over the course of iterations as follows:

$${\text{Flame}}\;{\text{number}} = {\text{round}}\left( {N - l * \frac{N - 1}{T}} \right)$$

(41)

where \(l\) is the current number of iteration, \(N\) is the maximum number of flames and \(T\) indicates the maximum number of iterations. In the initial steps of iterations, there is \(N\) number of flames. The moths update their positions just as for the best flame in the last steps of iterations.

The variables named \(K_{\text{P}}\), \(K_{\text{I}}\) and \(K_{\text{D}}\) in PID controller and \(K_{\text{P}}\), \(K_{\text{I}}\), \(K_{\text{D}}\),\(\lambda\) and \(\mu\) in FOPID controller are tuned by proposed algorithm, keeping in view minimum objective function in Eq. (24). The best agent is selected in each iteration with minimum objective function, and over the course of iterations, the best position is evaluated and ranking of agents are done. The optimal variables (gains) of the controller are found from the best agents at the end of the iterations.