Reference: Kennedy J, Eberhart R. Particle swarm optimization[C]//Proceedings of ICNN'95-International Conference on Neural Networks. IEEE, 1995, 4: 1942-1948.
| Variables | Meaning |
|---|---|
| pop | The number of population |
| u_bound | List, the upper bound of the i-th dimension is u_bound[i] |
| l_bound | List, the lower bound of the i-th dimension is l_bound[i] |
| vmin | List, the minimum velocity of the particle on the i-th dimension is vmin[i] |
| vmax | List, the maximum velocity of the particle on the i-th dimension is vmax[i] |
| iter | The maximum number of iterations |
| omega | The inertia weight to control the influence of the previous velocity value on the updated velocity |
| phi1 | The cognitive weight |
| phi2 | The social weight |
| dim | The number of dimensions |
| position | List, the position of the i-th particle is position[i] |
| fitness | List, the score of the i-th particle is fitness[i] |
| velocity | List, the velocity of the i-th particle is velocity[i] |
| g_best | The global best score |
| g_best_location | The global best position |
| p_best | List, the personal best score of the i-th particle is p_best[i] |
| p_best_location | List, the personal best position of the i-th particle is p_best[i] |
| iter_best | List, the best so-far score of each iteration |
if __name__ == '__main__':
pop = 50
iter = 500
vmin = [-2, -2, -2, -2]
vmax = [2, 2, 2, 2]
print(main(pop, iter, vmin, vmax)){
'best solution': [1.300568607387978, 0.6431938035005514, 67.38697386901593, 10.0],
'best score': 8053.847210456193,
}
