2.4.2. PSO Algorithm

Particle swarm optimization (PSO) is a heuristic algorithm inspired by the choreography of a flock of birds [41]. In the space of real numbers, every single possible solution is modeled as a particle moving through the hyperspace of the problem. At each iteration, the velocities of individual particles are stochastically adjusted based on the best historical position for the particle itself and the best position in the neighborhood. Both the best particle and the neighborhood best one are found based on a user defined fitness function. The flow chart of the integration of the simulation software with the proposed PSO algorithm for the positioning and dimensioning is shown in Figure 4. The characteristics of the route and those of the rolling stock (expressed in Table 1) are provided as input to the software described in Section 2.1. The power supplied by the supply line is then estimated by calculating the consumption of the vehicle. The traffic file produced is the input to the electrical calculation software described in Section 2.2 (together with the other values listed in Table 2 which are entered by the user) who is able to calculate the energy supplied by the substations for a particular configuration of location and sizing. The objective function in Equation (21) is thus calculated and finally, the PSO returns a feasible and better solution than the original one.

**Figure 4.** Flowchart of the PSO-based solution algorithm.
