Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to do the move function (next position) for Particle Swarm Optimization to solve TSP

Summary on my program:

I'm reading in a text file and on each line there is an int (node identifier), and 3 floats (x, y, z locations). The node id always starts are 1 and increments in order. After I read in this information, I create an adjacency matrix to get the distance from each node to every other node. As of right now, in my PSO algorithm class I first create a vector of particles (a class I made). In the particle class, the constructor takes in an int, which is the largest node number. It then creates a random path of all the nodes (stored in a vector called 'currentPath') that starts and ends at node 1. I also set another vector in the particle class called 'bestPath' to this random path. In the PSO algorithm class, after creating the vector of particles I find out which particle has the most optimal current route, and set a vector called 'globalBest' to this path. Next, I enter a for loop and in each iteration I call a function called 'move' on each of the particles in the particle vector.

Question:

In the move function, how do I use the particle's current path, best path, velocity, and the global best path to calculate the next path? Also how do I calculate velocity/why is it relevant in generating the next path?

Comments