# Applying Particle Swarm Optimization Variations to Solve the Transportation Problem Effectively
## 4 The Basic PSO for Solving the TP
Balance one element in row \(k\) as: \(\mathit{particle(i).Position(a,l\_count)=particle(i).Position(a,l\_count)+1 neg}\)
15. end
16. \(l\_count=l\_count+1\)
17. end
18. end
19. end
20. end
```  
**Algorithm 3**Negative values repair algorithm  
```
1. Set as input \(\mathit{particle(i).Position}\)
2. Enter \(\mathit{Supply}\), \(\mathit{Demand}\)
3. \(\mathit{pos}=\mathrm{floor}(\mathit{particle(i).Position})\)
4. Set as \(\mathit{sumrow}\) the sum of the elements of the row. 5. Set as \(\mathit{sumcol}\) the sum of the column's elements
6. Take \(s=\mathit{Supply}-\mathit{sumrow}\)
7. Take \(d=\mathit{Demand}-\mathit{sumcol}\)
8. for\(u=1:m\)
9. for\(v=1:n\)
10. If\(s(u)\leqslant d(v)\)
11. \(\mathit{www}=\min(s(u),\,d(v))\)
12. \(\mathit{pos}(u,v)=\mathrm{pos}(u,\,v)+\mathit{www}\)
13. \(d(v)=d(v)-s(u)\)
14. \(s(u)=0\)
15. else if\(d(v)<s(u)\)
16. \(\mathit{www}=\min(s(u),\,d(v))\)
17. \(\mathit{pos}(u,v)=\mathrm{pos}(u,\,v)+\mathit{www}\)
18. \(s(u)=s(u)-d(v)\)
19. \(d(v)=0\)
20. end
21. end
22. end
23. Return particle().position = pos

## 5 Variations of PSO

This section presents two already-known and two new variations of the classical implementation of the PSO, which are presented and used in this contribution to solve the TP. These variations are investigated in order to improve the performance of the classical PSO algorithm. ### Decreasing Weight Particle Swarm Optimization (DWPSO)

The inertia weight \(w\) is the most influential parameter with respect to both the success rate and the function evaluation [18]. In DWPSO, the inertia factor is linearly decreasing. The decision to use this variation was not arbitrary; DWPSO is one of the classic and very effective PSO variations since its superiority remains imperishable over years. Through DWPSO, the algorithm focuses on diversity at former iterations and on convergence at latter ones [18]. The right and proper selection of the inertia weight provides a balance among global and local exploitation and results in fewer iterations, on average, to find a sufficiently optimal solution [19]. Exploitation is the capacity of particles to converge to the same peak of the objective function and remain there without wanting to obtain better solutions in their wider field. On the contrary, in the exploration condition, the particles are in constant search, discovering beneficial solutions. After constant research regarding the figurative of inertia weight, [PERSON] and [PERSON] concluded that values in the interval [0.9, 1.2] have a positive effect on the improvement of the solution [20]. A linearly decreasing inertia weight with \(c_{1}=2,c_{2}=2\) and \(w\) between 0.4 and 0.9 was used by [PERSON] and [PERSON], too. According to their claim, \(w_{new}\) is the new inertia weight, which linearly decreases from 0.9 to 0.4. Equation (7) for DWPSO is given as

\[w_{new}(t)=w_{max}-\frac{(w_{max}-w_{min})\cdot t}{t_{max}}, \tag{7}\]

where \(w_{max}\) is set as 0.9, performing extensive exploration, and \(w_{min}\) is equal to 0.4, performing more exploitation. Moreover, \(t\) is the current iteration of the algorithm and \(t_{max}\) is the maximum number of iterations. A large portion of researchers' results illustrate that linearly decreasing in the inertia weight can greatly improve the performance of PSO, having better results than the classic implementation of the algorithm. ### Time-Varying Acceleration Coefficients (Tvac)

In population-based optimization methods, proper control of global and local exploration is essential for the efficient identification of the optimum solution. [PERSON] et al. introduced the TVAC in PSO [11]. According to their research, the cognitive parameter \(c_{1}\) starts with a high value and linearly decreases to a low value, whereas the social parameter \(c_{2}\) starts with a low value and linearly increases to a high value [21].