marshalling GPPopulation

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

marshalling GPPopulation

Simone Bronzin
Hi all,

Is there any easy way to marshal and unmarshal a GPPopulation?

thank you,

Simone Bronzin
Unitary
Executive

mobile: +39.3939459672



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users
Reply | Threaded
Open this post in threaded view
|

Re: marshalling GPPopulation

Klaus Meffert-5
Simone,

You could use Xstream, which is includes with JGAP. E.g.:

//To read an object from file
      XStream xstream = new XStream();
      File f = new File(a_filename);
      InputStream oi = new FileInputStream(f);
      GPGenotype result = (GPGenotype) xstream.fromXML(oi);

// To write, use xstream.toXML

Or use xstream.marshal(..) and xstream.unmarshal --> also see
Internet-documentation

Best

Klaus
www.klaus-meffert.com

 

> -----Original Message-----
> From: Simone Bronzin [mailto:[hidden email]]
> Sent: Friday, September 11, 2009 11:30 AM
> To: [hidden email]
> Subject: [jgap-users] marshalling GPPopulation
>
> Hi all,
>
> Is there any easy way to marshal and unmarshal a GPPopulation?
>
> thank you,
>
> Simone Bronzin
> Unitary
> Executive
>
> mobile: +39.3939459672
>
>
>
> --------------------------------------------------------------
> ----------------
> Let Crystal Reports handle the reporting - Free Crystal
> Reports 2008 30-Day trial. Simplify your report design,
> integration and deployment - and focus on what you do best,
> core application coding. Discover what's new with Crystal
> Reports now.  http://p.sf.net/sfu/bobj-july 
> _______________________________________________
> jgap-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jgap-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users
Reply | Threaded
Open this post in threaded view
|

Re: marshalling GPPopulation

Klaus Meffert-5
In reply to this post by Simone Bronzin
Simone,

the main cause is that either result is null or the GP configuration of
result. Please ensure that result is not null when writing to a file.
I would also suggest to not append to the file in this case.

Normally, you should not marhal the GP configuration as it could become
quite lengthy as XML, maybe a circular reference could occur. Better would
be rebuilding the GP config. After unmarshalling a GPProgram and setting the
config. to it.

Best

Klaus
www.klaus-meffert.com

 

> -----Original Message-----
> From: Simone Bronzin [mailto:[hidden email]]
> Sent: Tuesday, September 15, 2009 11:55 AM
> To: Klaus Meffert
> Cc: [hidden email]
> Subject: RE: [jgap-users] marshalling GPPopulation
>
> Klaus,
>
> thank you for your reply. I got an error. Running this
>
> ...
>          XStream xstream = new XStream();
>
>         PrintWriter outFile = new PrintWriter(new
> FileOutputStream("gpprogram.xml", true));
>
>         String xml = xstream.toXML(gp.getAllTimeBest());
>
>         outFile.print(xml);
>         outFile.close();
>
> File f = new File("gpprogram.xml");
>         InputStream oi = new FileInputStream(f);
>         GPProgram result = (GPProgram) xstream.fromXML(oi);
>
>         double gpFitness = fitness.evaluate(gp);
>
> a NullPointerException is raised at the line
>
> protected double evaluate(final IGPProgram gpProgram) { ...
> gpProgram.getGPConfiguration().clearMemory(); // HERE ...
> }
>
>
> it seems that GPConfiguration.m_memory is not correctly set
> by the unmarshaling process, and remains null. Before diving
> into xstream documentation I was wondering if I missed something.
>
> Thank you,
>
> Simone
>
>
> Def. Quota Klaus Meffert <[hidden email]>:
>
> > Simone,
> >
> > You could use Xstream, which is includes with JGAP. E.g.:
> >
> > //To read an object from file
> >       XStream xstream = new XStream();
> >       File f = new File(a_filename);
> >       InputStream oi = new FileInputStream(f);
> >       GPGenotype result = (GPGenotype) xstream.fromXML(oi);
> >
> > // To write, use xstream.toXML
> >
> > Or use xstream.marshal(..) and xstream.unmarshal --> also see
> > Internet-documentation
> >
> > Best
> >
> > Klaus
> > www.klaus-meffert.com
> >
> >
> >
> >> -----Original Message-----
> >> From: Simone Bronzin [mailto:[hidden email]]
> >> Sent: Friday, September 11, 2009 11:30 AM
> >> To: [hidden email]
> >> Subject: [jgap-users] marshalling GPPopulation
> >>
> >> Hi all,
> >>
> >> Is there any easy way to marshal and unmarshal a GPPopulation?
> >>
> >> thank you,
> >>
> >> Simone Bronzin
> >> Unitary
> >> Executive
> >>
> >> mobile: +39.3939459672
> >>
> >>
> >>
> >> --------------------------------------------------------------
> >> ----------------
> >> Let Crystal Reports handle the reporting - Free Crystal
> Reports 2008
> >> 30-Day trial. Simplify your report design, integration and
> deployment
> >> - and focus on what you do best, core application coding. Discover
> >> what's new with Crystal Reports now.  
> http://p.sf.net/sfu/bobj-july 
> >> _______________________________________________
> >> jgap-users mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/jgap-users
> >
> >
>
>
>
> Simone Bronzin
> Unitary
> Executive
>
> mobile: +39.3939459672
> phone: +39.
>


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users