# Online Identification of Photovoltaic Source Parameters by Using a Genetic Algorithm
## 2 The Optimized SDM Parameter Identification Method Based on Genetic Algorithm
### Genetic Algorithm Fitness Function Calculation  
The GA fitness function is evaluated by accounting for the deviation from the desired goals. A first error term is the root mean square error (RMSE) of the fitted I-V curve, given M experimental test points. Since the I-V curvature changes significantly around the MPP, the M points must be selected so as to include the MPP. For each test point \(\mathbf{P_{i}}=[\mathbf{V_{i}},\mathbf{I_{i}}]\), the measured current \(\mathbf{I_{i}}\) must be compared with the current that satisfies the implicit and transcendental SDM equation (1) for \(V_{pv}=\mathbf{V_{i}}\). To this aim, the explicit version of (1) can be obtained using the Lambert-W function:  
\[I_{pv,i}=-\frac{\eta\cdot V_{t}}{R_{s}}\cdot W(\theta_{I})+\frac{I_{ph}+I_{s}- V_{pv,i}/R_{h}}{1+R_{s}/R_{h}} \tag{2}\]  
with:  
\[\theta_{I}=\frac{\left(\frac{R_{h}\cdot R_{s}}{R_{h}+R_{s}}\right)\cdot I_{s }\cdot e^{\frac{R_{h}\cdot R_{s}}{\left(I_{ph}+I_{s}\right)+R_{h}\cdot V_{pv, i}}{\eta\cdot V_{t}\cdot(R_{h}+R_{h})}}}{\eta\cdot V_{t}} \tag{3}\]  
In [10,22], many details and useful references about the Lambert-W function can be found. The numerical calculation of the Lambert-W function has been implemented in C language as shown in [23].  
Once \(I_{pv,i}\) is known for \(i\) in \(\{1,\,2,...,\,M\}\), the RMSE of the fitting curve can be computed as:  
\[\mathbf{RMSE}=\sqrt[]{\frac{1}{M}\sum_{i=1}^{M}(I_{pv,i}-\mathbf{I_{i}})^{2}} \tag{4}\]Moreover, to constrain the P-V curve to have its maximum in the MPP, the error on the derivative of the power in the MPP is also calculated, as shown in [24], thus improving the convergence and precision of the genetic algorithm [12]:  
\[\mathbf{E_{MPP}=}\frac{dP}{dV}\Bigg{|}_{MPP}=\frac{-\frac{1}{R_{h}}-\frac{I_{s}}{ \eta\cdot V_{t}}\cdot e^{\frac{V_{MPP}+I_{MPP}\cdot Rs}{\eta V_{t}}}}{1+\frac{R_ {s}}{R_{h}}+\frac{R_{s}\cdot I_{s}}{\eta\cdot V_{t}}\cdot e^{\frac{V_{MPP}+I_{MPP }\cdot Rs}{\eta V_{t}}}}\cdot V_{MPP}+I_{MPP} \tag{5}\]  
To account for both types of errors, which are independent, they must be combined in quadrature. Furthermore, since the considered genetic algorithm maximizes the objective function, the latter has been made equal to the reciprocal of the overall error:  
\[\mathbf{Fitness}=\frac{1}{\sqrt{E_{MPP}^{2}+RMSE^{2}}} \tag{6}\]  
It is worth noting that in [12; 17], the fitness function is calculated by selecting test points from \(I_{sc}\) to \(V_{oc}\); in this paper, instead, all the points are concentrated close to the MPP. Figure 2 shows the difference and highlights that the new approach allows reducing the power loss significantly because the system is controlled to operate not too far from the MPP. It is also evident that the distribution of test points must be large enough to easily catch the I-V curvature; thus, the choice of the number and position of test points around the MPP must be made as a trade-off between power loss reduction and precision in the SDM parameters' identification. This aspect is described in Section 3.1, where some experimental cases are proposed.