geatpy-dev / geatpy

Evolutionary algorithm toolbox and framework with high performance for Python
http://www.geatpy.com
GNU Lesser General Public License v3.0
1.96k stars 725 forks source link

译码矩阵FieldDR必须是3行的Numpy ndarray类型矩阵。 #321

Closed whjdark closed 1 year ago

whjdark commented 1 year ago

尝试着设置多条(2条以上)染色体,提示 RuntimeError: error in crtpp: FieldDR must be a matrix with 3 rows. (译码矩阵FieldDR必须是3行的Numpy ndarray类型矩阵。)

  Encodings = ['BG','BG','P']
  Field0 = ea.crtfld(Encodings[0], problem.varTypes[:2],
      problem.ranges[:,:2], problem.borders[:,:2])
  Field1 = ea.crtfld(Encodings[1], problem.varTypes[2:4],
      problem.ranges[:,2:4], problem.borders[:,2:4])
  Field2 = ea.crtfld(Encodings[2], problem.varTypes[4:],
      problem.ranges[:,4:], problem.borders[:,4:])
  Fields = [Field0 , Field1, Field2]
  population = ea.PsyPopulation(Encodings, Fields, NIND=150)
Charles-Hus commented 1 year ago

这个我也遇到过,你只需要打印一下你的数据,看一下格式就知道怎么回事了。把传进来的数据格式改成人家的数据格式就行了