Implementation of particle swarm optimization