This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import numpy as np | |
class PSO: | |
def __init__(self, func=None, param_len=1, size=5, w=0.9, c1=2., c2=2., x_min=-10., x_max=10., v_min=-0.5, | |
v_max=0.5, r1=None, r2=None): | |
self.func = func # 计算适应性系数的方法 | |
self.param_len = param_len # 参数个数 | |
self.size = size # 有多少微粒 |