Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Java中的jenetics.io库增加遗传算法的种群规模? 我正在尝试开始使用Jenetics JAVA库进行遗传算法,但从我有限的遗传算法背景来看,有些东西我还不了解。 我需要使用populationSize()将设置为50的population size的默认值更改为其他值。 这是我的代码段 公共静态void main(字符串[]args) { initarray(); 最终工厂gtf=基因型of(整合染色体组of(0,TRUCKS.length-1,LEN),整合染色体组of(0,LOCATIONS.length-1,LEN),整合染色体组of(0,TIMES.length-1,LEN)); 最终发动机=发动机制造商(主要::评估,gtf) .populationSize(整数150) .build(); System.out.println(“engine.getPopulationSize()=”+engine.getPopulationSize()); 最终进化结果=engine.stream().limit(1000).collect(进化结果.tobesteevolutionresult()); 基因型=结果。GetBestEphype().GetGenype(); System.out.println(“结果=”+基因型); System.out.println(“result.getbestepotype().getFitness()=”+result.getbestepotype().getFitness()); }`在这里输入代码`_Java_Genetic Algorithm_Jenetics - Fatal编程技术网

如何使用Java中的jenetics.io库增加遗传算法的种群规模? 我正在尝试开始使用Jenetics JAVA库进行遗传算法,但从我有限的遗传算法背景来看,有些东西我还不了解。 我需要使用populationSize()将设置为50的population size的默认值更改为其他值。 这是我的代码段 公共静态void main(字符串[]args) { initarray(); 最终工厂gtf=基因型of(整合染色体组of(0,TRUCKS.length-1,LEN),整合染色体组of(0,LOCATIONS.length-1,LEN),整合染色体组of(0,TIMES.length-1,LEN)); 最终发动机=发动机制造商(主要::评估,gtf) .populationSize(整数150) .build(); System.out.println(“engine.getPopulationSize()=”+engine.getPopulationSize()); 最终进化结果=engine.stream().limit(1000).collect(进化结果.tobesteevolutionresult()); 基因型=结果。GetBestEphype().GetGenype(); System.out.println(“结果=”+基因型); System.out.println(“result.getbestepotype().getFitness()=”+result.getbestepotype().getFitness()); }`在这里输入代码`

如何使用Java中的jenetics.io库增加遗传算法的种群规模? 我正在尝试开始使用Jenetics JAVA库进行遗传算法,但从我有限的遗传算法背景来看,有些东西我还不了解。 我需要使用populationSize()将设置为50的population size的默认值更改为其他值。 这是我的代码段 公共静态void main(字符串[]args) { initarray(); 最终工厂gtf=基因型of(整合染色体组of(0,TRUCKS.length-1,LEN),整合染色体组of(0,LOCATIONS.length-1,LEN),整合染色体组of(0,TIMES.length-1,LEN)); 最终发动机=发动机制造商(主要::评估,gtf) .populationSize(整数150) .build(); System.out.println(“engine.getPopulationSize()=”+engine.getPopulationSize()); 最终进化结果=engine.stream().limit(1000).collect(进化结果.tobesteevolutionresult()); 基因型=结果。GetBestEphype().GetGenype(); System.out.println(“结果=”+基因型); System.out.println(“result.getbestepotype().getFitness()=”+result.getbestepotype().getFitness()); }`在这里输入代码`,java,genetic-algorithm,jenetics,Java,Genetic Algorithm,Jenetics,populationSize()是我得到错误的地方。我需要将默认值50更改为150。据我所知,您必须从populationSize方法调用中删除int关键字: I am trying to get started using the Jenetics JAVA library for genetic algorithms and there is something I don't understand from my GA limited background. I need to chang

populationSize()是我得到错误的地方。我需要将默认值50更改为150。

据我所知,您必须从
populationSize
方法调用中删除
int
关键字:

I am trying to get started using the Jenetics JAVA library for genetic algorithms and there is something I don't understand from my GA limited background.
I need to change the default value of population size which is set to 50 into a different value using populationSize().

here is my code segment
 public static void main(String[] args)
    {
        initArrays();
        final Factory<Genotype<IntegerGene>> gtf = Genotype.of(IntegerChromosome.of(0, TRUCKS.length - 1, LEN), IntegerChromosome.of(0, LOCATIONS.length - 1, LEN), IntegerChromosome.of(0, TIMES.length - 1, LEN));
        final Engine<IntegerGene, Integer> engine = Engine.builder(Main::eval, gtf)
                .populationSize(int 150)
                .build();
        System.out.println("engine.getPopulationSize() = " + engine.getPopulationSize());
        final EvolutionResult<IntegerGene, Integer> result = engine.stream().limit(1000).collect(EvolutionResult.toBestEvolutionResult());
        Genotype<IntegerGene> genotype = result.getBestPhenotype().getGenotype();
        System.out.println("result = " + genotype);
        System.out.println("result.getBestPhenotype().getFitness() = " + result.getBestPhenotype().getFitness());
    }`enter code here`
final Engine=Engine.builder(Main::eval,gtf)
.人口规模(150)
.build();

您尝试过什么?您有任何错误或注意事项吗?此外,请将您的代码复制粘贴到问题中,而不是屏幕截图。是的,我有。我现在已经把我的代码包括在问题中了。
final Engine<IntegerGene, Integer> engine = Engine.builder(Main::eval, gtf)
    .populationSize(150)
    .build();