GP settings

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

GP settings

Luis Garcia-5
I need to create a GP to solve a problem which consists of several; variables. At the end, the program resulting should look something like:

If X > z then
If X > y then 
EXECUTE
Else
DONT EXECUTE
ELSE IF X < Z AND Y > X THEN
EXECUTE
END

X,Y,Z are double numbers and the "execute" or "don't execute" commands (the result) could be anything that we can interpret as the order (a boolean result of TRUE or FALSE, or a 1, -1, or a 1, 0 order... does not matter as long as we can discern what is telling us). I created this little genotype to test my basic concept; but there is something I am not doing right as I get mostly errors or if I get results is something like If(true) then (false) And (False) with no reference to the variables...

public GPGenotype create() throws InvalidConfigurationException {
            
        GPConfiguration conf = getGPConfiguration();
        Class[] types = {
            CommandGene.BooleanClass
        };
        Class[][] argTypes = {            
            {}
        };

        CommandGene[][] nodeSets = { 
        {
            X = Variable.create(conf, "X", CommandGene.FloatClass),
            Y = Variable.create(conf, "Y", CommandGene.FloatClass),
            Z = Variable.create(conf, "Z", CommandGene.FloatClass),            
                    
            new If(conf, CommandGene.BooleanClass),
            new IfElse(conf, CommandGene.BooleanClass),
            new LesserThan(conf, CommandGene.BooleanClass),
            new GreaterThan(conf, CommandGene.BooleanClass),
            new And(conf),
            new Or(conf),
            new Equals(conf, CommandGene.BooleanClass),
            new True(conf,CommandGene.BooleanClass),
            new False(conf,CommandGene.BooleanClass),
            //new Terminal(conf, CommandGene.FloatClass, -1.0d, 1.0d, true),
        }
        };

        return GPGenotype.randomInitialGenotype(conf, types, argTypes, nodeSets,
            20, true);
    }


The number of variables, by the way, is much larger (about 17); but I don't think that matters as it is the same concept.

Thanks,
Luis

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users
Loading...