## 4 Fuzzy Logic Controller Parameter Optimization Using Cuckoo Search Algorithm
### Initialization  
In the initialization phase, the CS algorithm initializes a set of solutions which are randomly sampled from the search space. For this purpose, the dimension of the solution and the length of the population must be defined.  
The dimension of the solution, \(d\), is defined according to the total number of parameters to optimize. In accordance with the FLC designed in Section 3, these parameters are related to the MF's mapping and the RB. In this regard, both inputs (i.e., position error and derivative of error) and output (i.e., control signal) comprise five fuzzy sets and eleven parameters (since every fuzzy set is represented by a membership function of three variable positions except for both located at the maximum and minimum universe of discourse limits that have two fixed positions and one variable) whereas the RB includes twenty-five parameters. Considering all these values, each solution is represented with \(d=58\) parameters. The length of the population is fixed and a value of \(n=25\) is sufficient according to the literature [3]. In this regard, the initial random population is formulated as a \(n\)\({}_{x}\)\(d\) matrix where every row is a candidate solution of dimension \(d\).  
In order to preserve some order and symmetry in comparison with the MF's mapping and RB distribution, every initial random solution conforming the initial random population, is generated according to the initial parameter distribution presented in Figure 3 and Table 1, as follows:  
\[X_{Gi}=[X_{MFi},X_{RBi}] \tag{6}\]  
\[X_{MFi}=X_{MF(I)}+R \tag{7}\]  
\[R=[U(-5\%\cdot R_{Inp(1)},5\%\cdot R_{Inp(1)}),U(-5\%\cdot R_{Inp(2)},5\% \cdot R_{Inp(2)}),U(-5\%\cdot R_{Out},5\%\cdot R_{Out})] \tag{8}\]  
\[X_{RBi}=X_{RB(I)}+U(-1,1) \tag{9}\]  
where \(X_{MFi}\) represents a candidate initial solution for the MF's mapping sampled randomly from the search space which is limited according to the problem restrictions (i.e., inputs and output rangevalues of FLC designed in Section 3) and of dimension equal to the total number of MF parameters to optimize, \(X_{MF(l)}\) represents initial membership function's parameters according to Figure 3, \(R\) is a set of displacements constituted of three different subsets that correspond to vectors of random numbers drawn from a uniform distribution where \(R_{Imp}\), \(R_{Imp}\), and \(R_{Out}\) are the defined range for every input/output variable, respectively, and a design value of 5% has been defined with the aim that randomly generated solutions result rather similar to initial distributed ones (Figure 3), \(X_{RBi}\) represents a candidate initial solution for the RB sampled randomly from the search space which is limited according to the problem restrictions (i.e., linguistic labels corresponding to fuzzy sets whose MF are depicted in Figure 3) and of dimension equal to the total number of RB parameters to optimize, \(X_{RB(l)}\) represents initial RB parameters according to Table 1, \(U\) (\(-1\), \(1\)) is a set of integer rule-base displacements drawn from a uniform distribution, and \(X_{Gi}\) is a candidate initial solution (nest) comprising of \(X_{MFi}\) and \(X_{RBi}\) at an initial generation \(G_{i}\).  
Once the initial random population is created, the CS algorithm evaluates every candidate solution, so the best ones obtained a pass to the next generations. It is worth pointing out that, during a minimization/maximation process, the'selection of best' step results crucial so the best solution according to problem's objectives of optimization can be obtained at the end of the algorithm.  
Figure 4: Flowchart of the optimization process.