## 4 Modeling and Prediction
### Evolution Model  
For the black box model of the evolution of battery performance, a GA [28] was used. In this case, the output of the algorithm is the evolution of the internal resistance of the battery, whose growth indicates aging, as seen in the analysis. After performing the previous data analysis, the following seven parameters that are used are (Figure 21) the following:  
* Number of cycles (i). * Training/competition flight (f). * Discharged capacity, based on historical average discharged capacity (c). * Voltage dispersion between cells (d). * Difference between input and output voltage in each charge (v). * Days of pre-storage (s). * Initial factory resistance (R0). To recreate the evolution of internal resistance in each cycle of charge and discharge, the algorithm operates based on the increase in resistance in that cycle, using Equation (4). \[ \begin{array}{c}R_{i}=R_{i-1}+\Delta R_{i}\\ \Delta R_{i}=A\cdot i+B\cdot f+C\cdot c+D\cdot d+E\cdot v+F\cdot s+G\end{array}  \tag{4}\]  
Figure 21: Black box model flow chart. The constants A, B, C, D, E, F, and G are the solution parameters to be optimized by the GA through creating, sorting, crossing, and mutation; and that will lead to the final solution to the problem (Figure 22). To have a proper relationship between shorter computation time and greater model accuracy, a population of 1000 members was chosen. Considering that the seven batteries are evaluated, the computation time between iterations is approximately 0.2 s, using a computer with 8 GB RAM and an Intel Core i5-7200U processor. The time it takes the algorithm to find a suitable solution depends on its own evolution and is random. The average duration is estimated at around 2.6 min, with about 750 iterations. For the first population, a number n of random combinations of the constants of the problem are created. Each of these combinations is a possible solution. Each of these combinations is then evaluated with respect to the actual evolution of internal resistance. To achieve this, the evolution of the resistance of the battery resulting from the application of each possible solution is recreated and the difference with the real value in each cycle is obtained. The total sum of the differences in each cycle squared makes up the total evaluation of the solution, which will be better when lower (Equation (5)). \[Eval^{n}=\sum_{i}(R_{i}^{n}-R_{i})^{2} \tag{5}\]  
This process is carried out for all the batteries that are under study, and the total sum of the evaluations obtained by combination is the total evaluation of each proposed solution. In this way, solutions that present particularly good results in some batteries and unsatisfying results in others are eliminated. The process is repeated until the stop criteria are met. Batteries 1, 2, and 3 were used to train the initial model, because they correctly represented an example of a medium, short, and long-life battery, respectively. The results obtained are presented in Table 2 and Figure 23. \begin{table}
\begin{tabular}{c c c c c c c} \hline
**A** & **B** & **C** & **D** & **E** & **F** & **G** \\ \hline
0.00158 & 0.13230 & 0.76660 & 0.35946 & 0.05849 & 0.02055 & \(-\)1.40986 \\ \end{tabular}
\end{table} 
Table 2: Solution parameters results of first model for batteries 1, 2, and 3. Figure 22: Genetic algorithm model flow chart. The accuracy of the first model for batteries 1, 2, and 3 was remarkably high. The R\({}^{2}\) ratings for each battery were R\({}^{2}\)(B1) = 0.9653; R\({}^{2}\)(B2) = 0.9974; R\({}^{2}\)(B3) = 0.9644. However, when testing this first model with some batteries which were not used to train the algorithm, it was found that the results in these cases were not satisfactory (Figure 24). Figure 23: Results of first model for batteries 1, 2, and 3. Figure 24: Results of first model applied on batteries 4, 5, 6, and 7.