psoAlt.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Tethys 作者: JosePedroMatos 项目源码 文件源码
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:]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号