fittest not returned with getFittestChromosome()?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

fittest not returned with getFittestChromosome()?

Gabriel-73
Hello all,

I have a strange thing going on, I am getting results that have a great
fitness but that are totally wrong. I checked my fitness function, I
even debugged it, and it seems to work: good results get a good fitness
and bad results get a bad fitness. I then decided to print the
Chromosomes that are evaluated with a max fitness (7.0).  Other than
only one solution being printed out (when I would expect several
different ones, I wonder if the random generator works correctly), it is
correct, but when the evolution loop is done, I get something totally bogus:

....
K:[x=2, y=2], K:[x=0, y=2], R:[x=1, y=0], <-- correct, evalutates to 7.0
fitness
K:[x=2, y=2], K:[x=0, y=2], R:[x=1, y=0], <-- why the whole list has
only this result, I do not know
K:[x=2, y=2], K:[x=0, y=2], R:[x=1, y=0],
K:[x=2, y=2], K:[x=0, y=2], R:[x=1, y=0],
K:[x=2, y=2], K:[x=0, y=2], R:[x=1, y=0],


The best solution (fitness : 7.000000) contained the following:
K:[x=1, y=2], K:[x=0, y=2], R:[x=0, y=0], <-- this is totally wrong...
it should have a fitness of 4.0.. I would expect the optimal solution
above to have been returned by this call, why is it not?

Here is how the evolution is done:

for (int i = 0 ; i < 1000; i++) {
    population.evolve();
}

IChromosome bestSolutionSoFar = population.getFittestChromosome();
System.out.printf("\n\nThe best solution (fitness : %f) contained the
following: \n", bestSolutionSoFar.getFitnessValue());

AbstractPlayingPiece app;
for(Gene g: bestSolutionSoFar.getGenes()) {
    app = (AbstractPlayingPiece) g.getAllele();
    System.out.print(app.toString() + ", ");
}

Does anyone know what is going on?

Sometimes I even get solutions like:

K:[x=2, y=1], K:[x=0, y=0], R:[x=2, y=1],

which my fitness function would give 1.0 to because no two Genes can
have the same coordinates (I checked/debugged, it works).

It is like if a mutation was applied after the evolution, but I checked
and this does not happen (unless I missed it).

Thank you,
Gabriel




------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users
Reply | Threaded
Open this post in threaded view
|

Re: fittest not returned with getFittestChromosome()?

Klaus Meffert-5
Hello Gabriel,

as already written to you via direct communication, just repeated for the
list:

The problem was that the allele classes you used did not support cloning. In
most cases allele classes are of standard types, such as String, Integer,
etc., in these cases the problem cannot occur.

The solution was to implement the Icloneable interface, which is provided by
JGAP.

To easy future problem recognition: I will extend JGAP to output a warning
message in case uncloneable allele classes are detected.

Best

Klaus
www.klaus-meffert.com

 

> -----Original Message-----
> From: Gabriel [mailto:[hidden email]]
> Sent: Sunday, February 20, 2011 11:14 AM
> To: [hidden email]
> Subject: [jgap-users] fittest not returned with
> getFittestChromosome()?
>
> Hello all,
>
> I have a strange thing going on, I am getting results that
> have a great fitness but that are totally wrong. I checked my
> fitness function, I even debugged it, and it seems to work:
> good results get a good fitness and bad results get a bad
> fitness. I then decided to print the Chromosomes that are
> evaluated with a max fitness (7.0).  Other than only one
> solution being printed out (when I would expect several
> different ones, I wonder if the random generator works
> correctly), it is correct, but when the evolution loop is
> done, I get something totally bogus:
>
> ....
> K:[x=2, y=2], K:[x=0, y=2], R:[x=1, y=0], <-- correct,
> evalutates to 7.0 fitness K:[x=2, y=2], K:[x=0, y=2], R:[x=1,
> y=0], <-- why the whole list has only this result, I do not
> know K:[x=2, y=2], K:[x=0, y=2], R:[x=1, y=0], K:[x=2, y=2],
> K:[x=0, y=2], R:[x=1, y=0], K:[x=2, y=2], K:[x=0, y=2], R:[x=1, y=0],
>
>
> The best solution (fitness : 7.000000) contained the following:
> K:[x=1, y=2], K:[x=0, y=2], R:[x=0, y=0], <-- this is totally
> wrong...
> it should have a fitness of 4.0.. I would expect the optimal
> solution above to have been returned by this call, why is it not?
>
> Here is how the evolution is done:
>
> for (int i = 0 ; i < 1000; i++) {
>     population.evolve();
> }
>
> IChromosome bestSolutionSoFar = population.getFittestChromosome();
> System.out.printf("\n\nThe best solution (fitness : %f) contained the
> following: \n", bestSolutionSoFar.getFitnessValue());
>
> AbstractPlayingPiece app;
> for(Gene g: bestSolutionSoFar.getGenes()) {
>     app = (AbstractPlayingPiece) g.getAllele();
>     System.out.print(app.toString() + ", "); }
>
> Does anyone know what is going on?
>
> Sometimes I even get solutions like:
>
> K:[x=2, y=1], K:[x=0, y=0], R:[x=2, y=1],
>
> which my fitness function would give 1.0 to because no two
> Genes can have the same coordinates (I checked/debugged, it works).
>
> It is like if a mutation was applied after the evolution, but
> I checked and this does not happen (unless I missed it).
>
> Thank you,
> Gabriel
>
>
>
>
> --------------------------------------------------------------
> ----------------
> The ultimate all-in-one performance toolkit: Intel(R)
> Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> jgap-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jgap-users


------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users