使用JGAp(遗传算法库)和重复的染色体 [英] using JGAp (genetic algorithm library) and the duplicated chromosomes
问题描述
我使用了JGAp java遗传算法库。
当我评估染色体时,我在人口中重复染色体
样本运行:
I used the JGAp java genetic algorithm library. and when I evaluated the chromosomes , I had duplication of chromosomes in the population sample run :
evaluation 0
A B C
A D F
S F W
evaluation 1:
A B C
A D F
A D F
evaluation 2:
A D F
A D F
A D F
我使用的配置是:
conf.setKeepPopulationSizeConstant(true);
conf.setRandomGenerator(new StockRandomGenerator());
conf.verifyStateIsValid();
我是否可以使用任何配置来获取独特的染色体?
is there any configuration that I can used in order to get unique chromosomes?
推荐答案
您可以确保只使用 NaturalSelectors 不允许重复。示例代码:
You can make sure only to use NaturalSelectors that does not allow duplicates. Example code:
conf.getNaturalSelectors(false).clear();
BestChromosomesSelector bcs = new BestChromosomesSelector(conf, 1.0d);
bcs.setDoubletteChromosomesAllowed(false);
conf.addNaturalSelector(bcs, false);
请注意,只有使用SwappingMutationOperator才可能会破坏人口的聪明才智。从JGAP修改MinimizingMakeChange示例但仅使用SwappingMutationOperator的测试显示,人口很快就会停止生成以前从未见过的人。
Please note that only using SwappingMutationOperator will probably starve the ingenuity of the population. A test modifying the MinimizingMakeChange example from JGAP, but using only the SwappingMutationOperator, shows that the population quickly stops producing individuals that have not been seen before.
这篇关于使用JGAp(遗传算法库)和重复的染色体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!