Particle swarm optimization (PSO) is a computational method that seeks to optimize a problem by iteratively attempting to enhance a candidate solution to a specific quality measure.

PSO is an AI technique that can approximate solutions to exceedingly challenging or impossible maximization and minimization issues involving numbers. By searching the whole high-dimensional problem space, PSO proved to be a good optimization algorithm. Moreover, it is a robust stochastic optimization method based on how swarms move and how smart they are.

Procedure

PSO figures out how to solve a problem by making a group of possible solutions, called "particles," and moving them around in the search space based on a simple mathematical formula for their position and speed. Of course, locally, each particle's movement is affected by its best-known position. Still, it is also directed towards the most notable roles in the search space, which change as other particles find better jobs. It should move the Swarm towards the best answers.

It is a metaheuristic because it doesn't make many or any assumptions about the problem it's trying to solve and can look through vast spaces of possible solutions. Also, PSO doesn't use the gradient of the problem being optimized. It means that, unlike gradient descent and quasi-Newton methods, PSO doesn't need the optimization problem to be able to be solved in more than one way. 

Algorithm

A simple version of the PSO algorithm works by having a group of possible solutions called a "swarm" (particles). A few simple formulas move these particles around in the search space. The particles move based on their best-known position in the search space and the best-known position of the whole Swarm. When better positions are found, they will guide the Swarm's movements. It is hoped, but not guaranteed, that a good solution will be seen by doing this repeatedly.

Step1: Randomly initialize Swarm population of N particles Xi ( i=1, 2, …, n)
Step2: Select hyperparameter values
           w, c1 and c2
Step 3: For Iter in range(max_iter): # loop max_iter times  
            For i in range(N): # for each particle:
               a. Compute the new velocity of ith particle
                    swarm[i].velocity = 
                         w*swarm[i].velocity + 
                         r1*c1*(swarm[i].bestPos - swarm[i].position) +
                         r2*c2*( best_pos_swarm - swarm[i].position) 
               b. If velocity is not in the range [minx, max], then clip it
                    if Swarm [i].velocity < minx:
                        swarm[i].velocity = minx
                    elif swarm[i].velocity[k] > maxx:
                        swarm[i].velocity[k] = maxx
               c. Compute the new position of the ith particle using its new velocity
                    swarm[i].position += swarm[i].velocity
               d. Update the new best of this particle and the new best of Swarm
                     if swaInsensitive to scaling of design variables.rm[i].fitness < swarm[i].bestFitness:
                        swarm[i].bestFitness = swarm[i].fitness
                        swarm[i].bestPos = swarm[i].position

                     if swarm[i].fitness < best_fitness_swarm
                        best_fitness_swarm = swarm[i].fitness
                        best_pos_swarm = swarm[i].position
             End-for
         End -for
Step 4: Return the best particle of the Swarm

Algorithm source: PSO - an overview

Although findings vary for specific PSO variants, the optimal performance is achieved with swarms of 70–500 particles for most examined PSO algorithms, indicating that the conventional option is frequently too small.

Conclusion

There is no significant difference between the two processes on a small scale. Only solutions near the ideal can be generated using genetic algorithms on medium and large sizes. The PSO approach is straightforward to implement and yields precise calculations.

Furthermore, the PSO algorithm has the disadvantages of being prone to local optimums in high-dimensional spaces and having a low convergence rate during the iterative phase.

Want to publish your content?

Publish an article and share your insights to the world.

ALSO EXPLORE

DISCLAIMER

The information provided on this page has been procured through secondary sources. In case you would like to suggest any update, please write to us at support.ai@mail.nasscom.in