FittestCandidate is not the best

84 views
Skip to first unread message

Ignacio

unread,
May 10, 2012, 3:20:38 PM5/10/12
to watch...@googlegroups.com
Hi,

i am using the GenerationalEvolutionEngine with a TargetFitness (targetFitness = 100 and isNatural = true). Then i invoke the envolve to the engine object to obtain the fittestCandidate. Then i invoke the method getFitness of my FitnessEvaluator passing the object "fittestCandidate" and it return a value less than 100 (this value should be at least 100). 

So i add an EvolutionObserver to the engine to log the data. I prints the getBestCandidateFitness()  and obtain a value of 100 in the last evolution. 

The question is why the evolutionEngine is returning an object that have a fitness less than 100?? Any idea?

Regards.


Daniel Dyer

unread,
May 10, 2012, 5:18:12 PM5/10/12
to watch...@googlegroups.com
On Thu, 10 May 2012 20:20:38 +0100, Ignacio <nac...@gmail.com> wrote:

> Hi,
>
> i am using the *GenerationalEvolutionEngine *with a *TargetFitness
> *(targetFitness
> = 100 and isNatural = true). Then i invoke the *envolve *to the *engine
> *object
> to obtain the fittestCandidate. Then i invoke the method *getFitness *of
> my
> *FitnessEvaluator *passing the object "fittestCandidate" and it return a
> value *less than 100* (this value should be at least 100).
>
> So i add an EvolutionObserver to the engine to log the data. I prints the
> getBestCandidateFitness<http://watchmaker.uncommons.org/api/org/uncommons/watchmaker/framework/PopulationData.html#getBestCandidateFitness()>()
> and obtain a value of 100 in the last evolution.
>
> The question is why the evolutionEngine is returning an object that have
> a
> fitness less than 100?? Any idea?

To make sure I'm clear what the problem is, the evolution observer says
the fitness is 100 but your fitness evaluator says it is less than 100
when you run it again on the same candidate?

Is your fitness evaluator deterministic? Will it always return the same
value for the same input or is there a random element to it?

You could try using the evolvePopulation method instead. This will return
the entire population, sorted in descending order of fitness, with the
fitness score attached to each individual. This will at least show you
what the evolution engine thinks the fitness scores are and may help to
isolate the problem.

Dan.

--
Daniel Dyer

Ignacio

unread,
May 10, 2012, 5:30:09 PM5/10/12
to watch...@googlegroups.com
Hi Dan, that's right the evolution observer says the fitness is 100 and my fitness evaluator says that is less. It is deterministic, there is not randoms.

Well, I will try with evolvePopulation.

Thanks.

Ignacio

unread,
May 14, 2012, 10:18:52 PM5/14/12
to watch...@googlegroups.com
Hi,

I think that its a bug using TargetFitness. The method getBestCandidateFitness() return a value of 100 while my Fitness evaluator says that the fitness value is less than 100.

 I implement my own TerminationCondition and its works fine. Here is the method shouldTerminate implementation:

@Override
public boolean shouldTerminate(PopulationData<?> populationData) {
List<PartidoDTO> mejorCandidato = (List<PartidoDTO>) populationData.getBestCandidate();
return this.fitnessEvaluator.getFitness(mejorCandidato, null) == 100;

Daniel Dyer

unread,
May 15, 2012, 7:27:59 AM5/15/12
to watch...@googlegroups.com
On Tue, 15 May 2012 03:18:52 +0100, Ignacio <nac...@gmail.com> wrote:

> Hi,
>
> I think that its a bug using TargetFitness. The
> method getBestCandidateFitness() return a value of 100 while my Fitness
> evaluator says that the fitness value is less than 100.

The implementation of TargetFitness is trivial (see
https://github.com/dwdyer/watchmaker/blob/master/framework/src/java/main/org/uncommons/watchmaker/framework/termination/TargetFitness.java).

I think that replacing it with your implementation is just hiding the real
problem, which is why does the fitness score returned by your evaluator
differ from that obtained during the last generation? We already know
that the fitness score for the best candidate in the population data is
100, so TargetFitness is working correctly as that is what it is checking
against.

If you are able to provide the code for your FitnessEvaluator, or some
other code that reproduces the problem, I will take a look at it.

Thanks,

Dan.

--
Daniel Dyer
Reply all
Reply to author
Forward
0 new messages