Particle swarm optimization based on an improved diversity mechanism