Update: At each iteration, the particles' positions and velocities are updated. After moving, the algorithm checks whether each particle's new position is an improvement over its personal best. If it is, the particle's personal best is updated. Similarly, if any particle's position is an improvement over the current global best, the global best is updated.