I wanted to remove the static key word from my code. But in the fitness function method it gives me an error. Is the static key-word is essential in the fitness function method?
Here is the code which gives me an error.
public void optimize()
{
long l1 = System.currentTimeMillis();
final Factory<Genotype<IntegerGene>> gtf = Genotype.of(IntegerChromosome.of(0, all.length - 1, LEN));
final Engine<IntegerGene, Integer> engine = Engine.builder(eval, gtf).populationSize(1000).build();
System.out.println("engine.getPopulationSize() = " + engine.getPopulationSize());
final EvolutionResult<IntegerGene, Integer> result = engine.stream().limit(500).collect(EvolutionResult.toBestEvolutionResult());
Genotype<IntegerGene> genotype = result.getBestPhenotype().getGenotype();
System.out.println("result = " + genotype);
System.out.println("result.getBestPhenotype().getFitness() = " + result.getBestPhenotype().getFitness());
System.out.println("Time taken : " + (System.currentTimeMillis() - l1));
}
Can the fitness function could be non-static or it should be always static? Can someone help?