## 3 Results and Discussion
### Genetic Algorithm Optimization  
During this last step of the research activity, a genetic algorithm was developed for the definition of optimal empirical models that relate bacterial growth with process parameters and products, such as fermentation time, pH, pH control, as well as lactic acid production. In particular, the proposed empirical models are of the polynomial type as described by Equation (5). For the implementation of the algorithm, a first attempt was made considering a polynomial consisting of only two terms, to simulate the logistic model. Equation (7) reports the chosen model:  
\[X(t,pH)=c_{0}+c_{1}t^{p_{1}}pH^{p_{2}} \tag{7}\]  
where \(X(t,pH)\) represents the biomass concentration as a function of fermentation time and pH, \(c_{0}\) the known term, \(c_{1}\) the empirical coefficient that multiplies the two terms \(t\) and \(pH\) respectively to the powers \(p_{1}\) and \(p_{2}\). In particular, the space of possible powers is discrete, that is \([-1,0,1]\), and contains \(3^{2}=9\) models, where the 3 is given by the number of powers and the power 2 by the number of variables in each term. In general, setting the total of individuals at 1000, it took less than 10 generations to reach convergence. Furthermore, the achievement of the global minimum was verified by calculating a further 50 generations. Equation (8) reports the obtained empirical model, which represents the decoding of the solution of the algorithm \(\{1,\,-1\}\), while Figure 8 shows the resulting trend compared with the experimental one for the case in which there is no pH control:  
\[X(t,pH)=-0.063367+0.47026\frac{t}{pH} \tag{8}\]  
Figure 7: Trends of the bacterial growth rates estimated using the logistic model: (**a**) without and (**b**) under pH control. As shown in Figure 8a, the suggested equation does not allow to reproduce the growth curve during the initial lag phase, while it reproduces in a sufficiently accurate way the exponential phase and the stationary phase, as shown in Figure 8b, where the value of normalized RMSE error was calculated according to Equation (9):  
\[NRMSE=\frac{\sqrt{\left(y_{GA}-y\right)^{2}}}{y} \tag{9}\]  
In the latter equation, \(y_{GA}\) represents the output of the model optimized by the genetic algorithm and \(y\) is the corresponding experimental value. The numerator represents the RMSE error which is then normalized with the experimental reference value (\(y\)) to compare the various stages of the fermentation process. To improve the interpolation capacity of the algorithm, it was decided to introduce a new term, the production of lactic acid (\(X_{AL}\)), defining a new regression model, as described by Equation (10):  
\[X(t,pH,X_{AL})=c_{0}+c_{1}t^{p_{1},1}pH^{p_{21}}X_{AL}^{p_{3},1}+c_{2}t^{p_{1},2}pH^{p_{22}}X_{AL}^{p_{3},2} \tag{10}\]  
With this improved model, \(3^{3\times 2}\) = 729 possible solutions were considered. Again, setting the total of individuals at 1000, it took less than 10 generations to reach convergence. Furthermore, the achievement of the global minimum was verified by calculating a further 50 generations. Equation (11) describes the obtained model:  
\[X(t,pH,X_{AL})=-0.52801+0.28568\frac{tX_{AL}}{pH}+0.52223\frac{1}{pH} \tag{11}\]  
Figure 9 shows the resulting trend compared with the experimental one, from which it is possible to notice how the addition of the lactic acid production term allows reproducing, even if not very accurately, also the initial lag phase, and slightly improving the ability to replicate the exponential and stationary phases. In fact, the \(NRMSE\) value for the lag phase decreases from 10.10 and 5.31 down to 0.64 and 0.77 at 0 h and 2 h, respectively, from an average 0.81 of the exponentials phase down to 0.28, and from an average 0.14 of the stationary phase down to 0.10. Figure 8: Genetic algorithm optimization by considering a single regression term and the response variable as a function of time and pH in case of uncontrolled pH: (**a**) comparative trends and (**b**) normalized RMSE.