# An Evolutionary-Based MPPT Algorithm for Photovoltaic Systems under Dynamic Partial Shading
## 2 Evolutionary-Based MPPT Algorithm for PV System Power Extraction
### PSO-Based Algorithm Implementation  
PSO is an evolutionary algorithm based on the modelling of group interaction between independent _agents_, also called _particles_, that share information about their respective search process in order to find a global maximum or minimum of a specific fitness function. Each particle represents a candidate solution and their movement in the search domain depends both on its own previous best position and the previous best position attained among all the particles. This behavior is mathematically expressed by two equations that define the velocity, \(v_{i}\), and the position, \(x_{i}\), of the \(i\)-th agent at the \(k\)-th step of the searching process:  
\[v_{i}^{k+1}=w\cdot v_{i}^{k}+c_{1}\cdot r_{1}\cdot\left(p_{best,i}-x_{i}^{k} \right)+c_{2}\cdot r_{2}\cdot\left(g_{best}-x_{i}^{k}\right) \tag{1}\]  
\[x_{i}^{k+1}=x_{i}^{k}+v_{i}^{k+1} \tag{2}\]  
where \(w\) is the inertia weight, \(c_{1}\) and \(c_{2}\) are the acceleration coefficients, \(r_{1}\) and \(r_{2}\) are random numbers between 0 and 1, \(p_{best,i}\) is the best position attained by the \(i\)-th particle and \(g_{best}\) is the best position attained among all the particles. It was found that a basic problem in the application of the PSO for the MPPT system is in its random nature [16]. Very low values of \(r_{1}\) and \(r_{2}\) result in a very low velocity, thus a large number of iteration is required to reach the solution. On the other hand, too large changes in the velocity might cause the particles to move far from the neighborhood of the global maximum, opening up the possibility of converging to a local maximum instead of the global one. Moreover, in a partially shaded PV generator, the distance between the two consecutive peaks in the P-V curve is quite constant, about 80% of the open voltage of the string of PV cells connected in parallel with a bypass diode. The goal of a MPPT algorithm is to maximize the PV output power by adjusting the duty cycle of the power converter dedicated to this function. The search of the global maximum using PSO is simple due to the fact that for this problem only a single dimensional search space is needed: the particles represent the duty cycle values and the PV generated power is the fitness function. The PSO-based MPPT algorithm presented in this work is based on a more deterministic structure, removing the random factors in (1). The velocity is limited to comply with the distance between the two peaks by tuning the coefficients \(c_{1}\) and \(c_{2}\). The search of the global maximum in the PSO-based MPPT algorithm is mathematically expressed by two equations that define the variation of the duty cycle, \(\Delta d_{i}\), and the duty cycle, \(d_{i}\), corresponding to the \(i\)-th agent at the \(k\)-th step of the searching process:  
\[\Delta d_{i}^{k+1}=w\cdot d_{i}^{k}+c_{1}\cdot\left(d_{best,i}-d_{i}^{k} \right)+c_{2}\cdot\left(D_{best}-d_{i}^{k}\right) \tag{3}\]  
\[d_{i}^{k+1}=d_{i}^{k}+\Delta d_{i}^{k+1} \tag{4}\]  
where \(w\) is the inertia weight, \(c_{1}\) and \(c_{2}\) are the acceleration coefficients, \(d_{best,i}\) is the duty cycle corresponding to the maximum PV output power detected by the \(i\)-th particle and \(D_{best}\) is the duty cycle corresponding to the maximum PV output power detected among all the particles. Figures 1 and 2 show the flowcharts of the proposed PSO-based MPPT algorithm; they represent the program of the MPPT controller that runs at every \(n\)-th time interval. The proposed PSO-based MPPT algorithm is organized in the following seven steps. 1. _Activation of_ the _MPPT algorithm_. First, the MPPT controller checks whether it is necessary to activate the search for a new GMPP by comparing the actual PV power, \(P_{PV}(n)\), with the previously recorded maximum power, \(P_{MPP}\). The absolute value of the difference between these powers over a threshold triggers the activation of the search for a new GMPP. 2. _PSO Initialization_. This step is the beginning of each GMPP searching process.