# Applying Particle Swarm Optimization Variations to Solve the Transportation Problem Effectively
## 3 Particle Swarm Optimization (PSO)  
The Particle Swarm Optimization (PSO) algorithm is considered to be one of the modern innovative heuristic algorithms since its methodology over the years has become extremely prevalent due to its simplicity of implementation; it leads very easily to satisfactory solutions [15]. According to the PSO algorithm, the collective behavior of animals has been analyzed in detail with an eye forward to function as a robust method in order to solve optimization problems in a wide variety of applications [16].  
In PSO, each candidate solution can be defined as a particle and the whole swarm can be considered as the population of the algorithm. The particles improve themselves by cooperating and sharing information among the swarm, and they succeed in learning and improving to provide the highest possible efficiency. More precisely, each particle through the search space is intended to find the best value for its individual fitness and, simultaneously, to minimize the objective function by satisfying all the constraints of the problem. Each particle is studied from a perspective that contains three different parameters: position; velocity; and its previous best positions.  
Consequently, in \(n\)-dimensional search space, each particle of the swarm is represented by \(x_{ij}=\left(x_{i1},\,x_{i2},\,\ldots,\,x_{ij}\right)\), and the equation of its position is as follows:  
\[x_{ij}(t+1)=x_{ij}(t)+v_{ij}(t+1),\,\,i=1,\,2,\ldots,n\,\,\kappa\alpha\,\,j=1, \,2,\ldots,\,n, \tag{5}\]  
where \(x_{ij}(t+1)\) is the current position, \(x_{ij}(t)\) is the previous position and \(v_{ij}(t+1)\) is the velocity which determines the movement of each particle in the current iteration (\(t+1\)).  
Respectively, the velocity of the particle is denoted by \(v_{ij}\) and is given by the following equation:  
\[\begin{array}{c}v_{ij}(t+1)=w\,v_{ij}(t)+c_{1}r_{1}\Big{(}pbest_{ij}(t)-x_{ ij}(t)\Big{)}+c_{2}r_{2}\Big{(}gbest_{ij}(t)-x_{ij}(t)\Big{)},\\ i=1,\,2,\ldots,n\,\,\kappa\alpha\,\,j=1,\,2,\ldots,n.\end{array} \tag{6}\]  
where  
* \(v_{ij}(t+1)\) denotes the velocity in the current iteration and \(v_{ij}(t)\) is the velocity in the previous iteration.
* \(w\) is the inertia weight, used to balance the global exploitation and local exploitation, providing a memory of the previous particle's direction which prevents major changes in the suggested direction of the particles.
* \(r_{1}\) and \(r_{2}\) are two variables which are randomly derived from uniform distribution in range [0, 1].
* \(c_{1}\) and \(c_{1}\) are defined as \"acceleration coefficients\" which have a huge effect on the efficiency of the PSO method. The constant \(c_{1}\) conveys how much confidence a particle has in itself, while \(c_{2}\) expresses how much confidence a particle has in the swarm.
* The variable \(pbes_{ij}(t)\) is the best position of the particle until the iteration \(t\), whereas \(gbest_{ij}(t)\) is the finest position of the whole swarm until the same iteration.
* The term \(c_{1}r_{1}\Big{(}pbest_{ij}(t)-x_{ij}(t)\Big{)}\) is known as the cognitive component; it acts as a kind of memory that stores the best previous positions that the particle has achieved.  
The cognitive component reflects the tendency of the particles to return to their best positions.
* The term \(c_{2}r_{2}\Big{(}gbest_{ij}(t)-x_{ij}(t)\Big{)}\) is called the social component. In this particular case, the particles behave according to the knowledge that they have obtained from the swarm, having as a guide the swarm's best position.  
The acceleration coefficients \(c_{1}\) and \(c_{2}\), together with the random variables \(r_{1}\) and \(r_{2}\), affect to a great extent the evolution of cognitive and social component and hence the velocity value, which, as is known, is mainly responsible for the ultimate direction of the particles.