def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# define required options
if not 'pBins' in self.opt:
self.opt['pBins']=10
if not 'inertia' in self.opt:
self.opt['inertia']=0.5
if not 'c1' in self.opt:
self.opt['c1']=0.6
if not 'c2' in self.opt:
self.opt['c2']=0.3
if not 'c3' in self.opt:
self.opt['c3']=0.001
if self.opt['c3']==0:
self.opt['c3']=1E-5
# define required variables
self.pBestIdxs=np.arange(self.opt['population'], dtype=np.int32)
self.gBestIdxs=np.arange(self.opt['population'], dtype=np.int32)
self.velocities=np.zeros((self.opt['population'],self.opt['nVars']))
tmp=np.hstack((-np.Inf, np.linspace(0,1, num=self.opt['pBins'])))
self.pBins=np.vstack((tmp[0:-1],tmp[1:]))
评论列表
文章目录