# Artificial Flora (AF) Optimization Algorithm
## 2 Artificial Flora Algorithm
### The Proposed Algorithm Flow and Complexity Analysis  
The basic flowchart of the proposed AF algorithm is shown in Figure 2. The main steps of artificial flora algorithm are as follows:  
1. Initialization according Equation (4), generate \(N\) original plants;
2. Calculate propagation distance according Equation (1), Equation (2) and Equation (3);
3. Generate offspring plants according Equation (5) and calculate their fitness;
4. Calculate the survival probability of offspring plants according to Equation (6)--whether the offspring survives or not is decided by the roulette wheel selection method;
5. If there are plants that survive, randomly select \(N\) plants as new original plants. If there are no surviving plant, generate new original plants according to Equation (4);
6. Record the best solution;
7. Estimate whether this meets the termination conditions. If so, output the optimal solution, otherwise goto step 2. Figure 2: Algorithm flow of artificial flora algorithm. Based on the aforementioned descriptions, the AF algorithm can be summarized as the pseudo code shown in Table 1.  
The time complexity of the algorithm can be measured by running time \(t\)(s) in order to facilitate the comparison of various algorithms. \[t(s)=t_{A}\times A(s)+t_{B}\times B(s)+...+T_{P}\times P(s) \tag{7}\]  
where \(t_{A}\), \(t_{B}\), \(t_{P}\) are the time required to perform every operation once and \(A\)(s), \(B\)(s), \(P\)(s) are the number of each operation. In the artificial flora algorithm, the number of original plants is \(N\), and the maximum branching number \(M\) is the number of seeds that one original plant can generate. \(t_{1}\) is the time to initialize population. \(t_{2}\)is the time of calculating propagation distance. \(t_{3}\) is the time to update the plant position. \(t_{4}\) is the time to calculate the fitness. \(t_{5}\) is the time to calculate the survival probability. \(t_{6}\) is the time to decide which plant is alive this generation using roulette wheel selection method. The time complexity analysis of this algorithm is shown in Table 2. Therefore, we can see that the time complexity of artificial flora algorithm is O(\(NM\)) in Table 2. \begin{table}
\begin{tabular}{l l l} \hline \hline
**Input**: times: Maximum run time & \multicolumn{1}{c}{} & \\ \(M\): Maximum branching number & \multicolumn{1}{c}{} & \\ \(N\): Number of original plants & \multicolumn{1}{c}{} & \\ \(p\): survival probability of offspring plants & \multicolumn{1}{c}{} & \\ \(t=0\); initialize the population and define the related parameters & \multicolumn{1}{c}{} & \\ Evaluate the \(N\) individuals’ fitness value, and find the best solution & \multicolumn{1}{c}{} & \\ While (\(t<\) times) & \multicolumn{1}{c}{} & \\ For \(i=1\):N*\(M\) & \multicolumn{1}{c}{} & \\ New original plants evolve propagation distance (According to Equation (1), Equation (2) and & \multicolumn{1}{c}{} & \\ Equation (3)) & \multicolumn{1}{c}{} & \\ Original plants spread their offspring (According to Equation (5)) & \multicolumn{1}{c}{} & \\ If \(rand\)(0,1) \(>\)\(p\) & \multicolumn{1}{c}{} & \\ Offspring plant is alive & \multicolumn{1}{c}{} & \\ Else & \multicolumn{1}{c}{} & \\ Offspring is died & \multicolumn{1}{c}{} & \\ End if & \multicolumn{1}{c}{} & \\ End for & \multicolumn{1}{c}{} & \\ Evaluate new solutions, and select \(N\) plants as new original plants randomly. & \multicolumn{1}{c}{} & \\ If the new solution’s better than their previous one, new plant will replace the old one. & \multicolumn{1}{c}{} & \\ Find the current best solution & \multicolumn{1}{c}{} & \\ \(t=t+1\); & \multicolumn{1}{c}{} & \\ End while & \multicolumn{1}{c}{} & \\
**Output**: Optimal solution & & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Pseudo code of artificial flora algorithm.