marshalling GPPopulation

View: New views
3 Messages — Rating Filter:   Alert me  

marshalling GPPopulation

by Simone Bronzin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
jgap-users@...
https://lists.sourceforge.net/lists/listinfo/jgap-users

Re: marshalling GPPopulation

by Klaus Meffert-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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:simone.bronzin@...]
> Sent: Friday, September 11, 2009 11:30 AM
> To: jgap-users@...
> 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
> jgap-users@...
> 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
jgap-users@...
https://lists.sourceforge.net/lists/listinfo/jgap-users

Parent Message unknown Re: marshalling GPPopulation

by Klaus Meffert-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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:simone.bronzin@...]
> Sent: Tuesday, September 15, 2009 11:55 AM
> To: Klaus Meffert
> Cc: jgap-users@...
> 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 <jgap@...>:
>
> > 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:simone.bronzin@...]
> >> Sent: Friday, September 11, 2009 11:30 AM
> >> To: jgap-users@...
> >> 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
> >> jgap-users@...
> >> https://lists.sourceforge.net/lists/listinfo/jgap-users
> >
> >
>
>
>
> Simone Bronzin
> Unitary
> Executive
>
> mobile: +39.3939459672
> phone: +39.
>


------------------------------------------------------------------------------
Come build with us! The BlackBerry® 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-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
jgap-users mailing list
jgap-users@...
https://lists.sourceforge.net/lists/listinfo/jgap-users