3.3.2. EV Charging Based on Particle Swarm Optimization (PSO)

The PSO algorithm is inspired by birds' swarm behavior flocking and fish schooling for guiding the particles to find the optimal global solution [64]. Generally, in PSO, the population particles are spread randomly and assumed to be flying in the search space. The information exchange between the particles influences the position and velocity of each particle iteratively. Based on the personal experience, each particle possesses the best solution achieved so far. A global best solution is found from the social experience of the swarm. The impact of personal best and global best is balanced by using a randomized correction factor.

In general, *X<sup>i</sup>* represents the existing position of the *i*th particle, *V<sup>i</sup>* is the velocity of the *i*th particle with a distance in a unit time, *Pbest* denotes the individual best position of the *i*th particle (local best), and *Gbest* represents the global best value obtained. Mathematically, the velocity and position of each particle are updated respectively, as follows:

$$V\_{i,j}^{k+1} = \left(\omega \times V\_{i,j}^{k}\right) + c\_1 \left(rrand1 \times \left(Pbest\_{i,j} - X\_{i,j}^{k}\right)\right) + c\_2 \left(rrand2 \times \left(Gbest\_{i,j} - X\_{i,j}^{k}\right)\right) \tag{9}$$

$$X\_{i,j}^{k+1} = X\_{i,j}^k + V\_{i,j}^{k+1} \tag{10}$$

where *V<sup>i</sup>* (*k*) and *X<sup>i</sup>* (*k*) are the velocity and position of the *i*th particle at iteration *k*. So that:

$$V\_{\mathbf{i},\mathbf{j}} = \left(V\_{\mathbf{i},\mathbf{1'}\prime}V\_{\mathbf{i},\mathbf{2'}\prime} \dots V\_{\mathbf{i},\mathbf{j}'}\right) \tag{11}$$

$$X\_{i,j} = \left(X\_{i,1'}, X\_{i,2'}, \dots, X\_{i,j'}\right) \tag{12}$$

Also, *c*<sup>1</sup> and *c*<sup>2</sup> are the coefficients of cognitive and social acceleration, which exchange the impact of the top solutions on the particle's velocity. Further, *rand*<sup>1</sup> and *rand*<sup>2</sup> are random numbers range between 0 and 1. inertia weight ω is linearly reduced from ωmax to ωmin with the iteration as given in Equation (13). Finally, the cost function, or the global best, is calculated further as shown in Equation (14).

$$
\omega = \omega\_{\text{max}} - \left(\frac{\omega\_{\text{max}} - \omega\_{\text{min}}}{k\_{\text{max}}}\right) \mathbf{k} \tag{13}
$$

$$\text{Gbest}\_{i,j}(k+1) = \begin{cases} \text{Gbest}\_{i,j}(k) \text{ if } f(\text{Pbest}\_{i,j}(k+1)) \ge f(\text{Gbest}\_{i,j}(k)) \\ \text{Pbest}\_{i,j}(k) \text{ if } f(\text{Pbest}\_{i,j}(k+1)) < f(\text{Gbest}\_{i,j}(k)) \end{cases} \tag{14}$$

The step by step procedure of implementing the PSO algorithm is given as follows:

Step 1: Initialize the number of EVs, number of chargers, capacity of EVs, and capacity of charger, and the population size. Each EV is assigned to different chargers randomly in the population, and the charging scheduling is generated.

