On MathExample, added the following lines below
gp.evolve(800) :
GPPopulation pop = gp.getGPPopulation();
pop.sortByFitness();
When pop.sortByFitness() is called I get this output:
Exception in thread "main"
java.lang.IllegalArgumentException: Evaluator must not
be null
at
org.jgap.gp.impl.GPProgramFitnessComparator.<init>(GPProgramFitnessComparator.java:53)
at
org.jgap.gp.impl.GPPopulation.sortByFitness(GPPopulation.java:315)
at tests.MathProblem.main(MathProblem.java:99)
In GPConfiguration there is a private
IGPFitnessEvaluator m_fitnessEvaluator, but in it's
constructor it calls setFitnessEvaluator(new
DeltaFitnessEvaluator()), so when sortByFitness is
called, the
getGPConfiguration().getGPFitnessEvaluator() returns null.
Should there be a setGPFitnessEvaluator(new
DefaultGPFitnessEvaluator()) in GPConfiguration's
constructor?
Logged In: YES
user_id=722855
You are right, the setter was missing. I added it as
ordinary setter (not in the constructor). There is a
default implementation of such an evaluator,
org.jgap.impl.gp.DefaultGPFitnessEvaluator