예제 #1
0
 def __init__(self,
              problem,
              population,
              MAXGEN=None,
              MAXTIME=None,
              MAXEVALS=None,
              MAXSIZE=None,
              logTras=None,
              verbose=None,
              outFunc=None,
              drawing=None,
              trappedValue=None,
              maxTrappedCount=None,
              dirName=None,
              **kwargs):
     # 先调用父类构造方法
     super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS,
                      MAXSIZE, logTras, verbose, outFunc, drawing,
                      trappedValue, maxTrappedCount, dirName)
     if population.ChromNum != 1:
         raise RuntimeError('传入的种群对象必须是单染色体的种群类型。')
     self.name = 'DE/target-to-best/1/bin'
     self.k = 0.5  # target-to-best中的参数k
     if population.Encoding == 'RI':
         self.mutOper = ea.Mutde(F=[self.k, 0.5])  # 生成差分变异算子对象
         self.recOper = ea.Xovexp(XOVR=0.5,
                                  Half_N=True)  # 生成指数交叉算子对象,这里的XOVR即为DE中的Cr
     else:
         raise RuntimeError('编码方式必须为' 'RI' '.')
예제 #2
0
 def __init__(self, problem, population):
     ea.SoeaAlgorithm.__init__(self, problem, population)  # 先调用父类构造方法
     if population.ChromNum != 1:
         raise RuntimeError('传入的种群对象必须是单染色体的种群类型。')
     self.name = 'DE/current-to-best/1/L'
     if population.Encoding == 'RI':
         self.mutOper = ea.Mutde(F=0.5)  # 生成差分变异算子对象
         self.recOper = ea.Xovexp(XOVR=0.5,
                                  Half=True)  # 生成指数交叉算子对象,这里的XOVR即为DE中的Cr
     else:
         raise RuntimeError('编码方式必须为' 'RI' '.')
예제 #3
0
 def __init__(self, problem, population):
     ea.SoeaAlgorithm.__init__(self, problem, population) # 先调用父类构造方法
     if str(type(population)) != "<class 'Population.Population'>":
         raise RuntimeError('传入的种群对象必须为Population类型')
     self.name = 'DE/rand/1/bin'
     if population.Encoding == 'RI':
         self.mutOper = ea.Mutde(F = 0.5) # 生成差分变异算子对象
         self.recOper = ea.Xovexp(XOVR = 0.5, Half = True) # 生成指数交叉算子对象,这里的XOVR即为DE中的Cr
     else:
         raise RuntimeError('编码方式必须为''RI''.')
     self.k = 0.5 # target-to-best中的参数k
 def __init__(self, problem, population):
     ea.SoeaAlgorithm.__init__(self, problem, population)  # 先调用父类构造方法
     if str(type(population)) != "<class 'Population.Population'>":
         raise RuntimeError('传入的种群对象必须为Population类型')
     self.name = 'DE_rand_1_L'
     self.selFunc = 'rws'  # 基向量的选择方式,采用轮盘赌选择
     if population.Encoding == 'RI':
         self.mutOper = ea.Mutde(F=0.5)  # 生成差分变异算子对象
         self.recOper = ea.Xovexp(XOVR=0.5,
                                  Half=True)  # 生成指数交叉算子对象,这里的XOVR即为DE中的Cr
     else:
         raise RuntimeError('编码方式必须为' 'RI' '.')
예제 #5
0
 def __init__(self, problem, population):
     ea.SoeaAlgorithm.__init__(self, problem, population)  # 先调用父类构造方法
     if population.ChromNum != 1:
         raise RuntimeError('传入的种群对象必须是单染色体的种群类型。')
     self.name = 'DE/rand/1/L'
     self.selFunc = 'rcs'  # 基向量的选择方式,采用随机补偿选择
     if population.Encoding == 'RI':
         self.mutOper = ea.Mutde(F=0.5)  # 生成差分变异算子对象
         self.recOper = ea.Xovexp(XOVR=0.5,
                                  Half_N=True)  # 生成指数交叉算子对象,这里的XOVR即为DE中的Cr
     else:
         raise RuntimeError('编码方式必须为' 'RI' '.')