GP: Saving an evolved program

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

GP: Saving an evolved program

Felix H. Dahlke-3
Hi,

I'm planning to save and execute a program evolved using GP. What is the
best way to do that?

I tried to store the first chromosome (there never seem to be more) of
my evolved program using the getPersistentRepresentation() method as
follows:

    IGPProgram p  = gp.getAllTimeBest();
    ProgramChromosome pc = p.getChromosome(0);
    String pr = pc.getPersistentRepresentation();

This works fine, pr looks like this:

    <org.jgap.gp.function.Add%23%3A2%3Ajava.lang.Class%3A0%3Anull%7Enull%7E>
   
<org.jgap.gp.terminal.Argument%23%3A0%3Ajava.lang.Class%3A0%3Anull%7Enull%7E>
    <org.jgap.gp.function.Add%23%3A2%3Ajava.lang.Class%3A0%3Anull%7Enull%7E>
   
<org.jgap.gp.terminal.Argument%23%3A0%3Ajava.lang.Class%3A0%3Anull%7Enull%7E>
   
<org.jgap.gp.terminal.Argument%23%3A0%3Ajava.lang.Class%3A0%3Anull%7Enull%7E>

I then try to load the chromosome from the persistent representation:

    ProgramChromosome npc = new ProgramChromosome(gp.getGPConfiguration());
    npc.setValueFromPersistentRepresentation(pr);

But this fails with the following exception:

    org.jgap.UnsupportedRepresentationException:
java.lang.NoSuchMethodException:
org.jgap.gp.function.Add.<init>(org.jgap.gp.impl.GPConfiguration)
    at
org.jgap.gp.impl.ProgramChromosome.setValueFromPersistentRepresentation(ProgramChromosome.java:1385)



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users

signature.asc (270 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: GP: Saving an evolved program

Klaus Meffert-5
Hello Felix,

you are right, the reason for the problem are that the GP commands do not
support the persistent representation. The solution would be to realize this
in CommandGene generically, which calls specialized methods in the GP
commands (which are sub classes of CommandGene).

Maybe you could instead use Xstream (or JGAPGPXStream). See class
org.jgap.util.PersistableObject for a convenient method on accessing
Xstream's functionality.

Best

Klaus
www.klaus-meffert.com

 

> -----Original Message-----
> From: Felix H. Dahlke [mailto:[hidden email]]
> Sent: Friday, September 17, 2010 2:28 PM
> To: [hidden email]
> Subject: [jgap-users] GP: Saving an evolved program
>
> Hi,
>
> I'm planning to save and execute a program evolved using GP.
> What is the best way to do that?
>
> I tried to store the first chromosome (there never seem to be
> more) of my evolved program using the
> getPersistentRepresentation() method as
> follows:
>
>     IGPProgram p  = gp.getAllTimeBest();
>     ProgramChromosome pc = p.getChromosome(0);
>     String pr = pc.getPersistentRepresentation();
>
> This works fine, pr looks like this:
>
>    
> <org.jgap.gp.function.Add%23%3A2%3Ajava.lang.Class%3A0%3Anull%
> 7Enull%7E>
>    
> <org.jgap.gp.terminal.Argument%23%3A0%3Ajava.lang.Class%3A0%3A
> null%7Enull%7E>
>    
> <org.jgap.gp.function.Add%23%3A2%3Ajava.lang.Class%3A0%3Anull%
> 7Enull%7E>
>    
> <org.jgap.gp.terminal.Argument%23%3A0%3Ajava.lang.Class%3A0%3A
> null%7Enull%7E>
>    
> <org.jgap.gp.terminal.Argument%23%3A0%3Ajava.lang.Class%3A0%3A
> null%7Enull%7E>
>
> I then try to load the chromosome from the persistent representation:
>
>     ProgramChromosome npc = new
> ProgramChromosome(gp.getGPConfiguration());
>     npc.setValueFromPersistentRepresentation(pr);
>
> But this fails with the following exception:
>
>     org.jgap.UnsupportedRepresentationException:
> java.lang.NoSuchMethodException:
> org.jgap.gp.function.Add.<init>(org.jgap.gp.impl.GPConfiguration)
>     at
> org.jgap.gp.impl.ProgramChromosome.setValueFromPersistentRepre
> sentation(ProgramChromosome.java:1385)
>
>
>


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users
Reply | Threaded
Open this post in threaded view
|

Re: GP: Saving an evolved program

Felix H. Dahlke-3
Thanks, I'll look into both ways, hopefully offering a patch if I can
make the first one work.

Are there any plans on storing actual Java byte code? Would that make sense?

On 09/20/2010 10:52 AM, Klaus Meffert wrote:

> Hello Felix,
>
> you are right, the reason for the problem are that the GP commands do not
> support the persistent representation. The solution would be to realize this
> in CommandGene generically, which calls specialized methods in the GP
> commands (which are sub classes of CommandGene).
>
> Maybe you could instead use Xstream (or JGAPGPXStream). See class
> org.jgap.util.PersistableObject for a convenient method on accessing
> Xstream's functionality.
>
> Best
>
> Klaus
> www.klaus-meffert.com
>
>  
>
>> -----Original Message-----
>> From: Felix H. Dahlke [mailto:[hidden email]]
>> Sent: Friday, September 17, 2010 2:28 PM
>> To: [hidden email]
>> Subject: [jgap-users] GP: Saving an evolved program
>>
>> Hi,
>>
>> I'm planning to save and execute a program evolved using GP.
>> What is the best way to do that?
>>
>> I tried to store the first chromosome (there never seem to be
>> more) of my evolved program using the
>> getPersistentRepresentation() method as
>> follows:
>>
>>     IGPProgram p  = gp.getAllTimeBest();
>>     ProgramChromosome pc = p.getChromosome(0);
>>     String pr = pc.getPersistentRepresentation();
>>
>> This works fine, pr looks like this:
>>
>>    
>> <org.jgap.gp.function.Add%23%3A2%3Ajava.lang.Class%3A0%3Anull%
>> 7Enull%7E>
>>    
>> <org.jgap.gp.terminal.Argument%23%3A0%3Ajava.lang.Class%3A0%3A
>> null%7Enull%7E>
>>    
>> <org.jgap.gp.function.Add%23%3A2%3Ajava.lang.Class%3A0%3Anull%
>> 7Enull%7E>
>>    
>> <org.jgap.gp.terminal.Argument%23%3A0%3Ajava.lang.Class%3A0%3A
>> null%7Enull%7E>
>>    
>> <org.jgap.gp.terminal.Argument%23%3A0%3Ajava.lang.Class%3A0%3A
>> null%7Enull%7E>
>>
>> I then try to load the chromosome from the persistent representation:
>>
>>     ProgramChromosome npc = new
>> ProgramChromosome(gp.getGPConfiguration());
>>     npc.setValueFromPersistentRepresentation(pr);
>>
>> But this fails with the following exception:
>>
>>     org.jgap.UnsupportedRepresentationException:
>> java.lang.NoSuchMethodException:
>> org.jgap.gp.function.Add.<init>(org.jgap.gp.impl.GPConfiguration)
>>     at
>> org.jgap.gp.impl.ProgramChromosome.setValueFromPersistentRepre
>> sentation(ProgramChromosome.java:1385)
>>
>>
>>
>


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users

signature.asc (270 bytes) Download Attachment