我正在尝试执行以下操作:我有一个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
谢谢。