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`
populationSize() 是我得到错误的地方。我需要将默认值 50 更改为 150。