介绍
粒子群优化算法(Particle Swarm Optimization,简称PSO)是经典的群体智能优化算法之一,其由电气工程师Eberhart博士(past President of IEEE Neural Networks Council)和心理学Kennedy博士(past Director of the Office of Analysis and Research Services, U.S. International Trade Commission)一起于1995提出,并于2001年在书Swarm Intelligence中做了详细的介绍。
Python代码
PSO及其各种变种的使用示例如下所示,其Python开源代码来自软件库PyPop7:
import time
import numpy as np
from pypop7.optimizers.pso.ccpso2 import CCPSO2
from pypop7.optimizers.pso.clpso import CLPSO
from pypop7.optimizers.pso.cpso import CPSO
from pypop7.optimizers.pso.ipso import IPSO
from pypop7.optimizers.pso.spso import SPSO
from pypop7.optimizers.pso.spsol import SPSOL
from pypop7.benchmarks.base_functions import ellipsoid, rosenbrock
if __name__ == '__main__':
start_run = time.time()
ndim_problem = 10
for Solver in [CCPSO2, CLPSO, CP