swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving object with lispAppArchiver?


From: Marcus G. Daniels
Subject: Re: Saving object with lispAppArchiver?
Date: 06 Sep 2000 08:39:28 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "MP" ==   <address@hidden> writes:

MP> is it possible to save object's variables to a file
MP> using lispAppArchiver? I'm saving data from simulation to file
MP> using EZGraph but I want also save a setting of modelSwarm etc. 

Here's an example using hdf5AppArchiver for saving simulation data to
a file.  HDF5 is good for logging data because it is fast and random-access.
If you prefer Lisp data files, simply replace "hdf5AppArchiver" with 
"lispAppArchiver". 

To load the HDF5 into R, you'd run:

$ R
> library(hdf5)
> hdf5load("TestArchiverSave.hdf")

Then you can do statistics on the saved data, e.g.:

> sum(agentList$ival)

import java.util.LinkedList;
import java.util.List;
import swarm.Globals;

public class TestArchiverSave {
    List agentList;

    class Agent {
        public int ival;
        public double dval;

        Agent (int ival, double dval) {
            super ();

            this.ival = ival;
            this.dval = dval;
        }
    }

    TestArchiverSave () {
        super ();
        agentList = new LinkedList ();

        for (int i = 0; i < 10; i++)
            agentList.add (new Agent (i + 1, i + 2));

        Globals.env.hdf5AppArchiver.putShallow$object ("agentList", agentList);
        Globals.env.hdf5AppArchiver.sync ();
    }

    static void main (String []args) {
        Globals.env.initSwarm ("TestArchiverSave",
                               "0.0",
                               "address@hidden",
                               args);

        new TestArchiverSave ();
    }
    
}


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]