粒子群群优化(PSO)算法



在粒子群优化(PSO(算法中,是否可以使用数据集初始化粒子的位置,而不是使用统一的随机数?

是的,可以用数据集值初始化群粒子而不是随机初始化。您需要从数据集中选择随机样本,并需要将其分配到群体的位置向量。

群颗粒的初始化

class Particle:
    position=[]
    velocity=[]
    pbest=[]
  
    
    def __init__(self):
          for i in range(rows): // rows is number of sample in your dataset
            
                                       
             self.position=Training_dataset[i,:]
             self.velocity=np.random.rand(rows,columns) 
             // columns is number of dimensions or features in dataset
                                   
               self.pbest=self.position
                

for i in  range(no_of_sample_in_dataset):
    
            p=Particle()              
            swarm.append(p)

最新更新