我正在尝试执行以下操作:我有一个 N 大小的染色体,其类型是 IntegerGene。我对在交叉算子之后评估的那个独特的染色体感兴趣,所以我使用:
Configuration configuration = new DefaultConfiguration ();
Configuracion.getGeneticOperators (). Clear ();
CrossoverOperator crossover = new CrossoverOperator (configuration);
Configuracion.addGeneticOperator (crossover);
...
Genotype poblacion = Genotype.randomInitialGenotype(configuracion);
例如,我想使用单个染色体来创建以下种群,这条染色体将是 | 9 | 5 | 10 | 0 | 因此我初始化它:
Gene [] genes = new Gene [4];
genes [0] = new IntegerGene (configuration, 9,9);
genes [1] = new IntegerGene (configuration, 5,5);
genes [2] = new IntegerGene (configuration, 10,10);
genes [3] = new IntegerGene (configuration, 0,0);
当我运行程序时,输出(染色体解)总是相同的(| 9 | 5 | 10 | 0 |),它不执行交叉算子....
Run:
Population Size: 10
...
9 5 10 0
Punctuation = 12.5
9 5 10 0
Punctuation = 12.5
9 5 10 0
Punctuation = 12.5
9 5 10 0
Punctuation = 12.5
Chromosome Solution [0] = 9
Chromosome Solution [1] = 5
Chromosome Solution [2] = 10
Chromosome Solution [3] = 0
谢谢你。