Quantcast

A bug??

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

A bug??

Luis Garcia-5
Not sure if this is a bug or a misinterpretation on my part of JGAP functionality. I have been playing with the LesserThan, GreaterThan commands. I went into the code and saw that these classes are pre-set to ALWAYS return a boolean (which makes sense) and that they only execute the boolean method. The others are not implemented. Now, that execute_boolean method has a series of "if" to discern the Class type that the method should run, correct? To me that means I can give this method a double, or a integral and it will always give me a boolean in return, correct? I created a simple program with the following genotype:

CommandGene[][] nodeSets = {
        {
            ZERO = Variable.create(conf, "ZERO", CommandGene.FloatClass),
            TWO = Variable.create(conf, "TWO", CommandGene.FloatClass),
            new LesserThan(conf, CommandGene.BooleanClass)
        }
    };

The script is set to return (and run) Boolean values and the fitness function runs the execute_boolean method and rewards the individual if it returns true from the analysis, the variables are set always with zero and 2. The script is attached in case someone wants to see it. Anyway, that should return something like ZERO < TWO or something similar, correct? Instead, it returns this error:

Exception in thread "main" org.jgap.InvalidConfigurationException: java.lang.RuntimeException: Chromosome (depth 1, index 0) requires a terminal of return type class java.lang.Boolean (sub return type 0) but there is no such node available
        at org.jgap.gp.impl.GPGenotype.randomInitialGenotype(GPGenotype.java:401)
        at org.jgap.gp.impl.GPGenotype.randomInitialGenotype(GPGenotype.java:315)
        at org.jgap.gp.impl.GPGenotype.randomInitialGenotype(GPGenotype.java:272)
        at org.jgap.gp.impl.GPGenotype.randomInitialGenotype(GPGenotype.java:224)
        at com.luisegarcia.gp.SimpleTest.create(SimpleTest.java:44)
        at com.luisegarcia.gp.SimpleTest.main(SimpleTest.java:61)
Caused by: java.lang.RuntimeException: Chromosome (depth 1, index 0) requires a terminal of return type class java.lang.Boolean (sub return type 0) but there is no such node available
        at org.jgap.gp.impl.ProgramChromosome.selectNode(ProgramChromosome.java:524)
        at org.jgap.gp.impl.ProgramChromosome.growOrFullNode(ProgramChromosome.java:573)
        at org.jgap.gp.impl.ProgramChromosome.growOrFullNode(ProgramChromosome.java:654)
        at org.jgap.gp.impl.ProgramChromosome.growOrFullNode(ProgramChromosome.java:654)
        at org.jgap.gp.impl.ProgramChromosome.growOrFull(ProgramChromosome.java:273)
        at org.jgap.gp.impl.GPProgram.growOrFull(GPProgram.java:208)
        at org.jgap.gp.impl.DefaultProgramCreator.create(DefaultProgramCreator.java:35)
        at org.jgap.gp.impl.GPPopulation.create(GPPopulation.java:511)
        at org.jgap.gp.impl.GPPopulation.create(GPPopulation.java:315)
        at org.jgap.gp.impl.GPPopulation.create(GPPopulation.java:241)
        at org.jgap.gp.impl.DefaultPopulationCreator.initialize(DefaultPopulationCreator.java:68)
        at org.jgap.gp.impl.GPGenotype.randomInitialGenotype(GPGenotype.java:398)
        ... 5 more
Java Result: 1

The only way it runs is if I add the terminal "False", in which case it never returns True because it only reads "false" and does not compares the values of the variables. I checked the code and I think there is something wrong in either MathCommand or GPPopulation. I could not figure it out. Unless, of course, I am not using the library as intended.
Thanks!
Luis

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users

SimpleTest.java (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A bug??

Luis Garcia-5
I think I figured it out. I followed the thread in the code and found that the error happens when the configuration is strict, meaning all the terminals have to be the same type as the return... go figure... so, all there is to do is to set the configuration setStrictProgramCreation method to false and it works.


From: Luis Garcia <[hidden email]>
To: JGAP USERS LIST <[hidden email]>
Sent: Tue, August 24, 2010 10:49:28 PM
Subject: [jgap-users] A bug??

Not sure if this is a bug or a misinterpretation on my part of JGAP functionality. I have been playing with the LesserThan, GreaterThan commands. I went into the code and saw that these classes are pre-set to ALWAYS return a boolean (which makes sense) and that they only execute the boolean method. The others are not implemented. Now, that execute_boolean method has a series of "if" to discern the Class type that the method should run, correct? To me that means I can give this method a double, or a integral and it will always give me a boolean in return, correct? I created a simple program with the following genotype:

CommandGene[][] nodeSets = {
        {
            ZERO = Variable.create(conf, "ZERO", CommandGene.FloatClass),
            TWO = Variable.create(conf, "TWO", CommandGene.FloatClass),
            new LesserThan(conf, CommandGene.BooleanClass)
        }
    };

The script is set to return (and run) Boolean values and the fitness function runs the execute_boolean method and rewards the individual if it returns true from the analysis, the variables are set always with zero and 2. The script is attached in case someone wants to see it. Anyway, that should return something like ZERO < TWO or something similar, correct? Instead, it returns this error:

Exception in thread "main" org.jgap.InvalidConfigurationException: java.lang.RuntimeException: Chromosome (depth 1, index 0) requires a terminal of return type class java.lang.Boolean (sub return type 0) but there is no such node available
        at org.jgap.gp.impl.GPGenotype.randomInitialGenotype(GPGenotype.java:401)
        at org.jgap.gp.impl.GPGenotype.randomInitialGenotype(GPGenotype.java:315)
        at org.jgap.gp.impl.GPGenotype.randomInitialGenotype(GPGenotype.java:272)
        at org.jgap.gp.impl.GPGenotype.randomInitialGenotype(GPGenotype.java:224)
        at com.luisegarcia.gp.SimpleTest.create(SimpleTest.java:44)
        at com.luisegarcia.gp.SimpleTest.main(SimpleTest.java:61)
Caused by: java.lang.RuntimeException: Chromosome (depth 1, index 0) requires a terminal of return type class java.lang.Boolean (sub return type 0) but there is no such node available
        at org.jgap.gp.impl.ProgramChromosome.selectNode(ProgramChromosome.java:524)
        at org.jgap.gp.impl.ProgramChromosome.growOrFullNode(ProgramChromosome.java:573)
        at org.jgap.gp.impl.ProgramChromosome.growOrFullNode(ProgramChromosome.java:654)
        at org.jgap.gp.impl.ProgramChromosome.growOrFullNode(ProgramChromosome.java:654)
        at org.jgap.gp.impl.ProgramChromosome.growOrFull(ProgramChromosome.java:273)
        at org.jgap.gp.impl.GPProgram.growOrFull(GPProgram.java:208)
        at org.jgap.gp.impl.DefaultProgramCreator.create(DefaultProgramCreator.java:35)
        at org.jgap.gp.impl.GPPopulation.create(GPPopulation.java:511)
        at org.jgap.gp.impl.GPPopulation.create(GPPopulation.java:315)
        at org.jgap.gp.impl.GPPopulation.create(GPPopulation.java:241)
        at org.jgap.gp.impl.DefaultPopulationCreator.initialize(DefaultPopulationCreator.java:68)
        at org.jgap.gp.impl.GPGenotype.randomInitialGenotype(GPGenotype.java:398)
        ... 5 more
Java Result: 1

The only way it runs is if I add the terminal "False", in which case it never returns True because it only reads "false" and does not compares the values of the variables. I checked the code and I think there is something wrong in either MathCommand or GPPopulation. I could not figure it out. Unless, of course, I am not using the library as intended.
Thanks!
Luis

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users
Loading...